2 # fshalt [-r] - sync (flush) and, if possible, halt all file servers
3 # and optionally reboot
11 echo usage: $0 '[-r]' >[1=2]
20 # start venti flushing
21 venti/sync -h localhost >[2]/dev/null &
22 venti/sync >[2]/dev/null &
24 unmount /mnt/consoles >[2]/dev/null
25 kill consolefs | rc # don't compete with /mnt/consoles
28 f=`{ls /srv/fscons*>[2]/dev/null}
29 k=`{ls /srv/kfs*cmd >[2]/dev/null|sort -r}
39 if(! dial/expect -t 120 ': ')
40 echo -n 'not synced...' > /dev/cons
44 # flush the last bit of possible fossil traffic
46 venti/sync -h localhost >[2]/dev/null &
47 venti/sync >[2]/dev/null &
56 disk/kfscmd -n `{echo $i | sed -n 's%/srv/kfs.(.*).cmd%\1%p'} sync
61 # halting (binaries we run can't be on the fs we're halting)
64 cp /bin/dial/expect /tmp
66 cp /bin/disk/kfscmd /tmp
72 cp /rc/lib/rcmain /tmp/lib
76 # put this in a shell function so this rc script doesn't get read
77 # when it's no longer accessible
85 if(! expect -t 60 ': ')
86 echo -n 'not halted...' > /dev/cons
96 kfscmd -n `{echo $i | sed -n 's%/srv/kfs.(.*).cmd%\1%p'} halt
104 echo reboot >'#c/reboot'