fshalt 958 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/rc
  2. # halt - sync (flush) and, if possible, halt all file servers
  3. rfork e
  4. path=(/bin)
  5. builtin cd /
  6. f=`{ls /srv/fscons*>[2]/dev/null}
  7. k=`{ls /srv/kfs*cmd >[2]/dev/null|sort -r}
  8. echo -n syncing...
  9. for(i in $f){
  10. echo -n $i...
  11. {
  12. echo fsys all sync
  13. if(! dial/expect -qt 120 ': ')
  14. echo -n 'not synced...' > /dev/cons
  15. } < $f >> $f
  16. }
  17. echo -n venti...
  18. venti/sync >[2]/dev/null
  19. for (i in $k){
  20. echo -n $i
  21. disk/kfscmd -n `{echo $i | sed 's%/srv/kfs.(.*).cmd%\1%'} sync
  22. sleep 2
  23. }
  24. # halting (binaries we run can't be on the fs we're halting)
  25. ramfs
  26. builtin cd /tmp
  27. cp /bin/dial/expect /tmp
  28. cp /bin/echo /tmp
  29. cp /bin/disk/kfscmd /tmp
  30. cp /bin/rc /tmp
  31. cp /bin/sed /tmp
  32. bind /tmp /bin
  33. echo
  34. echo -n halting...
  35. for(i in $f){
  36. echo -n $i...
  37. {
  38. echo fsys all halt
  39. if(! expect -qt 120 ': ')
  40. echo -n 'not halted...' > /dev/cons
  41. } < $f >> $f
  42. }
  43. for (i in $k){
  44. echo -n $i...
  45. kfscmd -n `{echo $i | sed 's%/srv/kfs.(.*).cmd%\1%'} halt
  46. }
  47. echo
  48. echo done