#!/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 [ "${DAEMONS[$i]:0:1}" != '!' ]; then ck_daemon ${DAEMONS[$i]#@} || /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 -1t /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 -t notmpfs,noramfs,nosysfs,noproc # 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