fs

morpheus filesystem files
git clone git://git.2f30.org/fs
Log | Files | Refs

rc.shutdown (967B)


      1 #!/bin/sh
      2 
      3 umask 022
      4 
      5 . /etc/rc.conf
      6 
      7 case "$1" in
      8 reboot|poweroff)
      9 	;;
     10 *)
     11 	echo "Invalid action '$1' for rc.shutdown" 1>&2
     12 	exit 1
     13 	;;
     14 esac
     15 
     16 # Set linefeed mode to avoid staircase effect
     17 echo; /bin/stty onlcr
     18 
     19 echo Shutting down
     20 
     21 HWCLOCK_PARAMS="-w"
     22 case $HARDWARECLOCK in
     23 	"")
     24 		;;
     25 	UTC)
     26 		HWCLOCK_PARAMS="-u $HWCLOCK_PARAMS"
     27 		;;
     28 	localtime)
     29 		HWCLOCK_PARAMS="-l $HWCLOCK_PARAMS"
     30 		;;
     31 	*)
     32 		HWCLOCK_PARAMS=""
     33 		;;
     34 esac
     35 
     36 if [ -n "$HWCLOCK_PARAMS" ]; then
     37 	echo Saving system clock
     38 	[ -n "$TIMEZONE" ] && export TZ="$TIMEZONE"
     39 	/bin/hwclock $HWCLOCK_PARAMS /dev/rtc0
     40 	unset TZ
     41 fi
     42 
     43 echo Storing random seed
     44 /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null
     45 
     46 /bin/svc -k
     47 
     48 /bin/killall5 -s TERM
     49 /bin/sleep 3
     50 /bin/killall5 -s KILL
     51 
     52 echo Remounting root as read-only
     53 /bin/mount -o remount,ro /
     54 
     55 echo Unmounting filesystems
     56 /bin/umount -a
     57 
     58 /bin/sync
     59 /bin/sleep 3
     60 wait
     61 
     62 echo bye
     63 
     64 case "$1" in
     65 reboot)
     66 	/bin/halt -r
     67 	;;
     68 poweroff)
     69 	/bin/halt -p
     70 	;;
     71 esac