blob: d15b8323d35a29124a0525e846e01b444a2b8fa6 [file] [log] [blame]
Patrick Williamsb2398202021-04-13 20:53:26 -05001#!/bin/bash -e
Anthony Wilson79f697e2018-09-13 13:48:52 -05002
3set -euo pipefail
4
Anthony Wilson189cf242018-10-23 01:18:21 -05005OPTS="bmcstate,bootprogress,chassiskill,chassisoff,chassison,chassisstate,hoststate,\
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -06006osstate,power,poweroff,poweron,state,status,hostrebootoff,hostrebooton,recoveryoff,recoveryon,\
Andrew Geisslerad1afe52022-02-23 16:07:06 -06007bmcrebootoff, bmcrebooton, listbootblock listlogs showlog deletelogs, stopofftargets"
Anthony Wilson0f359832018-09-13 14:28:07 -05008
Andrew Jeffery60c3ac82019-10-02 09:29:29 +09309USAGE="Usage: obmcutil [-h] [--wait] [--verbose]
Anthony Wilson0f359832018-09-13 14:28:07 -050010 {$OPTS}"
Anthony Wilson79f697e2018-09-13 13:48:52 -050011
12INTERFACE_ROOT=xyz.openbmc_project
13STATE_INTERFACE=$INTERFACE_ROOT.State
Vishwanatha Subbanna6d3a2c52019-10-24 07:21:30 -050014CONTROL_INTERFACE=$INTERFACE_ROOT.Control
Anthony Wilson79f697e2018-09-13 13:48:52 -050015
16OBJECT_ROOT=/xyz/openbmc_project
17STATE_OBJECT=$OBJECT_ROOT/state
Vishwanatha Subbanna6d3a2c52019-10-24 07:21:30 -050018CONTROL_OBJECT=$OBJECT_ROOT/control
Anthony Wilson79f697e2018-09-13 13:48:52 -050019
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -050020HOST_TIMEOUT_TARGET=obmc-host-timeout@0.target
Vishwanatha Subbanna84b3b292019-11-04 05:43:19 -060021HOST_CRASH_TARGET=obmc-host-crash@0.target
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -050022
Anthony Wilsonacf54d02018-09-20 15:19:28 -050023## 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
30G_ORIG_CMD=
31# The state an interface should be in after executing the requested command.
32G_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.
35G_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.
38G_WAIT=
Andrew Jeffery60c3ac82019-10-02 09:29:29 +093039# Print the journal to the console
40G_VERBOSE=
Anthony Wilsonacf54d02018-09-20 15:19:28 -050041
Anthony Wilsonf3f16fa2018-09-13 14:10:52 -050042print_help ()
43{
44 echo "$USAGE"
45 echo ""
46 echo "positional arguments:"
Anthony Wilson0f359832018-09-13 14:28:07 -050047 echo " {$OPTS}"
Anthony Wilsonf3f16fa2018-09-13 14:10:52 -050048 echo ""
Vishwanatha Subbanna6d3a2c52019-10-24 07:21:30 -050049 echo "Examples:"
50 echo ""
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -060051 echo "obmcutil hostrebootoff Disable auto reboot of Host from Quiesce state"
Andrew Geissler3191be82020-10-23 10:45:55 -050052 echo "obmcutil hostrebootoffonetime Disable auto reboot of Host from"
53 echo " Quiesce state for a single boot"
Andrew Geisslerad1afe52022-02-23 16:07:06 -060054 echo "obmcutil hostrebooton Enable auto reboot of Host from Quiesce state"
Vishwanatha Subbanna6d3a2c52019-10-24 07:21:30 -050055 echo ""
Andrew Geisslerad1afe52022-02-23 16:07:06 -060056 echo "obmcutil bmcrebootoff Disable reboot of BMC"
57 echo "obmcutil bmcrebooton Enable reboot of BMC"
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -060058 echo ""
Andrew Geisslerad1afe52022-02-23 16:07:06 -060059 echo "obmcutil recoveryoff Disable handling boot watchdog timeout and host crash"
60 echo " Also, disable BMC and Host auto reboots"
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -060061 echo ""
Andrew Geisslerad1afe52022-02-23 16:07:06 -060062 echo "obmcutil recoveryon Enable handling boot watchdog timeout and host crash"
63 echo " Also, enable BMC and Host auto reboots"
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -050064 echo ""
Andrew Geisslerad1afe52022-02-23 16:07:06 -060065 echo "obmcutil listbootblock Check for and list any errors blocking the boot"
66 echo " of the system"
Andrew Geissler3b7b5612020-05-14 10:45:29 -050067 echo ""
Andrew Geisslerad1afe52022-02-23 16:07:06 -060068 echo "obmcutil listlogs List all phosphor-logging entries on the"
69 echo " system"
Andrew Geissler295ee4f2020-05-14 14:14:05 -050070 echo ""
Andrew Geisslerad1afe52022-02-23 16:07:06 -060071 echo "obmcutil showlog <log> Display details of input log. Format of <log>"
72 echo " should match listlogs output"
Andrew Geisslerd8c63202020-05-14 15:06:31 -050073 echo ""
Andrew Geisslerad1afe52022-02-23 16:07:06 -060074 echo "obmcutil deletelogs Delete all phosphor-logging entries from"
75 echo " system"
76 echo "obmcutil stopofftargets Manually stop all obmc targets in power off"
77 echo " path"
Andrew Geissler42f28982020-05-14 15:12:42 -050078 echo ""
Andrew Geisslerd8779cd2020-06-11 10:48:40 -050079 echo "optional arguments (must precede the positional options above):"
Anthony Wilsonf3f16fa2018-09-13 14:10:52 -050080 echo " -h, --help show this help message and exit"
Anthony Wilsonacf54d02018-09-20 15:19:28 -050081 echo " -w, --wait block until state transition succeeds or fails"
Andrew Jeffery60c3ac82019-10-02 09:29:29 +093082 echo " -v, --verbose print the journal to stdout if --wait is supplied"
Anthony Wilsonf3f16fa2018-09-13 14:10:52 -050083 exit 0
84}
85
Anthony Wilsonacf54d02018-09-20 15:19:28 -050086run_timeout ()
87{
88 local timeout="$1"; shift
Patrick Williamsb2398202021-04-13 20:53:26 -050089 local cmd="$*"
Andrew Jeffery60c3ac82019-10-02 09:29:29 +093090 local verbose_child=
91
Andrew Jeffery2869a922019-10-18 14:42:34 +103092 if [ -n "$G_VERBOSE" ]; then
Andrew Jeffery60c3ac82019-10-02 09:29:29 +093093 journalctl -f &
94 verbose_child=$!
95 fi
Anthony Wilsonacf54d02018-09-20 15:19:28 -050096
97 $cmd
98
99 # Run a background query for the transition to the expected state
100 # This will be killed if the transition doesn't succeed within
101 # a timeout period.
102 (
Patrick Williamsb2398202021-04-13 20:53:26 -0500103 while ! grep -q "$G_REQUESTED_STATE" <<< "$(handle_cmd "$G_QUERY")" ; do
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500104 sleep 1
105 done
106 ) &
Andrew Jeffery60c3ac82019-10-02 09:29:29 +0930107 wait_child=$!
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500108
109 # Could be bad if process is killed before 'timeout' occurs if
110 # transition doesn't succeed.
111 trap -- "" SIGTERM
112
113 # Workaround for lack of 'timeout' command.
114 (
Patrick Williamsb2398202021-04-13 20:53:26 -0500115 sleep "$timeout"
Andrew Jeffery60c3ac82019-10-02 09:29:29 +0930116 kill $wait_child
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500117 ) > /dev/null 2>&1 &
118
Andrew Jeffery60c3ac82019-10-02 09:29:29 +0930119 if ! wait $wait_child; then
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500120 echo "Unable to confirm '$G_ORIG_CMD' success" \
121 "within timeout period (${timeout}s)"
122 fi
Andrew Jeffery60c3ac82019-10-02 09:29:29 +0930123
Andrew Jeffery8be70292019-11-01 08:56:49 +1030124 if [ -n "$verbose_child" ]; then
Andrew Jeffery60c3ac82019-10-02 09:29:29 +0930125 kill $verbose_child
126 fi
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500127}
128
129run_cmd ()
130{
Patrick Williamsb2398202021-04-13 20:53:26 -0500131 local cmd="$*";
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500132
133 if [ -n "$G_WAIT" ]; then
Patrick Williamsb2398202021-04-13 20:53:26 -0500134 run_timeout "$G_WAIT" "$cmd"
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500135 else
136 $cmd
137 fi
138}
139
Anthony Wilson3ae0a352018-09-13 14:47:56 -0500140set_property ()
141{
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500142 run_cmd busctl set-property "$@"
Anthony Wilson3ae0a352018-09-13 14:47:56 -0500143}
144
Anthony Wilson79f697e2018-09-13 13:48:52 -0500145get_property ()
146{
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500147 G_WAIT=""
148 run_cmd busctl get-property "$@"
Anthony Wilson79f697e2018-09-13 13:48:52 -0500149}
150
151state_query ()
152{
Patrick Williamsb2398202021-04-13 20:53:26 -0500153 local state
154 state=$(get_property "$@" | cut -d '"' -f2)
155 printf "%-20s: %s\n" "$4" "$state"
Anthony Wilson79f697e2018-09-13 13:48:52 -0500156}
157
Anthony Wilsonea87db42018-09-26 16:06:38 -0500158print_usage_err ()
159{
160 echo "ERROR: $1" >&2
161 echo "$USAGE"
162 exit 1
163}
164
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -0500165mask_systemd_target ()
166{
Patrick Williamsb2398202021-04-13 20:53:26 -0500167 target="$*"
168 systemctl mask "$target"
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -0500169}
170
171unmask_systemd_target ()
172{
Patrick Williamsb2398202021-04-13 20:53:26 -0500173 target="$*"
174 systemctl unmask "$target"
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -0500175}
176
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -0600177disable_bmc_reboot ()
178{
179 dir="/run/systemd/system/"
180 file="reboot-guard.conf"
181 units=("reboot" "poweroff" "halt")
182
183 for unit in "${units[@]}"; do
Patrick Williamsb2398202021-04-13 20:53:26 -0500184 mkdir -p "${dir}${unit}.target.d"
185 echo -e "[Unit]\nRefuseManualStart=yes" >> "${dir}${unit}.target.d/${file}"
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -0600186 done
187}
188
189enable_bmc_reboot ()
190{
191 dir="/run/systemd/system/"
192 file="reboot-guard.conf"
193 units=("reboot" "poweroff" "halt")
194
195 for unit in "${units[@]}"; do
Patrick Williamsb2398202021-04-13 20:53:26 -0500196 rm -rf "${dir}${unit}.target.d/${file}"
197 rm -rf "${dir}${unit}.target.d"
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -0600198 done
199}
200
Andrew Geissler3b7b5612020-05-14 10:45:29 -0500201# will write blocking errors to stdout
202check_boot_block_errors ()
203{
204 # array of boot block objects
205 blockArray=()
206
207 # Look for any objects under logging that implement the
208 # xyz.openbmc_project.Logging.ErrorBlocksTransition
209 subtree="$(busctl call xyz.openbmc_project.ObjectMapper \
210 /xyz/openbmc_project/object_mapper \
211 xyz.openbmc_project.ObjectMapper \
212 GetSubTree sias "/xyz/openbmc_project/logging/" 0 1 \
213 xyz.openbmc_project.Logging.ErrorBlocksTransition)"
214
215 # remove quotation marks
Patrick Williamsb2398202021-04-13 20:53:26 -0500216 # shellcheck disable=SC2001
217 subtree="$(echo "$subtree" | sed 's/\"//g')"
Andrew Geissler3b7b5612020-05-14 10:45:29 -0500218
219 for entry in $subtree; do
220 if [[ ${entry} =~ "xyz/openbmc_project/logging/block"* ]]; then
Patrick Williamsb2398202021-04-13 20:53:26 -0500221 blockArray+=( "$entry" )
Andrew Geissler3b7b5612020-05-14 10:45:29 -0500222 fi
223 done
224
225 # now find associated error log for each boot block error
226 for berror in "${blockArray[@]}"; do
Patrick Williamsb2398202021-04-13 20:53:26 -0500227 assocs="$(busctl call xyz.openbmc_project.Logging "$berror" \
Andrew Geissler3b7b5612020-05-14 10:45:29 -0500228 org.freedesktop.DBus.Properties Get \
229 ss xyz.openbmc_project.Association.Definitions Associations)"
230
231 # remove quotation marks
Patrick Williamsb2398202021-04-13 20:53:26 -0500232 # shellcheck disable=SC2001
233 assocs="$(echo "$assocs" | sed 's/\"//g')"
Andrew Geissler3b7b5612020-05-14 10:45:29 -0500234
235 for entry in $assocs; do
236 if [[ ${entry} =~ "xyz/openbmc_project/logging/entry"* ]]; then
237 echo "Blocking Error: $entry"
238 fi
239 done
240 done
241}
242
Andrew Geisslerdeb6bb42020-05-14 13:44:57 -0500243# helper function to check for boot block errors and notify user
244check_and_warn_boot_block()
245{
246 blockingErrors=$(check_boot_block_errors)
Patrick Williamsb2398202021-04-13 20:53:26 -0500247 if [ -n "$blockingErrors" ]; then
Andrew Geisslerdeb6bb42020-05-14 13:44:57 -0500248 echo !!!!!!!!!!
249 echo "WARNING! System has blocking errors that will prevent boot"
250 echo "$blockingErrors"
251 echo !!!!!!!!!!
252 fi
253}
254
Andrew Geissler295ee4f2020-05-14 14:14:05 -0500255# list all phosphor-logging entries
256list_logs()
257{
258 # Look for any objects under logging that implement the
259 # xyz.openbmc_project.Logging.Entry
260 busctl -j call xyz.openbmc_project.ObjectMapper \
261 /xyz/openbmc_project/object_mapper \
262 xyz.openbmc_project.ObjectMapper \
263 GetSubTreePaths sias "/xyz/openbmc_project/logging/" 0 1 \
264 xyz.openbmc_project.Logging.Entry
265}
266
Andrew Geisslerd8c63202020-05-14 15:06:31 -0500267# display input log details
268show_log()
269{
270 busctl -j call xyz.openbmc_project.Logging \
Patrick Williamsb2398202021-04-13 20:53:26 -0500271 "$1" \
Andrew Geisslerd8c63202020-05-14 15:06:31 -0500272 org.freedesktop.DBus.Properties \
273 GetAll s xyz.openbmc_project.Logging.Entry
274}
275
Andrew Geissler42f28982020-05-14 15:12:42 -0500276# delete all phosphor-logging entries
277delete_logs()
278{
279 busctl call xyz.openbmc_project.Logging \
280 /xyz/openbmc_project/logging \
281 xyz.openbmc_project.Collection.DeleteAll DeleteAll
282}
283
Andrew Geisslerad1afe52022-02-23 16:07:06 -0600284# stop all targets associated with powering off a system
285stop_off_targets()
286{
287 systemctl stop \
288 obmc-chassis-powered-off@0.target \
289 obmc-host-stop-pre@0.target \
290 obmc-host-stopped@0.target \
291 obmc-host-stopping@0.target \
292 obmc-power-off@0.target \
293 obmc-power-stop-pre@0.target \
294 obmc-power-stop@0.target
295}
296
Anthony Wilson79f697e2018-09-13 13:48:52 -0500297handle_cmd ()
298{
299 case "$1" in
Anthony Wilson3ae0a352018-09-13 14:47:56 -0500300 chassisoff)
301 OBJECT=$STATE_OBJECT/chassis0
302 SERVICE=$(mapper get-service $OBJECT)
303 INTERFACE=$STATE_INTERFACE.Chassis
304 PROPERTY=RequestedPowerTransition
305 VALUE=$INTERFACE.Transition.Off
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500306 G_REQUESTED_STATE=$INTERFACE.PowerState.Off
307 G_QUERY="chassisstate"
Patrick Williamsb2398202021-04-13 20:53:26 -0500308 set_property "$SERVICE" $OBJECT $INTERFACE $PROPERTY "s" $VALUE
Anthony Wilson3ae0a352018-09-13 14:47:56 -0500309 ;;
310 chassison)
Andrew Geisslerdeb6bb42020-05-14 13:44:57 -0500311 check_and_warn_boot_block
Anthony Wilson3ae0a352018-09-13 14:47:56 -0500312 OBJECT=$STATE_OBJECT/chassis0
313 SERVICE=$(mapper get-service $OBJECT)
314 INTERFACE=$STATE_INTERFACE.Chassis
315 PROPERTY=RequestedPowerTransition
316 VALUE=$INTERFACE.Transition.On
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500317 G_REQUESTED_STATE=$INTERFACE.PowerState.On
318 G_QUERY="chassisstate"
Patrick Williamsb2398202021-04-13 20:53:26 -0500319 set_property "$SERVICE" $OBJECT $INTERFACE $PROPERTY "s" $VALUE
Anthony Wilson3ae0a352018-09-13 14:47:56 -0500320 ;;
321 poweroff)
322 OBJECT=$STATE_OBJECT/host0
323 SERVICE=$(mapper get-service $OBJECT)
324 INTERFACE=$STATE_INTERFACE.Host
325 PROPERTY=RequestedHostTransition
326 VALUE=$INTERFACE.Transition.Off
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500327 G_REQUESTED_STATE=$INTERFACE.HostState.Off
328 G_QUERY="hoststate"
Patrick Williamsb2398202021-04-13 20:53:26 -0500329 set_property "$SERVICE" $OBJECT $INTERFACE $PROPERTY "s" $VALUE
Anthony Wilson3ae0a352018-09-13 14:47:56 -0500330 ;;
331 poweron)
Andrew Geisslerdeb6bb42020-05-14 13:44:57 -0500332 check_and_warn_boot_block
Anthony Wilson3ae0a352018-09-13 14:47:56 -0500333 OBJECT=$STATE_OBJECT/host0
334 SERVICE=$(mapper get-service $OBJECT)
335 INTERFACE=$STATE_INTERFACE.Host
336 PROPERTY=RequestedHostTransition
337 VALUE=$INTERFACE.Transition.On
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500338 G_REQUESTED_STATE=$INTERFACE.HostState.Running
339 G_QUERY="hoststate"
Patrick Williamsb2398202021-04-13 20:53:26 -0500340 set_property "$SERVICE" $OBJECT $INTERFACE $PROPERTY "s" $VALUE
Anthony Wilson3ae0a352018-09-13 14:47:56 -0500341 ;;
Anthony Wilson79f697e2018-09-13 13:48:52 -0500342 bmcstate)
343 OBJECT=$STATE_OBJECT/bmc0
344 SERVICE=$(mapper get-service $OBJECT)
345 INTERFACE=$STATE_INTERFACE.BMC
346 PROPERTY=CurrentBMCState
Patrick Williamsb2398202021-04-13 20:53:26 -0500347 state_query "$SERVICE" $OBJECT $INTERFACE $PROPERTY
Anthony Wilson79f697e2018-09-13 13:48:52 -0500348 ;;
349 chassisstate)
350 OBJECT=$STATE_OBJECT/chassis0
351 SERVICE=$(mapper get-service $OBJECT)
352 INTERFACE=$STATE_INTERFACE.Chassis
353 PROPERTY=CurrentPowerState
Patrick Williamsb2398202021-04-13 20:53:26 -0500354 state_query "$SERVICE" $OBJECT $INTERFACE $PROPERTY
Anthony Wilson79f697e2018-09-13 13:48:52 -0500355 ;;
356 hoststate)
357 OBJECT=$STATE_OBJECT/host0
358 SERVICE=$(mapper get-service $OBJECT)
359 INTERFACE=$STATE_INTERFACE.Host
360 PROPERTY=CurrentHostState
Patrick Williamsb2398202021-04-13 20:53:26 -0500361 state_query "$SERVICE" $OBJECT $INTERFACE $PROPERTY
Anthony Wilson79f697e2018-09-13 13:48:52 -0500362 ;;
Alexander Filippov86cffd92019-04-03 16:29:57 +0300363 osstate)
364 OBJECT=$STATE_OBJECT/host0
365 SERVICE=$(mapper get-service $OBJECT)
366 INTERFACE=$STATE_INTERFACE.OperatingSystem.Status
367 PROPERTY=OperatingSystemState
Patrick Williamsb2398202021-04-13 20:53:26 -0500368 state_query "$SERVICE" $OBJECT $INTERFACE $PROPERTY
Alexander Filippov86cffd92019-04-03 16:29:57 +0300369 ;;
Anthony Wilson79f697e2018-09-13 13:48:52 -0500370 state|status)
Alexander Filippov86cffd92019-04-03 16:29:57 +0300371 for query in bmcstate chassisstate hoststate bootprogress osstate
Anthony Wilson79f697e2018-09-13 13:48:52 -0500372 do
373 handle_cmd $query
374 done
Andrew Geisslerdeb6bb42020-05-14 13:44:57 -0500375 check_and_warn_boot_block
Anthony Wilson79f697e2018-09-13 13:48:52 -0500376 ;;
Anthony Wilson50c5f882018-09-13 14:19:37 -0500377 bootprogress)
378 OBJECT=$STATE_OBJECT/host0
379 SERVICE=$(mapper get-service $OBJECT)
380 INTERFACE=$STATE_INTERFACE.Boot.Progress
381 PROPERTY=BootProgress
Patrick Williamsb2398202021-04-13 20:53:26 -0500382 state_query "$SERVICE" $OBJECT $INTERFACE $PROPERTY
Anthony Wilson50c5f882018-09-13 14:19:37 -0500383 ;;
Anthony Wilson0f359832018-09-13 14:28:07 -0500384 power)
385 OBJECT=/org/openbmc/control/power0
386 SERVICE=$(mapper get-service $OBJECT)
387 INTERFACE=org.openbmc.control.Power
388 for property in pgood state pgood_timeout
389 do
390 # get_property can potentially return several
391 # different formats of values, so we do the parsing outside
392 # of get_property depending on the query. These queries
393 # return 'i VALUE' formatted strings.
Patrick Williamsb2398202021-04-13 20:53:26 -0500394 STATE=$(get_property "$SERVICE" $OBJECT $INTERFACE $property \
Anthony Wilson0f359832018-09-13 14:28:07 -0500395 | sed 's/i[ ^I]*//')
Patrick Williamsb2398202021-04-13 20:53:26 -0500396 printf "%s = %s\n" $property "$STATE"
Anthony Wilson0f359832018-09-13 14:28:07 -0500397 done
398 ;;
Anthony Wilson189cf242018-10-23 01:18:21 -0500399 chassiskill)
400 /usr/libexec/chassiskill
401 ;;
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -0600402 hostrebootoff)
Vishwanatha Subbanna6d3a2c52019-10-24 07:21:30 -0500403 OBJECT=$CONTROL_OBJECT/host0/auto_reboot
404 SERVICE=$(mapper get-service $OBJECT)
405 INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy
406 PROPERTY=AutoReboot
407 VALUE=false
Patrick Williamsb2398202021-04-13 20:53:26 -0500408 set_property "$SERVICE" $OBJECT $INTERFACE $PROPERTY "b" $VALUE
Vishwanatha Subbanna6d3a2c52019-10-24 07:21:30 -0500409 ;;
Andrew Geissler3191be82020-10-23 10:45:55 -0500410 hostrebootoffonetime)
411 OBJECT=$CONTROL_OBJECT/host0/auto_reboot/one_time
412 SERVICE=$(mapper get-service $OBJECT)
413 INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy
414 PROPERTY=AutoReboot
415 VALUE=false
Patrick Williamsb2398202021-04-13 20:53:26 -0500416 set_property "$SERVICE" $OBJECT $INTERFACE $PROPERTY "b" $VALUE
Andrew Geissler3191be82020-10-23 10:45:55 -0500417 ;;
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -0600418 hostrebooton)
Vishwanatha Subbanna6d3a2c52019-10-24 07:21:30 -0500419 OBJECT=$CONTROL_OBJECT/host0/auto_reboot
420 SERVICE=$(mapper get-service $OBJECT)
421 INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy
422 PROPERTY=AutoReboot
423 VALUE=true
Patrick Williamsb2398202021-04-13 20:53:26 -0500424 set_property "$SERVICE" $OBJECT $INTERFACE $PROPERTY "b" $VALUE
Vishwanatha Subbanna6d3a2c52019-10-24 07:21:30 -0500425 ;;
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -0600426 bmcrebootoff)
427 disable_bmc_reboot
428 ;;
429 bmcrebooton)
430 enable_bmc_reboot
431 ;;
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -0500432 recoveryoff)
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -0600433 handle_cmd hostrebootoff
434 handle_cmd bmcrebootoff
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -0500435 mask_systemd_target $HOST_TIMEOUT_TARGET
Vishwanatha Subbanna84b3b292019-11-04 05:43:19 -0600436 mask_systemd_target $HOST_CRASH_TARGET
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -0500437 ;;
438 recoveryon)
Vishwanatha Subbannaa65d30d2019-11-13 01:26:12 -0600439 handle_cmd hostrebooton
440 handle_cmd bmcrebooton
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -0500441 unmask_systemd_target $HOST_TIMEOUT_TARGET
Vishwanatha Subbanna84b3b292019-11-04 05:43:19 -0600442 unmask_systemd_target $HOST_CRASH_TARGET
Vishwanatha Subbanna7a787dd2019-10-31 06:02:31 -0500443 ;;
Andrew Geissler3b7b5612020-05-14 10:45:29 -0500444 listbootblock)
445 blockingErrors=$(check_boot_block_errors)
446 if [ -z "$blockingErrors" ]; then
447 echo "No blocking errors present"
448 else
449 echo "$blockingErrors"
450 fi
451 ;;
Andrew Geissler295ee4f2020-05-14 14:14:05 -0500452 listlogs)
453 list_logs
454 ;;
Andrew Geisslerd8c63202020-05-14 15:06:31 -0500455 showlog)
Patrick Williamsb2398202021-04-13 20:53:26 -0500456 show_log "$2"
Andrew Geisslerd8c63202020-05-14 15:06:31 -0500457 ;;
Andrew Geissler42f28982020-05-14 15:12:42 -0500458 deletelogs)
459 delete_logs
460 ;;
Andrew Geisslerad1afe52022-02-23 16:07:06 -0600461 stopofftargets)
462 stop_off_targets
463 ;;
Anthony Wilson79f697e2018-09-13 13:48:52 -0500464 *)
Anthony Wilsonea87db42018-09-26 16:06:38 -0500465 print_usage_err "Invalid command '$1'"
Anthony Wilson79f697e2018-09-13 13:48:52 -0500466 ;;
467 esac
468}
469
Andrew Geisslerd8779cd2020-06-11 10:48:40 -0500470shiftcnt=0
Anthony Wilsonea87db42018-09-26 16:06:38 -0500471for arg in "$@"; do
472 case $arg in
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500473 -w|--wait)
474 G_WAIT=30
Andrew Geisslerd8779cd2020-06-11 10:48:40 -0500475 shiftcnt=$((shiftcnt+1))
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500476 continue
477 ;;
Anthony Wilsonea87db42018-09-26 16:06:38 -0500478 -h|--help)
479 print_help
480 ;;
Andrew Jeffery60c3ac82019-10-02 09:29:29 +0930481 -v|--verbose)
482 G_VERBOSE=y
Andrew Geisslerd8779cd2020-06-11 10:48:40 -0500483 shiftcnt=$((shiftcnt+1))
Andrew Jeffery60c3ac82019-10-02 09:29:29 +0930484 ;;
Anthony Wilsonea87db42018-09-26 16:06:38 -0500485 -*)
486 print_usage_err "Unknown option: $arg"
487 ;;
488 *)
Anthony Wilsonacf54d02018-09-20 15:19:28 -0500489 G_ORIG_CMD=$arg
Andrew Geisslerd8779cd2020-06-11 10:48:40 -0500490 # shift out the optional parameters
491 shift $shiftcnt
Andrew Geisslerd8c63202020-05-14 15:06:31 -0500492 # pass all arguments to handle_cmd in case command takes additional
493 # parameters
494 handle_cmd "$@"
Anthony Wilsonea87db42018-09-26 16:06:38 -0500495 break
496 ;;
497 esac
498done