#!/bin/sh # called as rc.halt - shut the system down # called as rc.reboot - reboot the system # in either case the preparations are identical PATH=/sbin:/bin/:/usr/bin # avoid staircase stty onlcr case "$0" in *.halt) command="halt" ;; *.reboot) command="reboot" ;; *) echo "$0: I must be rc.halt or rc.reboot!" exit 1 esac # do the kill thing killall5 -15 sleep 5 killall5 -9 # write reboot or halt to wtmp $command -w # unmount remote file systems echo "Unmounting remote filesystems" umount -a -tnfs # turn off swap echo "Turning off swap" swapoff -a # unmount local file systems echo "Unmounting local filesystems" umount -a -tnonfs echo "Remounting root file system readonly" mount -n -o remount,ro / # just in case sync # now halt if we are halting, reboot if we are rebooting if [ "$command" = "halt" ]; then echo "Halting" /sbin/halt -d -f -i -p else echo "Rebooting" /sbin/reboot -d -f -i fi