]> git.lizzy.rs Git - plan9front.git/blobdiff - rc/bin/fshalt
remove !tcp22 service
[plan9front.git] / rc / bin / fshalt
index 681311f1703ea4107b18f6144d80449662c342f1..2fed2465af5ce799f08c8b2dd584e82aace99817 100755 (executable)
@@ -1,8 +1,9 @@
 #!/bin/rc
 # fshalt [-r] - sync (flush) and, if possible, halt all file servers
 #      and optionally reboot
-rfork e
+rfork en
 reboot=no
+scram=no
 switch ($#*) {
 case 0
 case 1
@@ -14,40 +15,36 @@ case *
 
 path=(/bin)
 builtin cd /
-
-setrtc
+bind -c '#s' /srv
+bind '#p' /proc
 
 unmount /mnt/consoles >[2]/dev/null
 kill consolefs | rc                    # don't compete with /mnt/consoles
 sleep 1
 
-k=`{ls /srv/kfs*cmd >[2]/dev/null|sort -r}
 c=`{ls /srv/cwfs*cmd >[2]/dev/null}
+h=`{ls /srv/hjfs*cmd >[2]/dev/null}
 
-for (i in $k){
-       echo -n $i... 
-       switch($i){
-       case /srv/kfs.cmd
-               disk/kfscmd sync
-       case *
-               disk/kfscmd -n `{echo $i | sed -n 's%/srv/kfs.(.*).cmd%\1%p'} sync
-       }
-       sleep 2
+# for scram, don't scram other systems
+bind -b '#P' /dev
+if(! ~ $reboot yes){
+       if (test -e '#P'/apm)
+               scram=yes
+       if (test -e '#P'/acpitbls -a -e '#P'/iow)
+               scram=yes
 }
 
 # halting (binaries we run can't be on the fs we're halting)
 ramfs
 builtin cd /tmp
-cp /bin/dial/expect /tmp
-cp /bin/disk/kfscmd /tmp
 cp /bin/echo /tmp
-cp /bin/iostats /tmp
 mkdir /tmp/lib
 cp /rc/lib/rcmain /tmp/lib
 cp /bin/ns /tmp
 cp /bin/rc /tmp
 cp /bin/sed /tmp
 cp /bin/sleep /tmp
+cp /bin/scram /tmp
 bind /tmp /rc
 bind /tmp /bin
 
@@ -56,20 +53,16 @@ bind /tmp /bin
 fn x {
        echo
        echo -n halting...
-       for (i in $k){
-               echo -n $i... 
-               switch($i){
-               case /srv/kfs.cmd
-                       kfscmd halt
-               case *
-                       kfscmd -n `{echo $i | sed -n 's%/srv/kfs.(.*).cmd%\1%p'} halt
-               }
-       }
        for (i in $c){
                echo -n $i...
                echo halt >>$i
                sleep 2
        }
+       for(i in $h){
+               echo -n $i
+               echo halt >>$i
+               sleep 2
+       }
        echo
        echo done halting
 
@@ -77,6 +70,10 @@ fn x {
                echo rebooting...
                echo reboot >'#c/reboot'
        }
+       if (~ $scram yes){
+               scram
+               echo 'It''s now safe to turn off your computer'
+       }
 }
 
 x