archboot/etc/rc.shutdown
Alexander Baldeck 2a150b1dca Initial revision
2007-02-22 22:46:50 +00:00

53 lines
1 KiB
Bash
Executable file

#!/bin/sh
#
# /etc/rc.shutdown
. /etc/rc.conf
. /etc/rc.d/functions
# avoid staircase effect
/bin/stty onlcr
echo "Shutting Down ..."
# Shutdown daemons
let i=${#DAEMONS[@]}
while [[ i -ge 0 ]]; do
if [[ `echo ${DAEMONS[$i]} | grep '^[^\!]' | wc -l` -eq 1 ]]; then
/etc/rc.d/${DAEMONS[$i]#@} stop
fi
let i=i-1
done
# find any leftover daemons and shut them down
if [ -d /var/run/daemons ]; then
for daemon in `ls /var/run/daemons`; do
/etc/rc.d/$daemon stop
done
fi
# removing psmouse module to fix some reboot issues on newer laptops
modprobe -r psmouse >/dev/null 2>&1
# Terminate all processes
echo "Sending SIGTERM To Processes ..."
/sbin/killall5 -15 &> /dev/null
/bin/sleep 5
echo "Sending SIGKILL To Processes ..."
/sbin/killall5 -9 &> /dev/null
echo "Deactivating Swap ..."
/sbin/swapoff -a
echo "Unmounting Filesystems ..."
/bin/umount -a
# Power off or reboot
if [ "$RUNLEVEL" = "0" ]; then
echo "[ POWER OFF ]"
/sbin/poweroff -d -f -i
else
echo " [ REBOOTING ]"
/sbin/reboot -d -f -i
fi
# End of file