#! /bin/sh ### BEGIN INIT INFO # Provides: halt # Required-Start: # Required-Stop: # Default-Start: # Default-Stop: 0 # Short-Description: Execute the halt command. # Description: ### END INIT INFO setvar NETDOWN = 'yes' setvar PATH = "/sbin:/usr/sbin:/bin:/usr/bin" test -f /etc/default/halt && source /etc/default/halt source /lib/lsb/init-functions proc do_stop { if test $INIT_HALT = "" { match $HALT { with [Pp]* setvar INIT_HALT = 'POWEROFF' with [Hh]* setvar INIT_HALT = 'HALT' with * setvar INIT_HALT = 'POWEROFF' } } # See if we need to cut the power. if test $INIT_HALT = "POWEROFF" && test -x /etc/init.d/ups-monitor { /etc/init.d/ups-monitor poweroff } # Don't shut down drives if we're using RAID. setvar hddown = ""-h"" if grep -qs '^md.*active' /proc/mdstat { setvar hddown = """" } # If INIT_HALT=HALT don't poweroff. setvar poweroff = ""-p"" if test $INIT_HALT = "HALT" { setvar poweroff = """" } # Make it possible to not shut down network interfaces, # needed to use wake-on-lan setvar netdown = ""-i"" if test $NETDOWN = "no" { setvar netdown = """" } log_action_msg "Will now halt" halt -d -f $netdown $poweroff $hddown } match $1 { with start|status # No-op with restart|reload|force-reload echo "Error: argument '$1' not supported" >&2 exit 3 with stop do_stop with * echo "Usage: $0 start|stop" >&2 exit 3 } :