Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 1 | #!/bin/sh -e |
| 2 | |
| 3 | set -euo pipefail |
| 4 | |
Anthony Wilson | 189cf24 | 2018-10-23 01:18:21 -0500 | [diff] [blame] | 5 | OPTS="bmcstate,bootprogress,chassiskill,chassisoff,chassison,chassisstate,hoststate,\ |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame^] | 6 | osstate,power,poweroff,poweron,state,status,hostrebootoff,hostrebooton,recoveryoff,recoveryon,\ |
| 7 | bmcrebootoff, bmcrebooton" |
Anthony Wilson | 0f35983 | 2018-09-13 14:28:07 -0500 | [diff] [blame] | 8 | |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 9 | USAGE="Usage: obmcutil [-h] [--wait] [--verbose] |
Anthony Wilson | 0f35983 | 2018-09-13 14:28:07 -0500 | [diff] [blame] | 10 | {$OPTS}" |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 11 | |
| 12 | INTERFACE_ROOT=xyz.openbmc_project |
| 13 | STATE_INTERFACE=$INTERFACE_ROOT.State |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 14 | CONTROL_INTERFACE=$INTERFACE_ROOT.Control |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 15 | |
| 16 | OBJECT_ROOT=/xyz/openbmc_project |
| 17 | STATE_OBJECT=$OBJECT_ROOT/state |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 18 | CONTROL_OBJECT=$OBJECT_ROOT/control |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 19 | |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 20 | HOST_TIMEOUT_TARGET=obmc-host-timeout@0.target |
Vishwanatha Subbanna | 84b3b29 | 2019-11-04 05:43:19 -0600 | [diff] [blame] | 21 | HOST_CRASH_TARGET=obmc-host-crash@0.target |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 22 | |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 23 | ## NOTE: The following global variables are used only in the run_timeout cmd. |
| 24 | ## By declaring these globally instead of passing them through the |
| 25 | ## intermediary functions, which may not be "best practice", the readability |
| 26 | ## and cleanliness of the code should at least be increased. |
| 27 | |
| 28 | # The command passed in to be executed (e.g. poweron/off, status, etc.) |
| 29 | # This will be be used in some instances of error reporting |
| 30 | G_ORIG_CMD= |
| 31 | # The state an interface should be in after executing the requested command. |
| 32 | G_REQUESTED_STATE= |
| 33 | # The query to run during a poweron/off or chassison/off to check that |
| 34 | # the requested state (G_REQUESTED_STATE) of the interface has been reached. |
| 35 | G_QUERY= |
| 36 | # Wait the set period of time for state transitions to be successful before |
| 37 | # continuing on with the program or reporting an error if timeout reached. |
| 38 | G_WAIT= |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 39 | # Print the journal to the console |
| 40 | G_VERBOSE= |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 41 | |
Anthony Wilson | f3f16fa | 2018-09-13 14:10:52 -0500 | [diff] [blame] | 42 | print_help () |
| 43 | { |
| 44 | echo "$USAGE" |
| 45 | echo "" |
| 46 | echo "positional arguments:" |
Anthony Wilson | 0f35983 | 2018-09-13 14:28:07 -0500 | [diff] [blame] | 47 | echo " {$OPTS}" |
Anthony Wilson | f3f16fa | 2018-09-13 14:10:52 -0500 | [diff] [blame] | 48 | echo "" |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 49 | echo "Examples:" |
| 50 | echo "" |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame^] | 51 | echo "obmcutil hostrebootoff Disable auto reboot of Host from Quiesce state" |
| 52 | echo "obmcutil hostrebooton Enable auto reboot of Host from Quiesce state" |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 53 | echo "" |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame^] | 54 | echo "obmcutil bmcrebootoff Disable reboot of BMC" |
| 55 | echo "obmcutil bmcrebooton Enable reboot of BMC" |
| 56 | echo "" |
| 57 | echo "obmcutil recoveryoff Disable handling boot watchdog timeout and host crash" |
| 58 | echo " Also, disable BMC and Host auto reboots" |
| 59 | echo "" |
| 60 | echo "obmcutil recoveryon Enable handling boot watchdog timeout and host crash" |
| 61 | echo " Also, enable BMC and Host auto reboots" |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 62 | echo "" |
Anthony Wilson | f3f16fa | 2018-09-13 14:10:52 -0500 | [diff] [blame] | 63 | echo "optional arguments:" |
| 64 | echo " -h, --help show this help message and exit" |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 65 | echo " -w, --wait block until state transition succeeds or fails" |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 66 | echo " -v, --verbose print the journal to stdout if --wait is supplied" |
Anthony Wilson | f3f16fa | 2018-09-13 14:10:52 -0500 | [diff] [blame] | 67 | exit 0 |
| 68 | } |
| 69 | |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 70 | run_timeout () |
| 71 | { |
| 72 | local timeout="$1"; shift |
| 73 | local cmd="$@" |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 74 | local verbose_child= |
| 75 | |
Andrew Jeffery | 2869a92 | 2019-10-18 14:42:34 +1030 | [diff] [blame] | 76 | if [ -n "$G_VERBOSE" ]; then |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 77 | journalctl -f & |
| 78 | verbose_child=$! |
| 79 | fi |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 80 | |
| 81 | $cmd |
| 82 | |
| 83 | # Run a background query for the transition to the expected state |
| 84 | # This will be killed if the transition doesn't succeed within |
| 85 | # a timeout period. |
| 86 | ( |
| 87 | while ! grep -q $G_REQUESTED_STATE <<< $(handle_cmd $G_QUERY) ; do |
| 88 | sleep 1 |
| 89 | done |
| 90 | ) & |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 91 | wait_child=$! |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 92 | |
| 93 | # Could be bad if process is killed before 'timeout' occurs if |
| 94 | # transition doesn't succeed. |
| 95 | trap -- "" SIGTERM |
| 96 | |
| 97 | # Workaround for lack of 'timeout' command. |
| 98 | ( |
| 99 | sleep $timeout |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 100 | kill $wait_child |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 101 | ) > /dev/null 2>&1 & |
| 102 | |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 103 | if ! wait $wait_child; then |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 104 | echo "Unable to confirm '$G_ORIG_CMD' success" \ |
| 105 | "within timeout period (${timeout}s)" |
| 106 | fi |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 107 | |
Andrew Jeffery | 8be7029 | 2019-11-01 08:56:49 +1030 | [diff] [blame] | 108 | if [ -n "$verbose_child" ]; then |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 109 | kill $verbose_child |
| 110 | fi |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | run_cmd () |
| 114 | { |
| 115 | local cmd="$@"; |
| 116 | |
| 117 | if [ -n "$G_WAIT" ]; then |
| 118 | run_timeout $G_WAIT "$cmd" |
| 119 | else |
| 120 | $cmd |
| 121 | fi |
| 122 | } |
| 123 | |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 124 | set_property () |
| 125 | { |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 126 | run_cmd busctl set-property "$@" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 127 | } |
| 128 | |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 129 | get_property () |
| 130 | { |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 131 | G_WAIT="" |
| 132 | run_cmd busctl get-property "$@" |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | state_query () |
| 136 | { |
| 137 | local state=$(get_property "$@" | cut -d '"' -f2) |
| 138 | printf "%-20s: %s\n" $4 $state |
| 139 | } |
| 140 | |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 141 | print_usage_err () |
| 142 | { |
| 143 | echo "ERROR: $1" >&2 |
| 144 | echo "$USAGE" |
| 145 | exit 1 |
| 146 | } |
| 147 | |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 148 | mask_systemd_target () |
| 149 | { |
| 150 | target="$@" |
| 151 | systemctl mask $target |
| 152 | } |
| 153 | |
| 154 | unmask_systemd_target () |
| 155 | { |
| 156 | target="$@" |
| 157 | systemctl unmask $target |
| 158 | } |
| 159 | |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame^] | 160 | disable_bmc_reboot () |
| 161 | { |
| 162 | dir="/run/systemd/system/" |
| 163 | file="reboot-guard.conf" |
| 164 | units=("reboot" "poweroff" "halt") |
| 165 | |
| 166 | for unit in "${units[@]}"; do |
| 167 | mkdir -p ${dir}${unit}.target.d |
| 168 | echo -e "[Unit]\nRefuseManualStart=yes" >> ${dir}${unit}.target.d/${file} |
| 169 | done |
| 170 | } |
| 171 | |
| 172 | enable_bmc_reboot () |
| 173 | { |
| 174 | dir="/run/systemd/system/" |
| 175 | file="reboot-guard.conf" |
| 176 | units=("reboot" "poweroff" "halt") |
| 177 | |
| 178 | for unit in "${units[@]}"; do |
| 179 | rm -rf ${dir}${unit}.target.d/${file} |
| 180 | rm -rf ${dir}${unit}.target.d |
| 181 | done |
| 182 | } |
| 183 | |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 184 | handle_cmd () |
| 185 | { |
| 186 | case "$1" in |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 187 | chassisoff) |
| 188 | OBJECT=$STATE_OBJECT/chassis0 |
| 189 | SERVICE=$(mapper get-service $OBJECT) |
| 190 | INTERFACE=$STATE_INTERFACE.Chassis |
| 191 | PROPERTY=RequestedPowerTransition |
| 192 | VALUE=$INTERFACE.Transition.Off |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 193 | G_REQUESTED_STATE=$INTERFACE.PowerState.Off |
| 194 | G_QUERY="chassisstate" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 195 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE |
| 196 | ;; |
| 197 | chassison) |
| 198 | OBJECT=$STATE_OBJECT/chassis0 |
| 199 | SERVICE=$(mapper get-service $OBJECT) |
| 200 | INTERFACE=$STATE_INTERFACE.Chassis |
| 201 | PROPERTY=RequestedPowerTransition |
| 202 | VALUE=$INTERFACE.Transition.On |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 203 | G_REQUESTED_STATE=$INTERFACE.PowerState.On |
| 204 | G_QUERY="chassisstate" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 205 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE |
| 206 | ;; |
| 207 | poweroff) |
| 208 | OBJECT=$STATE_OBJECT/host0 |
| 209 | SERVICE=$(mapper get-service $OBJECT) |
| 210 | INTERFACE=$STATE_INTERFACE.Host |
| 211 | PROPERTY=RequestedHostTransition |
| 212 | VALUE=$INTERFACE.Transition.Off |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 213 | G_REQUESTED_STATE=$INTERFACE.HostState.Off |
| 214 | G_QUERY="hoststate" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 215 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE |
| 216 | ;; |
| 217 | poweron) |
| 218 | OBJECT=$STATE_OBJECT/host0 |
| 219 | SERVICE=$(mapper get-service $OBJECT) |
| 220 | INTERFACE=$STATE_INTERFACE.Host |
| 221 | PROPERTY=RequestedHostTransition |
| 222 | VALUE=$INTERFACE.Transition.On |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 223 | G_REQUESTED_STATE=$INTERFACE.HostState.Running |
| 224 | G_QUERY="hoststate" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 225 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE |
| 226 | ;; |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 227 | bmcstate) |
| 228 | OBJECT=$STATE_OBJECT/bmc0 |
| 229 | SERVICE=$(mapper get-service $OBJECT) |
| 230 | INTERFACE=$STATE_INTERFACE.BMC |
| 231 | PROPERTY=CurrentBMCState |
| 232 | state_query $SERVICE $OBJECT $INTERFACE $PROPERTY |
| 233 | ;; |
| 234 | chassisstate) |
| 235 | OBJECT=$STATE_OBJECT/chassis0 |
| 236 | SERVICE=$(mapper get-service $OBJECT) |
| 237 | INTERFACE=$STATE_INTERFACE.Chassis |
| 238 | PROPERTY=CurrentPowerState |
| 239 | state_query $SERVICE $OBJECT $INTERFACE $PROPERTY |
| 240 | ;; |
| 241 | hoststate) |
| 242 | OBJECT=$STATE_OBJECT/host0 |
| 243 | SERVICE=$(mapper get-service $OBJECT) |
| 244 | INTERFACE=$STATE_INTERFACE.Host |
| 245 | PROPERTY=CurrentHostState |
| 246 | state_query $SERVICE $OBJECT $INTERFACE $PROPERTY |
| 247 | ;; |
Alexander Filippov | 86cffd9 | 2019-04-03 16:29:57 +0300 | [diff] [blame] | 248 | osstate) |
| 249 | OBJECT=$STATE_OBJECT/host0 |
| 250 | SERVICE=$(mapper get-service $OBJECT) |
| 251 | INTERFACE=$STATE_INTERFACE.OperatingSystem.Status |
| 252 | PROPERTY=OperatingSystemState |
| 253 | state_query $SERVICE $OBJECT $INTERFACE $PROPERTY |
| 254 | ;; |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 255 | state|status) |
Alexander Filippov | 86cffd9 | 2019-04-03 16:29:57 +0300 | [diff] [blame] | 256 | for query in bmcstate chassisstate hoststate bootprogress osstate |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 257 | do |
| 258 | handle_cmd $query |
| 259 | done |
| 260 | ;; |
Anthony Wilson | 50c5f88 | 2018-09-13 14:19:37 -0500 | [diff] [blame] | 261 | bootprogress) |
| 262 | OBJECT=$STATE_OBJECT/host0 |
| 263 | SERVICE=$(mapper get-service $OBJECT) |
| 264 | INTERFACE=$STATE_INTERFACE.Boot.Progress |
| 265 | PROPERTY=BootProgress |
| 266 | state_query $SERVICE $OBJECT $INTERFACE $PROPERTY |
| 267 | ;; |
Anthony Wilson | 0f35983 | 2018-09-13 14:28:07 -0500 | [diff] [blame] | 268 | power) |
| 269 | OBJECT=/org/openbmc/control/power0 |
| 270 | SERVICE=$(mapper get-service $OBJECT) |
| 271 | INTERFACE=org.openbmc.control.Power |
| 272 | for property in pgood state pgood_timeout |
| 273 | do |
| 274 | # get_property can potentially return several |
| 275 | # different formats of values, so we do the parsing outside |
| 276 | # of get_property depending on the query. These queries |
| 277 | # return 'i VALUE' formatted strings. |
| 278 | STATE=$(get_property $SERVICE $OBJECT $INTERFACE $property \ |
| 279 | | sed 's/i[ ^I]*//') |
| 280 | printf "%s = %s\n" $property $STATE |
| 281 | done |
| 282 | ;; |
Anthony Wilson | 189cf24 | 2018-10-23 01:18:21 -0500 | [diff] [blame] | 283 | chassiskill) |
| 284 | /usr/libexec/chassiskill |
| 285 | ;; |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame^] | 286 | hostrebootoff) |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 287 | OBJECT=$CONTROL_OBJECT/host0/auto_reboot |
| 288 | SERVICE=$(mapper get-service $OBJECT) |
| 289 | INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy |
| 290 | PROPERTY=AutoReboot |
| 291 | VALUE=false |
| 292 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "b" $VALUE |
| 293 | ;; |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame^] | 294 | hostrebooton) |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 295 | OBJECT=$CONTROL_OBJECT/host0/auto_reboot |
| 296 | SERVICE=$(mapper get-service $OBJECT) |
| 297 | INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy |
| 298 | PROPERTY=AutoReboot |
| 299 | VALUE=true |
| 300 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "b" $VALUE |
| 301 | ;; |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame^] | 302 | bmcrebootoff) |
| 303 | disable_bmc_reboot |
| 304 | ;; |
| 305 | bmcrebooton) |
| 306 | enable_bmc_reboot |
| 307 | ;; |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 308 | recoveryoff) |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame^] | 309 | handle_cmd hostrebootoff |
| 310 | handle_cmd bmcrebootoff |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 311 | mask_systemd_target $HOST_TIMEOUT_TARGET |
Vishwanatha Subbanna | 84b3b29 | 2019-11-04 05:43:19 -0600 | [diff] [blame] | 312 | mask_systemd_target $HOST_CRASH_TARGET |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 313 | ;; |
| 314 | recoveryon) |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame^] | 315 | handle_cmd hostrebooton |
| 316 | handle_cmd bmcrebooton |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 317 | unmask_systemd_target $HOST_TIMEOUT_TARGET |
Vishwanatha Subbanna | 84b3b29 | 2019-11-04 05:43:19 -0600 | [diff] [blame] | 318 | unmask_systemd_target $HOST_CRASH_TARGET |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 319 | ;; |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 320 | *) |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 321 | print_usage_err "Invalid command '$1'" |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 322 | ;; |
| 323 | esac |
| 324 | } |
| 325 | |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 326 | for arg in "$@"; do |
| 327 | case $arg in |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 328 | -w|--wait) |
| 329 | G_WAIT=30 |
| 330 | continue |
| 331 | ;; |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 332 | -h|--help) |
| 333 | print_help |
| 334 | ;; |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 335 | -v|--verbose) |
| 336 | G_VERBOSE=y |
| 337 | ;; |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 338 | -*) |
| 339 | print_usage_err "Unknown option: $arg" |
| 340 | ;; |
| 341 | *) |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 342 | G_ORIG_CMD=$arg |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 343 | handle_cmd $arg |
| 344 | break |
| 345 | ;; |
| 346 | esac |
| 347 | done |