123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- RC="[${0##*/}]"
- umask 022
- IFS='
- '
- PATH=/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin
- LC_ALL=C
- stty onlcr 0>&1
- trap "" HUP INT QUIT ABRT TERM
- if grep -q '^RC_HWCLOCK=local' /etc/rc.conf
- then
- echo "${RC}: Saving hardware clock in local time"
- hwclock --systohc --localtime
- else
- echo "${RC}: Saving hardware clock in UTC"
- hwclock --systohc --utc
- fi
- if grep -E -q -m 1 '(usr|grp)quota' /etc/fstab
- then
- echo "${RC}: Setting any quota file system to OFF"
- quotaoff -va
- fi
- echo "${RC}: Saving random number generator"
- echo " /dev/urandom <-> /etc/random-seed ..."
- size="$(cat /proc/sys/kernel/random/poolsize)" || size=512
- dd if=/dev/urandom of=/etc/random-seed count=1 bs=$size
- chmod 600 /etc/random-seed; unset -v size
- halt -w
- sync
- if test -x /etc/rc.d/rc.fuse
- then
- /etc/rc.d/rc.fuse stop > /dev/null
- fi
- echo "${RC}: Sending the TERM signal to all the processes"
- killall5 -15 -o $$
- sleep 9
- echo "${RC}: Deactivating swap devices"
- swapoff -v -a
- echo "${RC}: Unmounting local and remote file systems"
- umount -v -a -r
- sleep 1
- sync
- echo "${RC}: Remounting root filesystem in read-only mode"
- mount -v -n -o remount,ro /
- wait
- case $0 in
- *.reboot)
- echo "Rebooting ..."
- exec reboot -d -f
- ;;
- *)
- exec halt -d -f -p
- ;;
- esac
|