#!/bin/sh # # rc.halt This file is executed by init when it goes into runlevel # 0 (halt) or runlevel 6 (reboot). It kills all processes, # unmounts file systems and then either halts or reboots. # # Author: Miquel van Smoorenburg, # Modified for RHS Linux by Damien Neil # # Set the path. PATH=/sbin:/bin:/usr/bin:/usr/sbin # See how we were called. case "$0" in *halt) message="The system is halted" command="halt -p" ;; *reboot) message="Please stand by while rebooting the system..." command="reboot" ;; *) echo "$0: call me as \"rc.halt\" or \"rc.reboot\" please!" exit 1 ;; esac # Kill all processes. [ "${BASH+bash}" = bash ] && enable kill action "Sending all processes the TERM signal..." kill -15 -1 sleep 5 action "Sending all processes the KILL signal.." kill -9 -1 # Write to wtmp file before unmounting /var halt -w # Turn off swap, then unmount file systems. action "Turning off swap and accounting" swapoff -a [ -x /sbin/accton ] && /sbin/accton action "Unmounting file systems" umount -a -f mount -n -o remount,ro / # turn off raid if [ -x /sbin/raidstop -a -f /etc/raidtab ]; then action "Turning off RAID" /sbin/raidstop -a fi # Remount read only anything that's left mounted. #echo "Remounting remaining filesystems (if any) readonly" mount | awk '/ext2/ { print $3 }' | while read line; do mount -n -o ro,remount $line done # Now halt or reboot. echo "$message" if [ -f /fastboot ]; then echo "On the next boot fsck will be skipped." elif [ -f /forcefsck ]; echo "On the next boot fsck will be forced." fi eval $command -i -d