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}
30 c=`{ls /srv/cwfs*cmd >[2]/dev/null}
40 if(! dial/expect -t 120 ': ')
41 echo -n 'not synced...' > /dev/cons
45 # flush the last bit of possible fossil traffic
47 venti/sync -h localhost >[2]/dev/null &
48 venti/sync >[2]/dev/null &
57 disk/kfscmd -n `{echo $i | sed -n 's%/srv/kfs.(.*).cmd%\1%p'} sync
68 # halting (binaries we run can't be on the fs we're halting)
71 cp /bin/dial/expect /tmp
73 cp /bin/disk/kfscmd /tmp
79 cp /rc/lib/rcmain /tmp/lib
83 # put this in a shell function so this rc script doesn't get read
84 # when it's no longer accessible
92 if(! expect -t 60 ': ')
93 echo -n 'not halted...' > /dev/cons
103 kfscmd -n `{echo $i | sed -n 's%/srv/kfs.(.*).cmd%\1%p'} halt
111 echo reboot >'#c/reboot'