crux-ports

My CRUX Linux ports
Log | Files | Refs | README

rc.shutdown (759B)


      1 #!/bin/sh
      2 umask 022
      3 
      4 . /etc/rc.conf
      5 
      6 case "$1" in
      7 reboot|poweroff) ;;
      8 *)
      9 	echo "Invalid action '$1' for rc.shutdown" >&2
     10 	exit 1
     11 	;;
     12 esac
     13 
     14 # avoid staircase effect by setting linefeed mode
     15 echo; /bin/stty onlcr
     16 
     17 echo Shutting down
     18 
     19 echo Saving system clock
     20 [ -n "$TIMEZONE" ] && export TZ="$TIMEZONE"
     21 /bin/hwclock -w -u /dev/rtc0
     22 unset TZ
     23 
     24 /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null
     25 
     26 echo Sending TERM to all processes
     27 /bin/killall5 -s TERM
     28 /bin/sleep 3
     29 echo Sending KILL to all processes
     30 /bin/killall5 -s KILL
     31 
     32 echo Remounting root as read-only
     33 /bin/mount -o remount,ro /
     34 
     35 echo Unmounting filesystems
     36 /bin/umount -a
     37 
     38 /bin/sync
     39 /bin/sleep 3
     40 wait
     41 
     42 echo Good bye.
     43 
     44 case "$1" in
     45 reboot) /bin/halt -r ;;
     46 poweroff) /bin/halt -p ;;
     47 esac