#!/bin/sh # # shutdwn Common script for system halt/reboot. # # Author: Miquel van Smoorenburg, # Modified for PLD Linux by Grzegorz Stanislawski # Changes: Arkadiusz Mi¶kiewicz # # $Id: rc.shutdown,v 1.5 2000/02/18 12:37:36 waszi Exp $ # Set the path. PATH=/sbin:/bin:/usr/bin:/usr/sbin # NLS NLS_DOMAIN="rc-scripts" # move to root dir cd / . /etc/rc.d/init.d/functions # Kill all processes. [ "${BASH+bash}" = bash ] && enable kill run_cmd "Sending all processes the TERM signal" killall5 -15 sleep 5 run_cmd "Sending all processes the KILL signal" killall5 -9 # Write to wtmp file before unmounting /var halt -w # Turn off swap, then unmount file systems. run_cmd "Turning off swap and accounting" swapoff -a [ -x /sbin/accton ] && /sbin/accton # Unmount file systems, killing processes if we have to. sig= retry=3 remaining=`awk '!/(^#| (proc|devfs|devpts|\/) |^none|^\/dev\/root)/ {print $2}' /proc/mounts` while [ -n "$remaining" -a "$retry" -gt 0 ] do _ERRORS="" show "Unmounting file systems"; busy if _ERRORS="`LC_ALL=C;LANG=C;initlog -c \"umount -a -f -t noproc\" 2>&1`"; then deltext; ok else deltext; fail; echo $_ERRORS fi unset _ERRORS sleep 2 remaining=`awk '!/(^#| (proc|devfs|devpts|\/) |^none|^\/dev\/root)/ {print $2}' /proc/mounts` [ -z "$remaining" ] && break [ -x /sbin/fuser ] && /sbin/fuser -k -m $sig $remaining >/dev/null sleep 5 retry=$(($retry-1)) sig=-9 done run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro / # turn off raid if [ -x /sbin/raidstop -a -f /etc/raidtab ]; then # we can not use raidstop -a here because this will only stop # devices listed in the default config file which is not always # the case. So we look only for the active raid devices if [ -f /proc/mdstat ] ; then mddevs=$(awk '/^md.* active/ {print $1}' /proc/mdstat) for mddev in $mddevs ; do MESSAGE="`nls "Turning off RAID for %s" "$mddev"`" run_cmd "$MESSAGE" raidstop /dev/$mddev done unset mddev mddevs fi #runcmd "Turning off RAID" /sbin/raidstop -a fi show "Remounting remaining filesystems ro mode"; busy if ( mount | awk '/ext2/ { print $3 }' | \ while read line; do mount -n -o ro,remount $line; done ); then deltext; ok else deltext; fail fi