#! /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 setglobal NETDOWN = 'yes' setglobal 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]* setglobal INIT_HALT = 'POWEROFF' with [Hh]* setglobal INIT_HALT = 'HALT' with * setglobal 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. setglobal hddown = '"-h'" if grep -qs '^md.*active' /proc/mdstat { setglobal hddown = ''"" } # If INIT_HALT=HALT don't poweroff. setglobal poweroff = '"-p'" if test $INIT_HALT = "HALT" { setglobal poweroff = ''"" } # Make it possible to not shut down network interfaces, # needed to use wake-on-lan setglobal netdown = '"-i'" if test $NETDOWN = "no" { setglobal 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 } :