#! /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|status { # 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 } } : (CommandList children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:NETDOWN) op:Equal rhs:{(yes)} spids:[31])] spids: [31] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PATH) op: Equal rhs: {(/sbin) (Lit_Other ":") (/usr/sbin) (Lit_Other ":") (/bin) (Lit_Other ":") (/usr/bin)} spids: [35] ) ] spids: [35] ) (AndOr children: [ (C {(Lit_Other "[")} {(-f)} {(/etc/default/halt)} {(Lit_Other "]")}) (C {(.)} {(/etc/default/halt)}) ] op_id: Op_DAmp ) (C {(.)} {(/lib/lsb/init-functions)}) (FuncDef name: do_stop body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$INIT_HALT"))} {(Lit_Other "=")} {(DQ )} {(Lit_Other "]")} ) ] action: [ (Case to_match: {(DQ ($ VSub_Name "$HALT"))} arms: [ (case_arm pat_list: [{(Lit_Other "[") (Pp) (Lit_Other "]") (Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:INIT_HALT) op: Equal rhs: {(POWEROFF)} spids: [107] ) ] spids: [107] ) ] spids: [100 104 111 -1] ) (case_arm pat_list: [{(Lit_Other "[") (Hh) (Lit_Other "]") (Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:INIT_HALT) op: Equal rhs: {(HALT)} spids: [121] ) ] spids: [121] ) ] spids: [114 118 125 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:INIT_HALT) op: Equal rhs: {(POWEROFF)} spids: [132] ) ] spids: [132] ) ] spids: [128 129 136 -1] ) ] spids: [91 97 139] ) ] spids: [-1 88] ) ] spids: [-1 142] ) (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$INIT_HALT"))} {(Lit_Other "=")} {(DQ (POWEROFF))} {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(-x)} {(/etc/init.d/ups-monitor)} {(Lit_Other "]")}) ] op_id: Op_DAmp ) ] action: [(C {(/etc/init.d/ups-monitor)} {(poweroff)})] spids: [-1 177] ) ] spids: [-1 185] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:hddown) op:Equal rhs:{(DQ (-h))} spids:[193])] spids: [193] ) (If arms: [ (if_arm cond: [(C {(grep)} {(-qs)} {(SQ <"^md.*active">)} {(/proc/mdstat)})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:hddown) op: Equal rhs: {(DQ )} spids: [215] ) ] spids: [215] ) ] spids: [-1 212] ) ] spids: [-1 220] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:poweroff) op:Equal rhs:{(DQ (-p))} spids:[228])] spids: [228] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$INIT_HALT"))} {(Lit_Other "=")} {(DQ (HALT))} {(Lit_Other "]")} ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:poweroff) op: Equal rhs: {(DQ )} spids: [254] ) ] spids: [254] ) ] spids: [-1 251] ) ] spids: [-1 259] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:netdown) op:Equal rhs:{(DQ (-i))} spids:[271])] spids: [271] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$NETDOWN"))} {(Lit_Other "=")} {(DQ (no))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:netdown) op: Equal rhs: {(DQ )} spids: [297] ) ] spids: [297] ) ] spids: [-1 294] ) ] spids: [-1 302] ) (C {(log_action_msg)} {(DQ ("Will now halt"))}) (C {(halt)} {(-d)} {(-f)} {($ VSub_Name "$netdown")} {($ VSub_Name "$poweroff")} {($ VSub_Name "$hddown")} ) ] spids: [69] ) spids: [64 68] ) (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list:[{(start)}{(status)}] spids:[337340347-1]) (case_arm pat_list: [{(restart)} {(reload)} {(force-reload)}] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Error: argument '") ($ VSub_Number "$1") ("' not supported"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[366])] ) (C {(exit)} {(3)}) ] spids: [350 355 375 -1] ) (case_arm pat_list:[{(stop)}] action:[(C {(do_stop)})] spids:[378379385-1]) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Usage: ") ($ VSub_Number "$0") (" start|stop"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[400])] ) (C {(exit)} {(3)}) ] spids: [388 389 409 -1] ) ] spids: [328 334 411] ) (C {(Lit_Other ":")}) ] )