#! /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 global NETDOWN := 'yes' global 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 = "" { matchstr $HALT { [Pp]* { global INIT_HALT := 'POWEROFF' } [Hh]* { global INIT_HALT := 'HALT' } * { global 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. global hddown := '"-h'" if grep -qs '^md.*active' /proc/mdstat { global hddown := ''"" } # If INIT_HALT=HALT don't poweroff. global poweroff := '"-p'" if test $INIT_HALT = "HALT" { global poweroff := ''"" } # Make it possible to not shut down network interfaces, # needed to use wake-on-lan global netdown := '"-i'" if test $NETDOWN = "no" { global netdown := ''"" } log_action_msg "Will now halt" halt -d -f $netdown $poweroff $hddown } matchstr $1 { start { # No-op } restart|reload|force-reload { echo "Error: argument '$1' not supported" > !2 exit 3 } stop { do_stop } * { echo "Usage: $0 start|stop" > !2 exit 3 } } :