#! /bin/sh # ### BEGIN INIT INFO # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Provides: unattended-upgrade-shutdown-check # Default-Start: 2 3 4 5 # Default-Stop: 0 6 # Short-Description: Check if unattended upgrades are being applied # Description: Check if unattended upgrades are being applied # and wait for them to finish ### END INIT INFO set -e global PATH := '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' global NAME := '"unattended-upgrades-shutdown'" global DESC := '"unattended package upgrades shutdown'" global SCRIPTNAME := ""/etc/init.d/$NAME"" global SHUTDOWN_HELPER := '"/usr/share/unattended-upgrades/unattended-upgrade-shutdown'" if test -x /usr/bin/python3 { global PYTHON := 'python3' } else { global PYTHON := 'python' } # Load the VERBOSE setting and other rcS variables source /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present source /lib/lsb/init-functions matchstr $1 { start|restart|force-reload|status { # nothing, just to keep update-rc.d happy (see debian #630732) } stop { if test -e $SHUTDOWN_HELPER { test $VERBOSE != "no" && log_action_begin_msg "Checking for running $DESC" $PYTHON $SHUTDOWN_HELPER test $VERBOSE != "no" && log_action_end_msg $Status $NAME } } * { echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" > !2 exit 3 } } : (CommandList children: [ (C {(set)} {(-e)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PATH) op: Equal rhs: {(/usr/local/sbin) (Lit_Other ":") (/usr/local/bin) (Lit_Other ":") (/sbin) (Lit_Other ":") (/bin) (Lit_Other ":") (/usr/sbin) (Lit_Other ":") (/usr/bin) } spids: [41] ) ] spids: [41] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:NAME) op: Equal rhs: {(DQ (unattended-upgrades-shutdown))} spids: [55] ) ] spids: [55] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DESC) op: Equal rhs: {(DQ ("unattended package upgrades shutdown"))} spids: [60] ) ] spids: [60] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SCRIPTNAME) op: Equal rhs: {(DQ (/etc/init.d/) ($ VSub_Name "$NAME"))} spids: [65] ) ] spids: [65] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SHUTDOWN_HELPER) op: Equal rhs: {(DQ (/usr/share/unattended-upgrades/unattended-upgrade-shutdown))} spids: [71] ) ] spids: [71] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-x)} {(/usr/bin/python3)} {(Lit_Other "]")}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:PYTHON) op:Equal rhs:{(python3)} spids:[91])] spids: [91] ) ] spids: [-1 88] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:PYTHON) op:Equal rhs:{(python)} spids:[97])] spids: [97] ) ] spids: [94 100] ) (C {(.)} {(/lib/init/vars.sh)}) (C {(.)} {(/lib/lsb/init-functions)}) (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list: [{(start)} {(restart)} {(force-reload)} {(status)}] spids: [130 137 144 -1] ) (case_arm pat_list: [{(stop)}] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-e)} {($ VSub_Name "$SHUTDOWN_HELPER")} {(Lit_Other "]")}) terminator: ) ] action: [ (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(KW_Bang "!") (Lit_Other "=")} {(DQ (no))} {(Lit_Other "]")} ) (C {(log_action_begin_msg)} {(DQ ("Checking for running ") ($ VSub_Name "$DESC"))} ) ] op_id: Op_DAmp ) (C {($ VSub_Name "$PYTHON")} {($ VSub_Name "$SHUTDOWN_HELPER")}) (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$VERBOSE"))} {(KW_Bang "!") (Lit_Other "=")} {(DQ (no))} {(Lit_Other "]")} ) (C {(log_action_end_msg)} {($ VSub_QMark "$?")} {(DQ ($ VSub_Name "$NAME"))}) ] op_id: Op_DAmp ) ] spids: [-1 161] ) ] spids: [-1 220] ) ] spids: [146 147 223 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Usage: ") ($ VSub_Name "$SCRIPTNAME") (" {start|stop|status|restart|force-reload}") ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[237])] ) (C {(exit)} {(3)}) ] spids: [225 226 246 -1] ) ] spids: [122 128 248] ) (C {(Lit_Other ":")}) ] )