#!/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.11 2000/06/23 09:11:10 wiget 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 if [ -x /sbin/quotaoff ]; then run_cmd "Turning off quotas for local filesystems" /sbin/quotaoff -a fi # Unmount file systems, killing processes if we have to. sig=-15 retry=3 force= remaining=`awk '!/(^#| proc | loopfs | devfs | devpts | shm |^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts` while [ -n "$remaining" -a "$retry" -gt 0 ] do show "Unmounting file systems" ; busy if ERRORS=`LC_ALL=C exec umount -a $FORCE -t noproc 2>&1` ; then deltext ; ok else deltext ; fail [ -n "$ERRORS" ] && echo "$ERRORS" fi sleep 2 remaining=`awk '!/(^#| proc | loopfs | devfs | devpts | shm |^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts` [ -z "$remaining" ] && break /sbin/fuser -k -m $sig $remaining > /dev/null sleep 5 retry=$(($retry-1)) sig=-9 force="-f" 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