diff options
| author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 17:14:36 +0300 |
|---|---|---|
| committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 17:14:36 +0300 |
| commit | 2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f (patch) | |
| tree | f6343b1ce11a8c87251dd27cf3d3e26b50693fa7 /rc/bin/replica/pull | |
| parent | e463eb40363ff4c68b1d903f4e0cdd0ac1c5977f (diff) | |
| download | plan9front-2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f.tar.xz | |
Import sources from 2011-03-30 iso image - rc
Diffstat (limited to 'rc/bin/replica/pull')
| -rwxr-xr-x | rc/bin/replica/pull | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/rc/bin/replica/pull b/rc/bin/replica/pull new file mode 100755 index 000000000..5b1fcc1e2 --- /dev/null +++ b/rc/bin/replica/pull @@ -0,0 +1,58 @@ +#!/bin/rc + +rfork en + +fn usage { + echo 'usage: replica/pull [-nv] [-c name] [-s name] replica-name [paths]' >[1=2] + exit usage +} + +. /rc/bin/replica/defs $* + +need clientlog serverlog clientdb clientroot serverroot + +# mount the server file system, update the log +must servermount +must serverupdate +must clientmount + +# download the log +n=`{ls -l $clientlog >[2]/dev/null |awk '{print $6}'} +s=`{ls -l $serverlog >[2]/dev/null |awk '{print $6}'} +if(~ $n 0 || ~ $#n 0 || test $s -lt $n){ + if(test -e $clientlog) must rm $clientlog + must fcp $serverlog $clientlog +} +if not{ + m=`{echo $n-1024 | hoc} + if(~ $m -*) + m=0 + cmp -s $serverlog $clientlog $m $m + x=$status + switch($x){ + case *': EOF' + must tail +^$n^c $serverlog >>$clientlog + case *': differ' + must rm $clientlog + must fcp $serverlog $clientlog + case '' + ; + case * + fatal cmp: $x + } +} + +# normally we'd do this after applylog, but we want +# applylog to be the last thing in this script, so we'll +# do it here instead, compacting changes from the +# _last_ applylog. + +ndb=`{echo $clientdb | sed 's;(.*)/(.*);\1/_\2;'} +must replica/compactdb $clientdb >$ndb +mv $ndb $clientdb + +# mount the client file system, apply the log +# this is the last thing in the script and is execed so that +# if replica/pull is overwritten nothing bad will happen. +# applylog takes care of itself as far as protection against being overwritten. +exec replica/applylog $opt $applyopt $clientdb $clientroot $serverroot $paths <$clientlog |
