Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 1 | #!/bin/bash -e |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 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 | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 7 | bmcrebootoff, bmcrebooton, listbootblock listlogs showlog deletelogs, stopofftargets" |
Anthony Wilson | 0f35983 | 2018-09-13 14:28:07 -0500 | [diff] [blame] | 8 | |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 9 | USAGE="Usage: obmcutil [-h] [--wait] [--verbose] [--id=<INSTANCE_ID>] |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [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= |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 41 | # Instance id, default 0 |
| 42 | G_INSTANCE_ID="0" |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 43 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 44 | function print_help() |
Anthony Wilson | f3f16fa | 2018-09-13 14:10:52 -0500 | [diff] [blame] | 45 | { |
| 46 | echo "$USAGE" |
| 47 | echo "" |
| 48 | echo "positional arguments:" |
Anthony Wilson | 0f35983 | 2018-09-13 14:28:07 -0500 | [diff] [blame] | 49 | echo " {$OPTS}" |
Anthony Wilson | f3f16fa | 2018-09-13 14:10:52 -0500 | [diff] [blame] | 50 | echo "" |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 51 | echo "Examples:" |
| 52 | echo "" |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 53 | echo "obmcutil hostrebootoff Disable auto reboot of Host from Quiesce state" |
Andrew Geissler | 3191be8 | 2020-10-23 10:45:55 -0500 | [diff] [blame] | 54 | echo "obmcutil hostrebootoffonetime Disable auto reboot of Host from" |
| 55 | echo " Quiesce state for a single boot" |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 56 | echo "obmcutil hostrebooton Enable auto reboot of Host from Quiesce state" |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 57 | echo "" |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 58 | echo "obmcutil bmcrebootoff Disable reboot of BMC" |
| 59 | echo "obmcutil bmcrebooton Enable reboot of BMC" |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 60 | echo "" |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 61 | echo "obmcutil recoveryoff Disable handling boot watchdog timeout and host crash" |
| 62 | echo " Also, disable BMC and Host auto reboots" |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 63 | echo "" |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 64 | echo "obmcutil recoveryon Enable handling boot watchdog timeout and host crash" |
| 65 | echo " Also, enable BMC and Host auto reboots" |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 66 | echo "" |
Anusha Dathatri | 24b25a4 | 2024-05-31 05:57:45 -0500 | [diff] [blame] | 67 | echo "obmcutil recoverystatus Display the status of handling boot watchdog timeout and host crash" |
| 68 | echo " and also the status of BMC and Host auto reboots setting" |
| 69 | echo "" |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 70 | echo "obmcutil listbootblock Check for and list any errors blocking the boot" |
| 71 | echo " of the system" |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame] | 72 | echo "" |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 73 | echo "obmcutil listlogs List all phosphor-logging entries on the" |
| 74 | echo " system" |
Andrew Geissler | 295ee4f | 2020-05-14 14:14:05 -0500 | [diff] [blame] | 75 | echo "" |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 76 | echo "obmcutil showlog <log> Display details of input log. Format of <log>" |
| 77 | echo " should match listlogs output" |
Andrew Geissler | d8c6320 | 2020-05-14 15:06:31 -0500 | [diff] [blame] | 78 | echo "" |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 79 | echo "obmcutil deletelogs Delete all phosphor-logging entries from" |
| 80 | echo " system" |
| 81 | echo "obmcutil stopofftargets Manually stop all obmc targets in power off" |
| 82 | echo " path" |
Andrew Geissler | 42f2898 | 2020-05-14 15:12:42 -0500 | [diff] [blame] | 83 | echo "" |
Andrew Geissler | d8779cd | 2020-06-11 10:48:40 -0500 | [diff] [blame] | 84 | echo "optional arguments (must precede the positional options above):" |
Anthony Wilson | f3f16fa | 2018-09-13 14:10:52 -0500 | [diff] [blame] | 85 | echo " -h, --help show this help message and exit" |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 86 | echo " -w, --wait block until state transition succeeds or fails" |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 87 | echo " -v, --verbose print the journal to stdout if --wait is supplied" |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 88 | echo " -i, -id instance id, default 0" |
Anthony Wilson | f3f16fa | 2018-09-13 14:10:52 -0500 | [diff] [blame] | 89 | exit 0 |
| 90 | } |
| 91 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 92 | function run_timeout() |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 93 | { |
| 94 | local timeout="$1"; shift |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 95 | local cmd="$*" |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 96 | local verbose_child= |
| 97 | |
Andrew Jeffery | 2869a92 | 2019-10-18 14:42:34 +1030 | [diff] [blame] | 98 | if [ -n "$G_VERBOSE" ]; then |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 99 | journalctl -f & |
| 100 | verbose_child=$! |
| 101 | fi |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 102 | |
| 103 | $cmd |
| 104 | |
| 105 | # Run a background query for the transition to the expected state |
| 106 | # This will be killed if the transition doesn't succeed within |
| 107 | # a timeout period. |
| 108 | ( |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 109 | while ! grep -q "$G_REQUESTED_STATE" <<< "$(handle_cmd "$G_QUERY")" ; do |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 110 | sleep 1 |
| 111 | done |
| 112 | ) & |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 113 | wait_child=$! |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 114 | |
| 115 | # Could be bad if process is killed before 'timeout' occurs if |
| 116 | # transition doesn't succeed. |
| 117 | trap -- "" SIGTERM |
| 118 | |
| 119 | # Workaround for lack of 'timeout' command. |
| 120 | ( |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 121 | sleep "$timeout" |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 122 | kill $wait_child |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 123 | ) > /dev/null 2>&1 & |
| 124 | |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 125 | if ! wait $wait_child; then |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 126 | echo "Unable to confirm '$G_ORIG_CMD' success" \ |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 127 | "within timeout period (${timeout}s)" |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 128 | fi |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 129 | |
Andrew Jeffery | 8be7029 | 2019-11-01 08:56:49 +1030 | [diff] [blame] | 130 | if [ -n "$verbose_child" ]; then |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 131 | kill $verbose_child |
| 132 | fi |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 133 | } |
| 134 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 135 | function run_cmd() |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 136 | { |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 137 | local cmd="$*"; |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 138 | |
| 139 | if [ -n "$G_WAIT" ]; then |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 140 | run_timeout "$G_WAIT" "$cmd" |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 141 | else |
| 142 | $cmd |
| 143 | fi |
| 144 | } |
| 145 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 146 | function set_property() |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 147 | { |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 148 | run_cmd busctl set-property "$@" |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 149 | } |
| 150 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 151 | function get_property() |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 152 | { |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 153 | G_WAIT="" |
| 154 | run_cmd busctl get-property "$@" |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 155 | } |
| 156 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 157 | function state_query() |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 158 | { |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 159 | local state |
| 160 | state=$(get_property "$@" | cut -d '"' -f2) |
| 161 | printf "%-20s: %s\n" "$4" "$state" |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 162 | } |
| 163 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 164 | function print_usage_err() |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 165 | { |
| 166 | echo "ERROR: $1" >&2 |
| 167 | echo "$USAGE" |
| 168 | exit 1 |
| 169 | } |
| 170 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 171 | function mask_systemd_target() |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 172 | { |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 173 | target="$*" |
| 174 | systemctl mask "$target" |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 175 | } |
| 176 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 177 | function unmask_systemd_target() |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 178 | { |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 179 | target="$*" |
| 180 | systemctl unmask "$target" |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 181 | } |
| 182 | |
Anusha Dathatri | 24b25a4 | 2024-05-31 05:57:45 -0500 | [diff] [blame] | 183 | function get_systemd_target_state() |
| 184 | { |
| 185 | target="$*" |
| 186 | enabled_state=$(systemctl is-enabled "$target") |
| 187 | echo "$enabled_state" |
| 188 | } |
| 189 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 190 | function disable_bmc_reboot() |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 191 | { |
| 192 | dir="/run/systemd/system/" |
| 193 | file="reboot-guard.conf" |
| 194 | units=("reboot" "poweroff" "halt") |
| 195 | |
| 196 | for unit in "${units[@]}"; do |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 197 | mkdir -p "${dir}${unit}.target.d" |
| 198 | echo -e "[Unit]\nRefuseManualStart=yes" >> "${dir}${unit}.target.d/${file}" |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 199 | done |
| 200 | } |
| 201 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 202 | function enable_bmc_reboot() |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 203 | { |
| 204 | dir="/run/systemd/system/" |
| 205 | file="reboot-guard.conf" |
| 206 | units=("reboot" "poweroff" "halt") |
| 207 | |
| 208 | for unit in "${units[@]}"; do |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 209 | rm -rf "${dir}${unit}.target.d/${file}" |
| 210 | rm -rf "${dir}${unit}.target.d" |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 211 | done |
| 212 | } |
| 213 | |
Anusha Dathatri | 24b25a4 | 2024-05-31 05:57:45 -0500 | [diff] [blame] | 214 | function get_bmc_reboot_status() |
| 215 | { |
| 216 | dir="/run/systemd/system/" |
| 217 | file="reboot-guard.conf" |
| 218 | units=("reboot" "poweroff" "halt") |
| 219 | |
| 220 | # if file do |
| 221 | for unit in "${units[@]}"; do |
| 222 | if [ -e "${dir}${unit}.target.d/${file}" ]; then |
| 223 | echo "off" |
| 224 | return 0 |
| 225 | fi |
| 226 | done |
| 227 | echo "on" |
| 228 | return 0 |
| 229 | } |
| 230 | |
| 231 | function get_host_reboot_status() |
| 232 | { |
| 233 | OBJECT=$CONTROL_OBJECT/host$G_INSTANCE_ID/auto_reboot |
| 234 | SERVICE=$(mapper get-service "$OBJECT") |
| 235 | INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy |
| 236 | PROPERTY=AutoReboot |
| 237 | output="$(get_property "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY)" |
| 238 | echo "${output//b /}" |
| 239 | } |
| 240 | |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame] | 241 | # will write blocking errors to stdout |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 242 | function check_boot_block_errors() |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame] | 243 | { |
| 244 | # array of boot block objects |
| 245 | blockArray=() |
| 246 | |
| 247 | # Look for any objects under logging that implement the |
| 248 | # xyz.openbmc_project.Logging.ErrorBlocksTransition |
| 249 | subtree="$(busctl call xyz.openbmc_project.ObjectMapper \ |
| 250 | /xyz/openbmc_project/object_mapper \ |
| 251 | xyz.openbmc_project.ObjectMapper \ |
| 252 | GetSubTree sias "/xyz/openbmc_project/logging/" 0 1 \ |
| 253 | xyz.openbmc_project.Logging.ErrorBlocksTransition)" |
| 254 | |
| 255 | # remove quotation marks |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 256 | # shellcheck disable=SC2001 |
| 257 | subtree="$(echo "$subtree" | sed 's/\"//g')" |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame] | 258 | |
| 259 | for entry in $subtree; do |
| 260 | if [[ ${entry} =~ "xyz/openbmc_project/logging/block"* ]]; then |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 261 | blockArray+=( "$entry" ) |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame] | 262 | fi |
| 263 | done |
| 264 | |
| 265 | # now find associated error log for each boot block error |
| 266 | for berror in "${blockArray[@]}"; do |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 267 | assocs="$(busctl call xyz.openbmc_project.Logging "$berror" \ |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame] | 268 | org.freedesktop.DBus.Properties Get \ |
| 269 | ss xyz.openbmc_project.Association.Definitions Associations)" |
| 270 | |
| 271 | # remove quotation marks |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 272 | # shellcheck disable=SC2001 |
| 273 | assocs="$(echo "$assocs" | sed 's/\"//g')" |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame] | 274 | |
| 275 | for entry in $assocs; do |
| 276 | if [[ ${entry} =~ "xyz/openbmc_project/logging/entry"* ]]; then |
| 277 | echo "Blocking Error: $entry" |
| 278 | fi |
| 279 | done |
| 280 | done |
| 281 | } |
| 282 | |
Andrew Geissler | deb6bb4 | 2020-05-14 13:44:57 -0500 | [diff] [blame] | 283 | # helper function to check for boot block errors and notify user |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 284 | function check_and_warn_boot_block() |
Andrew Geissler | deb6bb4 | 2020-05-14 13:44:57 -0500 | [diff] [blame] | 285 | { |
| 286 | blockingErrors=$(check_boot_block_errors) |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 287 | if [ -n "$blockingErrors" ]; then |
Andrew Geissler | deb6bb4 | 2020-05-14 13:44:57 -0500 | [diff] [blame] | 288 | echo !!!!!!!!!! |
| 289 | echo "WARNING! System has blocking errors that will prevent boot" |
| 290 | echo "$blockingErrors" |
| 291 | echo !!!!!!!!!! |
| 292 | fi |
| 293 | } |
| 294 | |
Andrew Geissler | 295ee4f | 2020-05-14 14:14:05 -0500 | [diff] [blame] | 295 | # list all phosphor-logging entries |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 296 | function list_logs() |
Andrew Geissler | 295ee4f | 2020-05-14 14:14:05 -0500 | [diff] [blame] | 297 | { |
| 298 | # Look for any objects under logging that implement the |
| 299 | # xyz.openbmc_project.Logging.Entry |
| 300 | busctl -j call xyz.openbmc_project.ObjectMapper \ |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 301 | /xyz/openbmc_project/object_mapper \ |
| 302 | xyz.openbmc_project.ObjectMapper \ |
| 303 | GetSubTreePaths sias "/xyz/openbmc_project/logging/" 0 1 \ |
| 304 | xyz.openbmc_project.Logging.Entry |
Andrew Geissler | 295ee4f | 2020-05-14 14:14:05 -0500 | [diff] [blame] | 305 | } |
| 306 | |
Andrew Geissler | d8c6320 | 2020-05-14 15:06:31 -0500 | [diff] [blame] | 307 | # display input log details |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 308 | function show_log() |
Andrew Geissler | d8c6320 | 2020-05-14 15:06:31 -0500 | [diff] [blame] | 309 | { |
| 310 | busctl -j call xyz.openbmc_project.Logging \ |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 311 | "$1" \ |
| 312 | org.freedesktop.DBus.Properties \ |
| 313 | GetAll s xyz.openbmc_project.Logging.Entry |
Andrew Geissler | d8c6320 | 2020-05-14 15:06:31 -0500 | [diff] [blame] | 314 | } |
| 315 | |
Andrew Geissler | 42f2898 | 2020-05-14 15:12:42 -0500 | [diff] [blame] | 316 | # delete all phosphor-logging entries |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 317 | function delete_logs() |
Andrew Geissler | 42f2898 | 2020-05-14 15:12:42 -0500 | [diff] [blame] | 318 | { |
| 319 | busctl call xyz.openbmc_project.Logging \ |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 320 | /xyz/openbmc_project/logging \ |
| 321 | xyz.openbmc_project.Collection.DeleteAll DeleteAll |
Andrew Geissler | 42f2898 | 2020-05-14 15:12:42 -0500 | [diff] [blame] | 322 | } |
| 323 | |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 324 | # stop all targets associated with powering off a system |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 325 | function stop_off_targets() |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 326 | { |
| 327 | systemctl stop \ |
| 328 | obmc-chassis-powered-off@0.target \ |
| 329 | obmc-host-stop-pre@0.target \ |
| 330 | obmc-host-stopped@0.target \ |
| 331 | obmc-host-stopping@0.target \ |
| 332 | obmc-power-off@0.target \ |
| 333 | obmc-power-stop-pre@0.target \ |
| 334 | obmc-power-stop@0.target |
| 335 | } |
| 336 | |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 337 | function handle_cmd() |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 338 | { |
| 339 | case "$1" in |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 340 | chassisoff) |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 341 | OBJECT=$STATE_OBJECT/chassis$G_INSTANCE_ID |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 342 | SERVICE=$(mapper get-service "$OBJECT") |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 343 | INTERFACE=$STATE_INTERFACE.Chassis |
| 344 | PROPERTY=RequestedPowerTransition |
| 345 | VALUE=$INTERFACE.Transition.Off |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 346 | G_REQUESTED_STATE=$INTERFACE.PowerState.Off |
| 347 | G_QUERY="chassisstate" |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 348 | set_property "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY "s" $VALUE |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 349 | ;; |
| 350 | chassison) |
Andrew Geissler | deb6bb4 | 2020-05-14 13:44:57 -0500 | [diff] [blame] | 351 | check_and_warn_boot_block |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 352 | OBJECT=$STATE_OBJECT/chassis$G_INSTANCE_ID |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 353 | SERVICE=$(mapper get-service "$OBJECT") |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 354 | INTERFACE=$STATE_INTERFACE.Chassis |
| 355 | PROPERTY=RequestedPowerTransition |
| 356 | VALUE=$INTERFACE.Transition.On |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 357 | G_REQUESTED_STATE=$INTERFACE.PowerState.On |
| 358 | G_QUERY="chassisstate" |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 359 | set_property "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY "s" $VALUE |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 360 | ;; |
| 361 | poweroff) |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 362 | OBJECT=$STATE_OBJECT/host$G_INSTANCE_ID |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 363 | SERVICE=$(mapper get-service "$OBJECT") |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 364 | INTERFACE=$STATE_INTERFACE.Host |
| 365 | PROPERTY=RequestedHostTransition |
| 366 | VALUE=$INTERFACE.Transition.Off |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 367 | G_REQUESTED_STATE=$INTERFACE.HostState.Off |
| 368 | G_QUERY="hoststate" |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 369 | set_property "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY "s" $VALUE |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 370 | ;; |
| 371 | poweron) |
Andrew Geissler | deb6bb4 | 2020-05-14 13:44:57 -0500 | [diff] [blame] | 372 | check_and_warn_boot_block |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 373 | OBJECT=$STATE_OBJECT/host$G_INSTANCE_ID |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 374 | SERVICE=$(mapper get-service "$OBJECT") |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 375 | INTERFACE=$STATE_INTERFACE.Host |
| 376 | PROPERTY=RequestedHostTransition |
| 377 | VALUE=$INTERFACE.Transition.On |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 378 | G_REQUESTED_STATE=$INTERFACE.HostState.Running |
| 379 | G_QUERY="hoststate" |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 380 | set_property "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY "s" $VALUE |
Anthony Wilson | 3ae0a35 | 2018-09-13 14:47:56 -0500 | [diff] [blame] | 381 | ;; |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 382 | bmcstate) |
| 383 | OBJECT=$STATE_OBJECT/bmc0 |
| 384 | SERVICE=$(mapper get-service $OBJECT) |
| 385 | INTERFACE=$STATE_INTERFACE.BMC |
| 386 | PROPERTY=CurrentBMCState |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 387 | state_query "$SERVICE" $OBJECT $INTERFACE $PROPERTY |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 388 | ;; |
| 389 | chassisstate) |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 390 | OBJECT=$STATE_OBJECT/chassis$G_INSTANCE_ID |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 391 | SERVICE=$(mapper get-service "$OBJECT") |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 392 | INTERFACE=$STATE_INTERFACE.Chassis |
| 393 | PROPERTY=CurrentPowerState |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 394 | state_query "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 395 | ;; |
| 396 | hoststate) |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 397 | OBJECT=$STATE_OBJECT/host$G_INSTANCE_ID |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 398 | SERVICE=$(mapper get-service "$OBJECT") |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 399 | INTERFACE=$STATE_INTERFACE.Host |
| 400 | PROPERTY=CurrentHostState |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 401 | state_query "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 402 | ;; |
Alexander Filippov | 86cffd9 | 2019-04-03 16:29:57 +0300 | [diff] [blame] | 403 | osstate) |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 404 | OBJECT=$STATE_OBJECT/host$G_INSTANCE_ID |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 405 | SERVICE=$(mapper get-service "$OBJECT") |
Alexander Filippov | 86cffd9 | 2019-04-03 16:29:57 +0300 | [diff] [blame] | 406 | INTERFACE=$STATE_INTERFACE.OperatingSystem.Status |
| 407 | PROPERTY=OperatingSystemState |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 408 | state_query "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY |
Alexander Filippov | 86cffd9 | 2019-04-03 16:29:57 +0300 | [diff] [blame] | 409 | ;; |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 410 | state|status) |
Alexander Filippov | 86cffd9 | 2019-04-03 16:29:57 +0300 | [diff] [blame] | 411 | for query in bmcstate chassisstate hoststate bootprogress osstate |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 412 | do |
| 413 | handle_cmd $query |
| 414 | done |
Andrew Geissler | deb6bb4 | 2020-05-14 13:44:57 -0500 | [diff] [blame] | 415 | check_and_warn_boot_block |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 416 | ;; |
Anthony Wilson | 50c5f88 | 2018-09-13 14:19:37 -0500 | [diff] [blame] | 417 | bootprogress) |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 418 | OBJECT=$STATE_OBJECT/host$G_INSTANCE_ID |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 419 | SERVICE=$(mapper get-service "$OBJECT") |
Anthony Wilson | 50c5f88 | 2018-09-13 14:19:37 -0500 | [diff] [blame] | 420 | INTERFACE=$STATE_INTERFACE.Boot.Progress |
| 421 | PROPERTY=BootProgress |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 422 | state_query "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY |
Anthony Wilson | 50c5f88 | 2018-09-13 14:19:37 -0500 | [diff] [blame] | 423 | ;; |
Anthony Wilson | 0f35983 | 2018-09-13 14:28:07 -0500 | [diff] [blame] | 424 | power) |
| 425 | OBJECT=/org/openbmc/control/power0 |
| 426 | SERVICE=$(mapper get-service $OBJECT) |
| 427 | INTERFACE=org.openbmc.control.Power |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 428 | for property in pgood state pgood_timeout; do |
Anthony Wilson | 0f35983 | 2018-09-13 14:28:07 -0500 | [diff] [blame] | 429 | # get_property can potentially return several |
| 430 | # different formats of values, so we do the parsing outside |
| 431 | # of get_property depending on the query. These queries |
| 432 | # return 'i VALUE' formatted strings. |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 433 | STATE=$(get_property "$SERVICE" "$OBJECT" "$INTERFACE" "$property" | sed 's/i[ ^I]*//') |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 434 | printf "%s = %s\n" $property "$STATE" |
Anthony Wilson | 0f35983 | 2018-09-13 14:28:07 -0500 | [diff] [blame] | 435 | done |
| 436 | ;; |
Anthony Wilson | 189cf24 | 2018-10-23 01:18:21 -0500 | [diff] [blame] | 437 | chassiskill) |
| 438 | /usr/libexec/chassiskill |
| 439 | ;; |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 440 | hostrebootoff) |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 441 | OBJECT=$CONTROL_OBJECT/host$G_INSTANCE_ID/auto_reboot |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 442 | SERVICE=$(mapper get-service "$OBJECT") |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 443 | INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy |
| 444 | PROPERTY=AutoReboot |
| 445 | VALUE=false |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 446 | set_property "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY "b" $VALUE |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 447 | ;; |
Andrew Geissler | 3191be8 | 2020-10-23 10:45:55 -0500 | [diff] [blame] | 448 | hostrebootoffonetime) |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 449 | OBJECT=$CONTROL_OBJECT/host$G_INSTANCE_ID/auto_reboot/one_time |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 450 | SERVICE=$(mapper get-service "$OBJECT") |
Andrew Geissler | 3191be8 | 2020-10-23 10:45:55 -0500 | [diff] [blame] | 451 | INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy |
| 452 | PROPERTY=AutoReboot |
| 453 | VALUE=false |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 454 | set_property "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY "b" $VALUE |
Patrick Williams | d182bff | 2022-12-08 06:39:12 -0600 | [diff] [blame] | 455 | ;; |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 456 | hostrebooton) |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 457 | OBJECT=$CONTROL_OBJECT/host$G_INSTANCE_ID/auto_reboot |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 458 | SERVICE=$(mapper get-service "$OBJECT") |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 459 | INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy |
| 460 | PROPERTY=AutoReboot |
| 461 | VALUE=true |
Andrew Geissler | 8aca050 | 2023-05-01 15:51:39 -0600 | [diff] [blame] | 462 | set_property "$SERVICE" "$OBJECT" $INTERFACE $PROPERTY "b" $VALUE |
Vishwanatha Subbanna | 6d3a2c5 | 2019-10-24 07:21:30 -0500 | [diff] [blame] | 463 | ;; |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 464 | bmcrebootoff) |
| 465 | disable_bmc_reboot |
| 466 | ;; |
| 467 | bmcrebooton) |
| 468 | enable_bmc_reboot |
| 469 | ;; |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 470 | recoveryoff) |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 471 | handle_cmd hostrebootoff |
| 472 | handle_cmd bmcrebootoff |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 473 | mask_systemd_target $HOST_TIMEOUT_TARGET |
Vishwanatha Subbanna | 84b3b29 | 2019-11-04 05:43:19 -0600 | [diff] [blame] | 474 | mask_systemd_target $HOST_CRASH_TARGET |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 475 | ;; |
| 476 | recoveryon) |
Vishwanatha Subbanna | a65d30d | 2019-11-13 01:26:12 -0600 | [diff] [blame] | 477 | handle_cmd hostrebooton |
| 478 | handle_cmd bmcrebooton |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 479 | unmask_systemd_target $HOST_TIMEOUT_TARGET |
Vishwanatha Subbanna | 84b3b29 | 2019-11-04 05:43:19 -0600 | [diff] [blame] | 480 | unmask_systemd_target $HOST_CRASH_TARGET |
Vishwanatha Subbanna | 7a787dd | 2019-10-31 06:02:31 -0500 | [diff] [blame] | 481 | ;; |
Anusha Dathatri | 24b25a4 | 2024-05-31 05:57:45 -0500 | [diff] [blame] | 482 | recoverystatus) |
| 483 | host_reboot_state=$(get_host_reboot_status) |
| 484 | if [[ $host_reboot_state == "true" ]]; then |
| 485 | host_reboot_status=1 |
| 486 | else |
| 487 | host_reboot_status=0 |
| 488 | fi |
| 489 | |
| 490 | bmc_reboot_state=$(get_bmc_reboot_status) |
| 491 | if [[ $bmc_reboot_state == "on" ]]; then |
| 492 | bmc_reboot_status=1 |
| 493 | else |
| 494 | bmc_reboot_status=0 |
| 495 | fi |
| 496 | |
| 497 | host_timeout_target_state=$(get_systemd_target_state $HOST_TIMEOUT_TARGET) |
| 498 | if [[ $host_timeout_target_state == "masked" ]]; then |
| 499 | host_timeout_status=0 |
| 500 | else |
| 501 | host_timeout_status=1 |
| 502 | fi |
| 503 | |
| 504 | host_crash_target_state=$(get_systemd_target_state $HOST_CRASH_TARGET) |
| 505 | if [[ $host_crash_target_state == "masked" ]]; then |
| 506 | host_crash_status=0 |
| 507 | else |
| 508 | host_crash_status=1 |
| 509 | fi |
| 510 | |
| 511 | if (( host_reboot_status && bmc_reboot_status && host_timeout_status && host_crash_status )); then |
| 512 | echo "recovery: On" |
| 513 | elif (( !host_reboot_status && !bmc_reboot_status && !host_timeout_status && !host_crash_status )); then |
| 514 | echo "recovery: Off" |
| 515 | else |
| 516 | echo "recovery: Undefined" |
| 517 | fi |
| 518 | |
| 519 | declare -A status |
| 520 | status[0]="Off" |
| 521 | status[1]="On" |
| 522 | |
| 523 | printf " %-11s: %s\n" "hostReboot" "${status[$host_reboot_status]}" |
| 524 | printf " %-11s: %s\n" "bmcReboot" "${status[$bmc_reboot_status]}" |
| 525 | printf " %-11s: %s\n" "hostTimeout" "${status[$host_timeout_status]}" |
| 526 | printf " %-11s: %s\n" "hostCrash" "${status[$host_crash_status]}" |
| 527 | ;; |
Andrew Geissler | 3b7b561 | 2020-05-14 10:45:29 -0500 | [diff] [blame] | 528 | listbootblock) |
| 529 | blockingErrors=$(check_boot_block_errors) |
| 530 | if [ -z "$blockingErrors" ]; then |
| 531 | echo "No blocking errors present" |
| 532 | else |
| 533 | echo "$blockingErrors" |
| 534 | fi |
| 535 | ;; |
Andrew Geissler | 295ee4f | 2020-05-14 14:14:05 -0500 | [diff] [blame] | 536 | listlogs) |
| 537 | list_logs |
| 538 | ;; |
Andrew Geissler | d8c6320 | 2020-05-14 15:06:31 -0500 | [diff] [blame] | 539 | showlog) |
Patrick Williams | b239820 | 2021-04-13 20:53:26 -0500 | [diff] [blame] | 540 | show_log "$2" |
Andrew Geissler | d8c6320 | 2020-05-14 15:06:31 -0500 | [diff] [blame] | 541 | ;; |
Andrew Geissler | 42f2898 | 2020-05-14 15:12:42 -0500 | [diff] [blame] | 542 | deletelogs) |
| 543 | delete_logs |
| 544 | ;; |
Andrew Geissler | ad1afe5 | 2022-02-23 16:07:06 -0600 | [diff] [blame] | 545 | stopofftargets) |
| 546 | stop_off_targets |
| 547 | ;; |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 548 | *) |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 549 | print_usage_err "Invalid command '$1'" |
Anthony Wilson | 79f697e | 2018-09-13 13:48:52 -0500 | [diff] [blame] | 550 | ;; |
| 551 | esac |
| 552 | } |
| 553 | |
Andrew Geissler | d8779cd | 2020-06-11 10:48:40 -0500 | [diff] [blame] | 554 | shiftcnt=0 |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 555 | for arg in "$@"; do |
| 556 | case $arg in |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 557 | -w|--wait) |
| 558 | G_WAIT=30 |
Andrew Geissler | d8779cd | 2020-06-11 10:48:40 -0500 | [diff] [blame] | 559 | shiftcnt=$((shiftcnt+1)) |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 560 | continue |
| 561 | ;; |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 562 | -h|--help) |
| 563 | print_help |
| 564 | ;; |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 565 | -v|--verbose) |
| 566 | G_VERBOSE=y |
Andrew Geissler | d8779cd | 2020-06-11 10:48:40 -0500 | [diff] [blame] | 567 | shiftcnt=$((shiftcnt+1)) |
Andrew Jeffery | 60c3ac8 | 2019-10-02 09:29:29 +0930 | [diff] [blame] | 568 | ;; |
Potin Lai | 0e044c4 | 2022-05-13 23:42:31 +0800 | [diff] [blame] | 569 | -i=*|--id=*) |
| 570 | G_INSTANCE_ID="${arg#*=}" |
| 571 | shiftcnt=$((shiftcnt+1)) |
| 572 | ;; |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 573 | -*) |
| 574 | print_usage_err "Unknown option: $arg" |
| 575 | ;; |
| 576 | *) |
Anthony Wilson | acf54d0 | 2018-09-20 15:19:28 -0500 | [diff] [blame] | 577 | G_ORIG_CMD=$arg |
Andrew Geissler | d8779cd | 2020-06-11 10:48:40 -0500 | [diff] [blame] | 578 | # shift out the optional parameters |
| 579 | shift $shiftcnt |
Andrew Geissler | d8c6320 | 2020-05-14 15:06:31 -0500 | [diff] [blame] | 580 | # pass all arguments to handle_cmd in case command takes additional |
| 581 | # parameters |
| 582 | handle_cmd "$@" |
Anthony Wilson | ea87db4 | 2018-09-26 16:06:38 -0500 | [diff] [blame] | 583 | break |
| 584 | ;; |
| 585 | esac |
| 586 | done |