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,\ |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame^] | 7 | bmcrebootoff, bmcrebooton, listbootblock" |
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 "" |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame^] | 63 | echo "obmcutil listbootblock Check for and list any errors blocking the boot" |
| 64 | echo " of the system" |
| 65 | echo "" |
Anthony Wilson | f3f16fa | 2018-09-13 14:10:52 -0500 | [diff] [blame] | 66 | echo "optional arguments:" |
| 67 | echo " -h, --help show this help message and exit" |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 68 | echo " -w, --wait block until state transition succeeds or fails" |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 69 | echo " -v, --verbose print the journal to stdout if --wait is supplied" |
Anthony Wilson | f3f16fa | 2018-09-13 14:10:52 -0500 | [diff] [blame] | 70 | exit 0 |
| 71 | } |
| 72 | |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 73 | run_timeout () |
| 74 | { |
| 75 | local timeout="$1"; shift |
| 76 | local cmd="$@" |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 77 | local verbose_child= |
| 78 | |
Andrew Jeffery | 2869a92 | 2019-10-18 14:42:34 +1030 | [diff] [blame] | 79 | if [ -n "$G_VERBOSE" ]; then |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 80 | journalctl -f & |
| 81 | verbose_child=$! |
| 82 | fi |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 83 | |
| 84 | $cmd |
| 85 | |
| 86 | # Run a background query for the transition to the expected state |
| 87 | # This will be killed if the transition doesn't succeed within |
| 88 | # a timeout period. |
| 89 | ( |
| 90 | while ! grep -q $G_REQUESTED_STATE <<< $(handle_cmd $G_QUERY) ; do |
| 91 | sleep 1 |
| 92 | done |
| 93 | ) & |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 94 | wait_child=$! |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 95 | |
| 96 | # Could be bad if process is killed before 'timeout' occurs if |
| 97 | # transition doesn't succeed. |
| 98 | trap -- "" SIGTERM |
| 99 | |
| 100 | # Workaround for lack of 'timeout' command. |
| 101 | ( |
| 102 | sleep $timeout |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 103 | kill $wait_child |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 104 | ) > /dev/null 2>&1 & |
| 105 | |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 106 | if ! wait $wait_child; then |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 107 | echo "Unable to confirm '$G_ORIG_CMD' success" \ |
| 108 | "within timeout period (${timeout}s)" |
| 109 | fi |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 110 | |
Andrew Jeffery | 8be7029 | 2019-11-01 08:56:49 +1030 | [diff] [blame] | 111 | if [ -n "$verbose_child" ]; then |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 112 | kill $verbose_child |
| 113 | fi |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | run_cmd () |
| 117 | { |
| 118 | local cmd="$@"; |
| 119 | |
| 120 | if [ -n "$G_WAIT" ]; then |
| 121 | run_timeout $G_WAIT "$cmd" |
| 122 | else |
| 123 | $cmd |
| 124 | fi |
| 125 | } |
| 126 | |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 127 | set_property () |
| 128 | { |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 129 | run_cmd busctl set-property "$@" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 130 | } |
| 131 | |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 132 | get_property () |
| 133 | { |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 134 | G_WAIT="" |
| 135 | run_cmd busctl get-property "$@" |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | state_query () |
| 139 | { |
| 140 | local state=$(get_property "$@" | cut -d '"' -f2) |
| 141 | printf "%-20s: %s\n" $4 $state |
| 142 | } |
| 143 | |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 144 | print_usage_err () |
| 145 | { |
| 146 | echo "ERROR: $1" >&2 |
| 147 | echo "$USAGE" |
| 148 | exit 1 |
| 149 | } |
| 150 | |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 151 | mask_systemd_target () |
| 152 | { |
| 153 | target="$@" |
| 154 | systemctl mask $target |
| 155 | } |
| 156 | |
| 157 | unmask_systemd_target () |
| 158 | { |
| 159 | target="$@" |
| 160 | systemctl unmask $target |
| 161 | } |
| 162 | |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 163 | disable_bmc_reboot () |
| 164 | { |
| 165 | dir="/run/systemd/system/" |
| 166 | file="reboot-guard.conf" |
| 167 | units=("reboot" "poweroff" "halt") |
| 168 | |
| 169 | for unit in "${units[@]}"; do |
| 170 | mkdir -p ${dir}${unit}.target.d |
| 171 | echo -e "[Unit]\nRefuseManualStart=yes" >> ${dir}${unit}.target.d/${file} |
| 172 | done |
| 173 | } |
| 174 | |
| 175 | enable_bmc_reboot () |
| 176 | { |
| 177 | dir="/run/systemd/system/" |
| 178 | file="reboot-guard.conf" |
| 179 | units=("reboot" "poweroff" "halt") |
| 180 | |
| 181 | for unit in "${units[@]}"; do |
| 182 | rm -rf ${dir}${unit}.target.d/${file} |
| 183 | rm -rf ${dir}${unit}.target.d |
| 184 | done |
| 185 | } |
| 186 | |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame^] | 187 | # will write blocking errors to stdout |
| 188 | check_boot_block_errors () |
| 189 | { |
| 190 | # array of boot block objects |
| 191 | blockArray=() |
| 192 | |
| 193 | # Look for any objects under logging that implement the |
| 194 | # xyz.openbmc_project.Logging.ErrorBlocksTransition |
| 195 | subtree="$(busctl call xyz.openbmc_project.ObjectMapper \ |
| 196 | /xyz/openbmc_project/object_mapper \ |
| 197 | xyz.openbmc_project.ObjectMapper \ |
| 198 | GetSubTree sias "/xyz/openbmc_project/logging/" 0 1 \ |
| 199 | xyz.openbmc_project.Logging.ErrorBlocksTransition)" |
| 200 | |
| 201 | # remove quotation marks |
| 202 | subtree="$(echo $subtree | sed 's/\"//g')" |
| 203 | |
| 204 | for entry in $subtree; do |
| 205 | if [[ ${entry} =~ "xyz/openbmc_project/logging/block"* ]]; then |
| 206 | blockArray+=( $entry ) |
| 207 | fi |
| 208 | done |
| 209 | |
| 210 | # now find associated error log for each boot block error |
| 211 | for berror in "${blockArray[@]}"; do |
| 212 | assocs="$(busctl call xyz.openbmc_project.Logging $berror \ |
| 213 | org.freedesktop.DBus.Properties Get \ |
| 214 | ss xyz.openbmc_project.Association.Definitions Associations)" |
| 215 | |
| 216 | # remove quotation marks |
| 217 | assocs="$(echo $assocs | sed 's/\"//g')" |
| 218 | |
| 219 | for entry in $assocs; do |
| 220 | if [[ ${entry} =~ "xyz/openbmc_project/logging/entry"* ]]; then |
| 221 | echo "Blocking Error: $entry" |
| 222 | fi |
| 223 | done |
| 224 | done |
| 225 | } |
| 226 | |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 227 | handle_cmd () |
| 228 | { |
| 229 | case "$1" in |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 230 | chassisoff) |
| 231 | OBJECT=$STATE_OBJECT/chassis0 |
| 232 | SERVICE=$(mapper get-service $OBJECT) |
| 233 | INTERFACE=$STATE_INTERFACE.Chassis |
| 234 | PROPERTY=RequestedPowerTransition |
| 235 | VALUE=$INTERFACE.Transition.Off |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 236 | G_REQUESTED_STATE=$INTERFACE.PowerState.Off |
| 237 | G_QUERY="chassisstate" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 238 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE |
| 239 | ;; |
| 240 | chassison) |
| 241 | OBJECT=$STATE_OBJECT/chassis0 |
| 242 | SERVICE=$(mapper get-service $OBJECT) |
| 243 | INTERFACE=$STATE_INTERFACE.Chassis |
| 244 | PROPERTY=RequestedPowerTransition |
| 245 | VALUE=$INTERFACE.Transition.On |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 246 | G_REQUESTED_STATE=$INTERFACE.PowerState.On |
| 247 | G_QUERY="chassisstate" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 248 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE |
| 249 | ;; |
| 250 | poweroff) |
| 251 | OBJECT=$STATE_OBJECT/host0 |
| 252 | SERVICE=$(mapper get-service $OBJECT) |
| 253 | INTERFACE=$STATE_INTERFACE.Host |
| 254 | PROPERTY=RequestedHostTransition |
| 255 | VALUE=$INTERFACE.Transition.Off |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 256 | G_REQUESTED_STATE=$INTERFACE.HostState.Off |
| 257 | G_QUERY="hoststate" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 258 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE |
| 259 | ;; |
| 260 | poweron) |
| 261 | OBJECT=$STATE_OBJECT/host0 |
| 262 | SERVICE=$(mapper get-service $OBJECT) |
| 263 | INTERFACE=$STATE_INTERFACE.Host |
| 264 | PROPERTY=RequestedHostTransition |
| 265 | VALUE=$INTERFACE.Transition.On |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 266 | G_REQUESTED_STATE=$INTERFACE.HostState.Running |
| 267 | G_QUERY="hoststate" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 268 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE |
| 269 | ;; |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 270 | bmcstate) |
| 271 | OBJECT=$STATE_OBJECT/bmc0 |
| 272 | SERVICE=$(mapper get-service $OBJECT) |
| 273 | INTERFACE=$STATE_INTERFACE.BMC |
| 274 | PROPERTY=CurrentBMCState |
| 275 | state_query $SERVICE $OBJECT $INTERFACE $PROPERTY |
| 276 | ;; |
| 277 | chassisstate) |
| 278 | OBJECT=$STATE_OBJECT/chassis0 |
| 279 | SERVICE=$(mapper get-service $OBJECT) |
| 280 | INTERFACE=$STATE_INTERFACE.Chassis |
| 281 | PROPERTY=CurrentPowerState |
| 282 | state_query $SERVICE $OBJECT $INTERFACE $PROPERTY |
| 283 | ;; |
| 284 | hoststate) |
| 285 | OBJECT=$STATE_OBJECT/host0 |
| 286 | SERVICE=$(mapper get-service $OBJECT) |
| 287 | INTERFACE=$STATE_INTERFACE.Host |
| 288 | PROPERTY=CurrentHostState |
| 289 | state_query $SERVICE $OBJECT $INTERFACE $PROPERTY |
| 290 | ;; |
Alexander Filippov | 86cffd9 | 2019-04-03 16:29:57 +0300 | [diff] [blame] | 291 | osstate) |
| 292 | OBJECT=$STATE_OBJECT/host0 |
| 293 | SERVICE=$(mapper get-service $OBJECT) |
| 294 | INTERFACE=$STATE_INTERFACE.OperatingSystem.Status |
| 295 | PROPERTY=OperatingSystemState |
| 296 | state_query $SERVICE $OBJECT $INTERFACE $PROPERTY |
| 297 | ;; |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 298 | state|status) |
Alexander Filippov | 86cffd9 | 2019-04-03 16:29:57 +0300 | [diff] [blame] | 299 | for query in bmcstate chassisstate hoststate bootprogress osstate |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 300 | do |
| 301 | handle_cmd $query |
| 302 | done |
| 303 | ;; |
Anthony Wilson | 50c5f88 | 2018-09-13 14:19:37 -0500 | [diff] [blame] | 304 | bootprogress) |
| 305 | OBJECT=$STATE_OBJECT/host0 |
| 306 | SERVICE=$(mapper get-service $OBJECT) |
| 307 | INTERFACE=$STATE_INTERFACE.Boot.Progress |
| 308 | PROPERTY=BootProgress |
| 309 | state_query $SERVICE $OBJECT $INTERFACE $PROPERTY |
| 310 | ;; |
Anthony Wilson | 0f35983 | 2018-09-13 14:28:07 -0500 | [diff] [blame] | 311 | power) |
| 312 | OBJECT=/org/openbmc/control/power0 |
| 313 | SERVICE=$(mapper get-service $OBJECT) |
| 314 | INTERFACE=org.openbmc.control.Power |
| 315 | for property in pgood state pgood_timeout |
| 316 | do |
| 317 | # get_property can potentially return several |
| 318 | # different formats of values, so we do the parsing outside |
| 319 | # of get_property depending on the query. These queries |
| 320 | # return 'i VALUE' formatted strings. |
| 321 | STATE=$(get_property $SERVICE $OBJECT $INTERFACE $property \ |
| 322 | | sed 's/i[ ^I]*//') |
| 323 | printf "%s = %s\n" $property $STATE |
| 324 | done |
| 325 | ;; |
Anthony Wilson | 189cf24 | 2018-10-23 01:18:21 -0500 | [diff] [blame] | 326 | chassiskill) |
| 327 | /usr/libexec/chassiskill |
| 328 | ;; |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 329 | hostrebootoff) |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 330 | OBJECT=$CONTROL_OBJECT/host0/auto_reboot |
| 331 | SERVICE=$(mapper get-service $OBJECT) |
| 332 | INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy |
| 333 | PROPERTY=AutoReboot |
| 334 | VALUE=false |
| 335 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "b" $VALUE |
| 336 | ;; |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 337 | hostrebooton) |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 338 | OBJECT=$CONTROL_OBJECT/host0/auto_reboot |
| 339 | SERVICE=$(mapper get-service $OBJECT) |
| 340 | INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy |
| 341 | PROPERTY=AutoReboot |
| 342 | VALUE=true |
| 343 | set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "b" $VALUE |
| 344 | ;; |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 345 | bmcrebootoff) |
| 346 | disable_bmc_reboot |
| 347 | ;; |
| 348 | bmcrebooton) |
| 349 | enable_bmc_reboot |
| 350 | ;; |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 351 | recoveryoff) |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 352 | handle_cmd hostrebootoff |
| 353 | handle_cmd bmcrebootoff |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 354 | mask_systemd_target $HOST_TIMEOUT_TARGET |
Vishwanatha Subbanna | 84b3b29 | 2019-11-04 05:43:19 -0600 | [diff] [blame] | 355 | mask_systemd_target $HOST_CRASH_TARGET |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 356 | ;; |
| 357 | recoveryon) |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 358 | handle_cmd hostrebooton |
| 359 | handle_cmd bmcrebooton |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 360 | unmask_systemd_target $HOST_TIMEOUT_TARGET |
Vishwanatha Subbanna | 84b3b29 | 2019-11-04 05:43:19 -0600 | [diff] [blame] | 361 | unmask_systemd_target $HOST_CRASH_TARGET |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 362 | ;; |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame^] | 363 | listbootblock) |
| 364 | blockingErrors=$(check_boot_block_errors) |
| 365 | if [ -z "$blockingErrors" ]; then |
| 366 | echo "No blocking errors present" |
| 367 | else |
| 368 | echo "$blockingErrors" |
| 369 | fi |
| 370 | ;; |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 371 | *) |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 372 | print_usage_err "Invalid command '$1'" |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 373 | ;; |
| 374 | esac |
| 375 | } |
| 376 | |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 377 | for arg in "$@"; do |
| 378 | case $arg in |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 379 | -w|--wait) |
| 380 | G_WAIT=30 |
| 381 | continue |
| 382 | ;; |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 383 | -h|--help) |
| 384 | print_help |
| 385 | ;; |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 386 | -v|--verbose) |
| 387 | G_VERBOSE=y |
| 388 | ;; |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 389 | -*) |
| 390 | print_usage_err "Unknown option: $arg" |
| 391 | ;; |
| 392 | *) |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 393 | G_ORIG_CMD=$arg |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 394 | handle_cmd $arg |
| 395 | break |
| 396 | ;; |
| 397 | esac |
| 398 | done |