179f697e0SAnthony Wilson#!/bin/sh -e 279f697e0SAnthony Wilson 379f697e0SAnthony Wilsonset -euo pipefail 479f697e0SAnthony Wilson 5189cf248SAnthony WilsonOPTS="bmcstate,bootprogress,chassiskill,chassisoff,chassison,chassisstate,hoststate,\ 6a65d30d1SVishwanatha Subbannaosstate,power,poweroff,poweron,state,status,hostrebootoff,hostrebooton,recoveryoff,recoveryon,\ 73b7b5619SAndrew Geisslerbmcrebootoff, bmcrebooton, listbootblock" 80f35983dSAnthony Wilson 960c3ac8cSAndrew JefferyUSAGE="Usage: obmcutil [-h] [--wait] [--verbose] 100f35983dSAnthony Wilson {$OPTS}" 1179f697e0SAnthony Wilson 1279f697e0SAnthony WilsonINTERFACE_ROOT=xyz.openbmc_project 1379f697e0SAnthony WilsonSTATE_INTERFACE=$INTERFACE_ROOT.State 146d3a2c54SVishwanatha SubbannaCONTROL_INTERFACE=$INTERFACE_ROOT.Control 1579f697e0SAnthony Wilson 1679f697e0SAnthony WilsonOBJECT_ROOT=/xyz/openbmc_project 1779f697e0SAnthony WilsonSTATE_OBJECT=$OBJECT_ROOT/state 186d3a2c54SVishwanatha SubbannaCONTROL_OBJECT=$OBJECT_ROOT/control 1979f697e0SAnthony Wilson 207a787dd7SVishwanatha SubbannaHOST_TIMEOUT_TARGET=obmc-host-timeout@0.target 2184b3b29eSVishwanatha SubbannaHOST_CRASH_TARGET=obmc-host-crash@0.target 227a787dd7SVishwanatha Subbanna 23acf54d08SAnthony Wilson## NOTE: The following global variables are used only in the run_timeout cmd. 24acf54d08SAnthony Wilson## By declaring these globally instead of passing them through the 25acf54d08SAnthony Wilson## intermediary functions, which may not be "best practice", the readability 26acf54d08SAnthony Wilson## and cleanliness of the code should at least be increased. 27acf54d08SAnthony Wilson 28acf54d08SAnthony Wilson# The command passed in to be executed (e.g. poweron/off, status, etc.) 29acf54d08SAnthony Wilson# This will be be used in some instances of error reporting 30acf54d08SAnthony WilsonG_ORIG_CMD= 31acf54d08SAnthony Wilson# The state an interface should be in after executing the requested command. 32acf54d08SAnthony WilsonG_REQUESTED_STATE= 33acf54d08SAnthony Wilson# The query to run during a poweron/off or chassison/off to check that 34acf54d08SAnthony Wilson# the requested state (G_REQUESTED_STATE) of the interface has been reached. 35acf54d08SAnthony WilsonG_QUERY= 36acf54d08SAnthony Wilson# Wait the set period of time for state transitions to be successful before 37acf54d08SAnthony Wilson# continuing on with the program or reporting an error if timeout reached. 38acf54d08SAnthony WilsonG_WAIT= 3960c3ac8cSAndrew Jeffery# Print the journal to the console 4060c3ac8cSAndrew JefferyG_VERBOSE= 41acf54d08SAnthony Wilson 42f3f16fa9SAnthony Wilsonprint_help () 43f3f16fa9SAnthony Wilson{ 44f3f16fa9SAnthony Wilson echo "$USAGE" 45f3f16fa9SAnthony Wilson echo "" 46f3f16fa9SAnthony Wilson echo "positional arguments:" 470f35983dSAnthony Wilson echo " {$OPTS}" 48f3f16fa9SAnthony Wilson echo "" 496d3a2c54SVishwanatha Subbanna echo "Examples:" 506d3a2c54SVishwanatha Subbanna echo "" 51a65d30d1SVishwanatha Subbanna echo "obmcutil hostrebootoff Disable auto reboot of Host from Quiesce state" 52a65d30d1SVishwanatha Subbanna echo "obmcutil hostrebooton Enable auto reboot of Host from Quiesce state" 53a65d30d1SVishwanatha Subbanna echo "" 54a65d30d1SVishwanatha Subbanna echo "obmcutil bmcrebootoff Disable reboot of BMC" 55a65d30d1SVishwanatha Subbanna echo "obmcutil bmcrebooton Enable reboot of BMC" 566d3a2c54SVishwanatha Subbanna echo "" 5784b3b29eSVishwanatha Subbanna echo "obmcutil recoveryoff Disable handling boot watchdog timeout and host crash" 58a65d30d1SVishwanatha Subbanna echo " Also, disable BMC and Host auto reboots" 59a65d30d1SVishwanatha Subbanna echo "" 6084b3b29eSVishwanatha Subbanna echo "obmcutil recoveryon Enable handling boot watchdog timeout and host crash" 61a65d30d1SVishwanatha Subbanna echo " Also, enable BMC and Host auto reboots" 627a787dd7SVishwanatha Subbanna echo "" 633b7b5619SAndrew Geissler echo "obmcutil listbootblock Check for and list any errors blocking the boot" 643b7b5619SAndrew Geissler echo " of the system" 653b7b5619SAndrew Geissler echo "" 66f3f16fa9SAnthony Wilson echo "optional arguments:" 67f3f16fa9SAnthony Wilson echo " -h, --help show this help message and exit" 68acf54d08SAnthony Wilson echo " -w, --wait block until state transition succeeds or fails" 6960c3ac8cSAndrew Jeffery echo " -v, --verbose print the journal to stdout if --wait is supplied" 70f3f16fa9SAnthony Wilson exit 0 71f3f16fa9SAnthony Wilson} 72f3f16fa9SAnthony Wilson 73acf54d08SAnthony Wilsonrun_timeout () 74acf54d08SAnthony Wilson{ 75acf54d08SAnthony Wilson local timeout="$1"; shift 76acf54d08SAnthony Wilson local cmd="$@" 7760c3ac8cSAndrew Jeffery local verbose_child= 7860c3ac8cSAndrew Jeffery 792869a926SAndrew Jeffery if [ -n "$G_VERBOSE" ]; then 8060c3ac8cSAndrew Jeffery journalctl -f & 8160c3ac8cSAndrew Jeffery verbose_child=$! 8260c3ac8cSAndrew Jeffery fi 83acf54d08SAnthony Wilson 84acf54d08SAnthony Wilson $cmd 85acf54d08SAnthony Wilson 86acf54d08SAnthony Wilson # Run a background query for the transition to the expected state 87acf54d08SAnthony Wilson # This will be killed if the transition doesn't succeed within 88acf54d08SAnthony Wilson # a timeout period. 89acf54d08SAnthony Wilson ( 90acf54d08SAnthony Wilson while ! grep -q $G_REQUESTED_STATE <<< $(handle_cmd $G_QUERY) ; do 91acf54d08SAnthony Wilson sleep 1 92acf54d08SAnthony Wilson done 93acf54d08SAnthony Wilson ) & 9460c3ac8cSAndrew Jeffery wait_child=$! 95acf54d08SAnthony Wilson 96acf54d08SAnthony Wilson # Could be bad if process is killed before 'timeout' occurs if 97acf54d08SAnthony Wilson # transition doesn't succeed. 98acf54d08SAnthony Wilson trap -- "" SIGTERM 99acf54d08SAnthony Wilson 100acf54d08SAnthony Wilson # Workaround for lack of 'timeout' command. 101acf54d08SAnthony Wilson ( 102acf54d08SAnthony Wilson sleep $timeout 10360c3ac8cSAndrew Jeffery kill $wait_child 104acf54d08SAnthony Wilson ) > /dev/null 2>&1 & 105acf54d08SAnthony Wilson 10660c3ac8cSAndrew Jeffery if ! wait $wait_child; then 107acf54d08SAnthony Wilson echo "Unable to confirm '$G_ORIG_CMD' success" \ 108acf54d08SAnthony Wilson "within timeout period (${timeout}s)" 109acf54d08SAnthony Wilson fi 11060c3ac8cSAndrew Jeffery 1118be70293SAndrew Jeffery if [ -n "$verbose_child" ]; then 11260c3ac8cSAndrew Jeffery kill $verbose_child 11360c3ac8cSAndrew Jeffery fi 114acf54d08SAnthony Wilson} 115acf54d08SAnthony Wilson 116acf54d08SAnthony Wilsonrun_cmd () 117acf54d08SAnthony Wilson{ 118acf54d08SAnthony Wilson local cmd="$@"; 119acf54d08SAnthony Wilson 120acf54d08SAnthony Wilson if [ -n "$G_WAIT" ]; then 121acf54d08SAnthony Wilson run_timeout $G_WAIT "$cmd" 122acf54d08SAnthony Wilson else 123acf54d08SAnthony Wilson $cmd 124acf54d08SAnthony Wilson fi 125acf54d08SAnthony Wilson} 126acf54d08SAnthony Wilson 1273ae0a354SAnthony Wilsonset_property () 1283ae0a354SAnthony Wilson{ 129acf54d08SAnthony Wilson run_cmd busctl set-property "$@" 1303ae0a354SAnthony Wilson} 1313ae0a354SAnthony Wilson 13279f697e0SAnthony Wilsonget_property () 13379f697e0SAnthony Wilson{ 134acf54d08SAnthony Wilson G_WAIT="" 135acf54d08SAnthony Wilson run_cmd busctl get-property "$@" 13679f697e0SAnthony Wilson} 13779f697e0SAnthony Wilson 13879f697e0SAnthony Wilsonstate_query () 13979f697e0SAnthony Wilson{ 14079f697e0SAnthony Wilson local state=$(get_property "$@" | cut -d '"' -f2) 14179f697e0SAnthony Wilson printf "%-20s: %s\n" $4 $state 14279f697e0SAnthony Wilson} 14379f697e0SAnthony Wilson 144ea87db40SAnthony Wilsonprint_usage_err () 145ea87db40SAnthony Wilson{ 146ea87db40SAnthony Wilson echo "ERROR: $1" >&2 147ea87db40SAnthony Wilson echo "$USAGE" 148ea87db40SAnthony Wilson exit 1 149ea87db40SAnthony Wilson} 150ea87db40SAnthony Wilson 1517a787dd7SVishwanatha Subbannamask_systemd_target () 1527a787dd7SVishwanatha Subbanna{ 1537a787dd7SVishwanatha Subbanna target="$@" 1547a787dd7SVishwanatha Subbanna systemctl mask $target 1557a787dd7SVishwanatha Subbanna} 1567a787dd7SVishwanatha Subbanna 1577a787dd7SVishwanatha Subbannaunmask_systemd_target () 1587a787dd7SVishwanatha Subbanna{ 1597a787dd7SVishwanatha Subbanna target="$@" 1607a787dd7SVishwanatha Subbanna systemctl unmask $target 1617a787dd7SVishwanatha Subbanna} 1627a787dd7SVishwanatha Subbanna 163a65d30d1SVishwanatha Subbannadisable_bmc_reboot () 164a65d30d1SVishwanatha Subbanna{ 165a65d30d1SVishwanatha Subbanna dir="/run/systemd/system/" 166a65d30d1SVishwanatha Subbanna file="reboot-guard.conf" 167a65d30d1SVishwanatha Subbanna units=("reboot" "poweroff" "halt") 168a65d30d1SVishwanatha Subbanna 169a65d30d1SVishwanatha Subbanna for unit in "${units[@]}"; do 170a65d30d1SVishwanatha Subbanna mkdir -p ${dir}${unit}.target.d 171a65d30d1SVishwanatha Subbanna echo -e "[Unit]\nRefuseManualStart=yes" >> ${dir}${unit}.target.d/${file} 172a65d30d1SVishwanatha Subbanna done 173a65d30d1SVishwanatha Subbanna} 174a65d30d1SVishwanatha Subbanna 175a65d30d1SVishwanatha Subbannaenable_bmc_reboot () 176a65d30d1SVishwanatha Subbanna{ 177a65d30d1SVishwanatha Subbanna dir="/run/systemd/system/" 178a65d30d1SVishwanatha Subbanna file="reboot-guard.conf" 179a65d30d1SVishwanatha Subbanna units=("reboot" "poweroff" "halt") 180a65d30d1SVishwanatha Subbanna 181a65d30d1SVishwanatha Subbanna for unit in "${units[@]}"; do 182a65d30d1SVishwanatha Subbanna rm -rf ${dir}${unit}.target.d/${file} 183a65d30d1SVishwanatha Subbanna rm -rf ${dir}${unit}.target.d 184a65d30d1SVishwanatha Subbanna done 185a65d30d1SVishwanatha Subbanna} 186a65d30d1SVishwanatha Subbanna 1873b7b5619SAndrew Geissler# will write blocking errors to stdout 1883b7b5619SAndrew Geisslercheck_boot_block_errors () 1893b7b5619SAndrew Geissler{ 1903b7b5619SAndrew Geissler # array of boot block objects 1913b7b5619SAndrew Geissler blockArray=() 1923b7b5619SAndrew Geissler 1933b7b5619SAndrew Geissler # Look for any objects under logging that implement the 1943b7b5619SAndrew Geissler # xyz.openbmc_project.Logging.ErrorBlocksTransition 1953b7b5619SAndrew Geissler subtree="$(busctl call xyz.openbmc_project.ObjectMapper \ 1963b7b5619SAndrew Geissler /xyz/openbmc_project/object_mapper \ 1973b7b5619SAndrew Geissler xyz.openbmc_project.ObjectMapper \ 1983b7b5619SAndrew Geissler GetSubTree sias "/xyz/openbmc_project/logging/" 0 1 \ 1993b7b5619SAndrew Geissler xyz.openbmc_project.Logging.ErrorBlocksTransition)" 2003b7b5619SAndrew Geissler 2013b7b5619SAndrew Geissler # remove quotation marks 2023b7b5619SAndrew Geissler subtree="$(echo $subtree | sed 's/\"//g')" 2033b7b5619SAndrew Geissler 2043b7b5619SAndrew Geissler for entry in $subtree; do 2053b7b5619SAndrew Geissler if [[ ${entry} =~ "xyz/openbmc_project/logging/block"* ]]; then 2063b7b5619SAndrew Geissler blockArray+=( $entry ) 2073b7b5619SAndrew Geissler fi 2083b7b5619SAndrew Geissler done 2093b7b5619SAndrew Geissler 2103b7b5619SAndrew Geissler # now find associated error log for each boot block error 2113b7b5619SAndrew Geissler for berror in "${blockArray[@]}"; do 2123b7b5619SAndrew Geissler assocs="$(busctl call xyz.openbmc_project.Logging $berror \ 2133b7b5619SAndrew Geissler org.freedesktop.DBus.Properties Get \ 2143b7b5619SAndrew Geissler ss xyz.openbmc_project.Association.Definitions Associations)" 2153b7b5619SAndrew Geissler 2163b7b5619SAndrew Geissler # remove quotation marks 2173b7b5619SAndrew Geissler assocs="$(echo $assocs | sed 's/\"//g')" 2183b7b5619SAndrew Geissler 2193b7b5619SAndrew Geissler for entry in $assocs; do 2203b7b5619SAndrew Geissler if [[ ${entry} =~ "xyz/openbmc_project/logging/entry"* ]]; then 2213b7b5619SAndrew Geissler echo "Blocking Error: $entry" 2223b7b5619SAndrew Geissler fi 2233b7b5619SAndrew Geissler done 2243b7b5619SAndrew Geissler done 2253b7b5619SAndrew Geissler} 2263b7b5619SAndrew Geissler 227*deb6bb45SAndrew Geissler# helper function to check for boot block errors and notify user 228*deb6bb45SAndrew Geisslercheck_and_warn_boot_block() 229*deb6bb45SAndrew Geissler{ 230*deb6bb45SAndrew Geissler blockingErrors=$(check_boot_block_errors) 231*deb6bb45SAndrew Geissler if ! [ -z "$blockingErrors" ]; then 232*deb6bb45SAndrew Geissler echo !!!!!!!!!! 233*deb6bb45SAndrew Geissler echo "WARNING! System has blocking errors that will prevent boot" 234*deb6bb45SAndrew Geissler echo "$blockingErrors" 235*deb6bb45SAndrew Geissler echo !!!!!!!!!! 236*deb6bb45SAndrew Geissler fi 237*deb6bb45SAndrew Geissler} 238*deb6bb45SAndrew Geissler 23979f697e0SAnthony Wilsonhandle_cmd () 24079f697e0SAnthony Wilson{ 24179f697e0SAnthony Wilson case "$1" in 2423ae0a354SAnthony Wilson chassisoff) 2433ae0a354SAnthony Wilson OBJECT=$STATE_OBJECT/chassis0 2443ae0a354SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 2453ae0a354SAnthony Wilson INTERFACE=$STATE_INTERFACE.Chassis 2463ae0a354SAnthony Wilson PROPERTY=RequestedPowerTransition 2473ae0a354SAnthony Wilson VALUE=$INTERFACE.Transition.Off 248acf54d08SAnthony Wilson G_REQUESTED_STATE=$INTERFACE.PowerState.Off 249acf54d08SAnthony Wilson G_QUERY="chassisstate" 2503ae0a354SAnthony Wilson set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE 2513ae0a354SAnthony Wilson ;; 2523ae0a354SAnthony Wilson chassison) 253*deb6bb45SAndrew Geissler check_and_warn_boot_block 2543ae0a354SAnthony Wilson OBJECT=$STATE_OBJECT/chassis0 2553ae0a354SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 2563ae0a354SAnthony Wilson INTERFACE=$STATE_INTERFACE.Chassis 2573ae0a354SAnthony Wilson PROPERTY=RequestedPowerTransition 2583ae0a354SAnthony Wilson VALUE=$INTERFACE.Transition.On 259acf54d08SAnthony Wilson G_REQUESTED_STATE=$INTERFACE.PowerState.On 260acf54d08SAnthony Wilson G_QUERY="chassisstate" 2613ae0a354SAnthony Wilson set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE 2623ae0a354SAnthony Wilson ;; 2633ae0a354SAnthony Wilson poweroff) 2643ae0a354SAnthony Wilson OBJECT=$STATE_OBJECT/host0 2653ae0a354SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 2663ae0a354SAnthony Wilson INTERFACE=$STATE_INTERFACE.Host 2673ae0a354SAnthony Wilson PROPERTY=RequestedHostTransition 2683ae0a354SAnthony Wilson VALUE=$INTERFACE.Transition.Off 269acf54d08SAnthony Wilson G_REQUESTED_STATE=$INTERFACE.HostState.Off 270acf54d08SAnthony Wilson G_QUERY="hoststate" 2713ae0a354SAnthony Wilson set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE 2723ae0a354SAnthony Wilson ;; 2733ae0a354SAnthony Wilson poweron) 274*deb6bb45SAndrew Geissler check_and_warn_boot_block 2753ae0a354SAnthony Wilson OBJECT=$STATE_OBJECT/host0 2763ae0a354SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 2773ae0a354SAnthony Wilson INTERFACE=$STATE_INTERFACE.Host 2783ae0a354SAnthony Wilson PROPERTY=RequestedHostTransition 2793ae0a354SAnthony Wilson VALUE=$INTERFACE.Transition.On 280acf54d08SAnthony Wilson G_REQUESTED_STATE=$INTERFACE.HostState.Running 281acf54d08SAnthony Wilson G_QUERY="hoststate" 2823ae0a354SAnthony Wilson set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE 2833ae0a354SAnthony Wilson ;; 28479f697e0SAnthony Wilson bmcstate) 28579f697e0SAnthony Wilson OBJECT=$STATE_OBJECT/bmc0 28679f697e0SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 28779f697e0SAnthony Wilson INTERFACE=$STATE_INTERFACE.BMC 28879f697e0SAnthony Wilson PROPERTY=CurrentBMCState 28979f697e0SAnthony Wilson state_query $SERVICE $OBJECT $INTERFACE $PROPERTY 29079f697e0SAnthony Wilson ;; 29179f697e0SAnthony Wilson chassisstate) 29279f697e0SAnthony Wilson OBJECT=$STATE_OBJECT/chassis0 29379f697e0SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 29479f697e0SAnthony Wilson INTERFACE=$STATE_INTERFACE.Chassis 29579f697e0SAnthony Wilson PROPERTY=CurrentPowerState 29679f697e0SAnthony Wilson state_query $SERVICE $OBJECT $INTERFACE $PROPERTY 29779f697e0SAnthony Wilson ;; 29879f697e0SAnthony Wilson hoststate) 29979f697e0SAnthony Wilson OBJECT=$STATE_OBJECT/host0 30079f697e0SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 30179f697e0SAnthony Wilson INTERFACE=$STATE_INTERFACE.Host 30279f697e0SAnthony Wilson PROPERTY=CurrentHostState 30379f697e0SAnthony Wilson state_query $SERVICE $OBJECT $INTERFACE $PROPERTY 30479f697e0SAnthony Wilson ;; 30586cffd9cSAlexander Filippov osstate) 30686cffd9cSAlexander Filippov OBJECT=$STATE_OBJECT/host0 30786cffd9cSAlexander Filippov SERVICE=$(mapper get-service $OBJECT) 30886cffd9cSAlexander Filippov INTERFACE=$STATE_INTERFACE.OperatingSystem.Status 30986cffd9cSAlexander Filippov PROPERTY=OperatingSystemState 31086cffd9cSAlexander Filippov state_query $SERVICE $OBJECT $INTERFACE $PROPERTY 31186cffd9cSAlexander Filippov ;; 31279f697e0SAnthony Wilson state|status) 31386cffd9cSAlexander Filippov for query in bmcstate chassisstate hoststate bootprogress osstate 31479f697e0SAnthony Wilson do 31579f697e0SAnthony Wilson handle_cmd $query 31679f697e0SAnthony Wilson done 317*deb6bb45SAndrew Geissler check_and_warn_boot_block 31879f697e0SAnthony Wilson ;; 31950c5f88dSAnthony Wilson bootprogress) 32050c5f88dSAnthony Wilson OBJECT=$STATE_OBJECT/host0 32150c5f88dSAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 32250c5f88dSAnthony Wilson INTERFACE=$STATE_INTERFACE.Boot.Progress 32350c5f88dSAnthony Wilson PROPERTY=BootProgress 32450c5f88dSAnthony Wilson state_query $SERVICE $OBJECT $INTERFACE $PROPERTY 32550c5f88dSAnthony Wilson ;; 3260f35983dSAnthony Wilson power) 3270f35983dSAnthony Wilson OBJECT=/org/openbmc/control/power0 3280f35983dSAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 3290f35983dSAnthony Wilson INTERFACE=org.openbmc.control.Power 3300f35983dSAnthony Wilson for property in pgood state pgood_timeout 3310f35983dSAnthony Wilson do 3320f35983dSAnthony Wilson # get_property can potentially return several 3330f35983dSAnthony Wilson # different formats of values, so we do the parsing outside 3340f35983dSAnthony Wilson # of get_property depending on the query. These queries 3350f35983dSAnthony Wilson # return 'i VALUE' formatted strings. 3360f35983dSAnthony Wilson STATE=$(get_property $SERVICE $OBJECT $INTERFACE $property \ 3370f35983dSAnthony Wilson | sed 's/i[ ^I]*//') 3380f35983dSAnthony Wilson printf "%s = %s\n" $property $STATE 3390f35983dSAnthony Wilson done 3400f35983dSAnthony Wilson ;; 341189cf248SAnthony Wilson chassiskill) 342189cf248SAnthony Wilson /usr/libexec/chassiskill 343189cf248SAnthony Wilson ;; 344a65d30d1SVishwanatha Subbanna hostrebootoff) 3456d3a2c54SVishwanatha Subbanna OBJECT=$CONTROL_OBJECT/host0/auto_reboot 3466d3a2c54SVishwanatha Subbanna SERVICE=$(mapper get-service $OBJECT) 3476d3a2c54SVishwanatha Subbanna INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy 3486d3a2c54SVishwanatha Subbanna PROPERTY=AutoReboot 3496d3a2c54SVishwanatha Subbanna VALUE=false 3506d3a2c54SVishwanatha Subbanna set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "b" $VALUE 3516d3a2c54SVishwanatha Subbanna ;; 352a65d30d1SVishwanatha Subbanna hostrebooton) 3536d3a2c54SVishwanatha Subbanna OBJECT=$CONTROL_OBJECT/host0/auto_reboot 3546d3a2c54SVishwanatha Subbanna SERVICE=$(mapper get-service $OBJECT) 3556d3a2c54SVishwanatha Subbanna INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy 3566d3a2c54SVishwanatha Subbanna PROPERTY=AutoReboot 3576d3a2c54SVishwanatha Subbanna VALUE=true 3586d3a2c54SVishwanatha Subbanna set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "b" $VALUE 3596d3a2c54SVishwanatha Subbanna ;; 360a65d30d1SVishwanatha Subbanna bmcrebootoff) 361a65d30d1SVishwanatha Subbanna disable_bmc_reboot 362a65d30d1SVishwanatha Subbanna ;; 363a65d30d1SVishwanatha Subbanna bmcrebooton) 364a65d30d1SVishwanatha Subbanna enable_bmc_reboot 365a65d30d1SVishwanatha Subbanna ;; 3667a787dd7SVishwanatha Subbanna recoveryoff) 367a65d30d1SVishwanatha Subbanna handle_cmd hostrebootoff 368a65d30d1SVishwanatha Subbanna handle_cmd bmcrebootoff 3697a787dd7SVishwanatha Subbanna mask_systemd_target $HOST_TIMEOUT_TARGET 37084b3b29eSVishwanatha Subbanna mask_systemd_target $HOST_CRASH_TARGET 3717a787dd7SVishwanatha Subbanna ;; 3727a787dd7SVishwanatha Subbanna recoveryon) 373a65d30d1SVishwanatha Subbanna handle_cmd hostrebooton 374a65d30d1SVishwanatha Subbanna handle_cmd bmcrebooton 3757a787dd7SVishwanatha Subbanna unmask_systemd_target $HOST_TIMEOUT_TARGET 37684b3b29eSVishwanatha Subbanna unmask_systemd_target $HOST_CRASH_TARGET 3777a787dd7SVishwanatha Subbanna ;; 3783b7b5619SAndrew Geissler listbootblock) 3793b7b5619SAndrew Geissler blockingErrors=$(check_boot_block_errors) 3803b7b5619SAndrew Geissler if [ -z "$blockingErrors" ]; then 3813b7b5619SAndrew Geissler echo "No blocking errors present" 3823b7b5619SAndrew Geissler else 3833b7b5619SAndrew Geissler echo "$blockingErrors" 3843b7b5619SAndrew Geissler fi 3853b7b5619SAndrew Geissler ;; 38679f697e0SAnthony Wilson *) 387ea87db40SAnthony Wilson print_usage_err "Invalid command '$1'" 38879f697e0SAnthony Wilson ;; 38979f697e0SAnthony Wilson esac 39079f697e0SAnthony Wilson} 39179f697e0SAnthony Wilson 392ea87db40SAnthony Wilsonfor arg in "$@"; do 393ea87db40SAnthony Wilson case $arg in 394acf54d08SAnthony Wilson -w|--wait) 395acf54d08SAnthony Wilson G_WAIT=30 396acf54d08SAnthony Wilson continue 397acf54d08SAnthony Wilson ;; 398ea87db40SAnthony Wilson -h|--help) 399ea87db40SAnthony Wilson print_help 400ea87db40SAnthony Wilson ;; 40160c3ac8cSAndrew Jeffery -v|--verbose) 40260c3ac8cSAndrew Jeffery G_VERBOSE=y 40360c3ac8cSAndrew Jeffery ;; 404ea87db40SAnthony Wilson -*) 405ea87db40SAnthony Wilson print_usage_err "Unknown option: $arg" 406ea87db40SAnthony Wilson ;; 407ea87db40SAnthony Wilson *) 408acf54d08SAnthony Wilson G_ORIG_CMD=$arg 409ea87db40SAnthony Wilson handle_cmd $arg 410ea87db40SAnthony Wilson break 411ea87db40SAnthony Wilson ;; 412ea87db40SAnthony Wilson esac 413ea87db40SAnthony Wilsondone 414