#! /bin/sh

# Calls /etc/rc.shutdown before any other shutdown scripts in
# rc0.d or rc6.d are run. Implements a shutdown analog to rc.local.
# Use a link number of K00 to ensure rc.shutdown is called before
# any services or daemons are stopped.
# 
# NOTE: Starting runlevel 0 for shutdown or runlevel 6 for 
# reboot does NOT run the Snn... links with "start"
# Entering runlevel 0 or 6 causes ALL links to be run with the argument
# "stop" See /usr/share/doc/sysv-rc/README.runlevels
# lsw 10/2/2008

PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions

case "$1" in
    stop)
	if [ -x /etc/rc.shutdown ]; then
	    log_begin_msg "Running local shutdown scripts (/etc/rc.shutdown)"
	    /etc/rc.shutdown
	    log_end_msg $?
	fi	
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    start)
	# no op in case link is installed in a normal runlevel
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac
