1 #!/usr/local/plan9/bin/rc
3 # the fossil configuration is stored at the 127kB offset in the disk
4 # and extends for at most 1 kB.
8 echo 'usage: fossil/conf [-w] /dev/sdC0/fossil [config]' >[1=2]
13 while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 --){
25 if(~ $wflag no && ! ~ $#* 1)
27 if(~ $wflag yes && ! ~ $#* 1 2)
31 if(! 9 test -f $disk){
32 echo 'unknown disk' $1 >[1=2]
37 rm -f /tmp/fossilconf.$pid
41 {echo fossil config; cat $2} >/tmp/fossilconf.$pid || exit oops
42 if(! 9 test -s /tmp/fossilconf.$pid){
43 echo 'config is empty; will not install' >[1=2]
46 if(9 test `{9 ls -l /tmp/fossilconf.$pid | awk '{print $6}'} -gt 1024){
47 echo 'config is too long; max is a little less than a kilobyte' >[1=2]
50 9 dd -quiet 1 -bs 1024 -count 1 -if $disk -iseek 127 \
51 >/tmp/_fossilconf.old || exit backup
52 9 dd -quiet 1 -count 2 </dev/zero >>/tmp/fossilconf.$pid || exit dd
53 9 dd -quiet 1 -bs 1024 -count 1 -if /tmp/fossilconf.$pid \
54 -trunc 0 -of $disk -oseek 127 || exit dd2
58 9 dd -quiet 1 -bs 1024 -count 1 -if $disk -iseek 127 |
59 zerotrunc >/tmp/fossilconf.$pid
61 if(! cmp -s <{sed 1q /tmp/fossilconf.$pid} <{echo fossil config}){
62 echo 'config has bad header' >[1=2]
66 sed 1d /tmp/fossilconf.$pid