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,\ 7*d8c63204SAndrew Geisslerbmcrebootoff, bmcrebooton, listbootblock listlogs showlog" 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 "" 66295ee4fbSAndrew Geissler echo "obmcutil listlogs List all phosphor-logging entries on the" 67295ee4fbSAndrew Geissler echo " system" 68295ee4fbSAndrew Geissler echo "" 69*d8c63204SAndrew Geissler echo "obmcutil showlog <log> Display details of input log. Format of <log>" 70*d8c63204SAndrew Geissler echo " should match listlogs output" 71*d8c63204SAndrew Geissler echo "" 72f3f16fa9SAnthony Wilson echo "optional arguments:" 73f3f16fa9SAnthony Wilson echo " -h, --help show this help message and exit" 74acf54d08SAnthony Wilson echo " -w, --wait block until state transition succeeds or fails" 7560c3ac8cSAndrew Jeffery echo " -v, --verbose print the journal to stdout if --wait is supplied" 76f3f16fa9SAnthony Wilson exit 0 77f3f16fa9SAnthony Wilson} 78f3f16fa9SAnthony Wilson 79acf54d08SAnthony Wilsonrun_timeout () 80acf54d08SAnthony Wilson{ 81acf54d08SAnthony Wilson local timeout="$1"; shift 82acf54d08SAnthony Wilson local cmd="$@" 8360c3ac8cSAndrew Jeffery local verbose_child= 8460c3ac8cSAndrew Jeffery 852869a926SAndrew Jeffery if [ -n "$G_VERBOSE" ]; then 8660c3ac8cSAndrew Jeffery journalctl -f & 8760c3ac8cSAndrew Jeffery verbose_child=$! 8860c3ac8cSAndrew Jeffery fi 89acf54d08SAnthony Wilson 90acf54d08SAnthony Wilson $cmd 91acf54d08SAnthony Wilson 92acf54d08SAnthony Wilson # Run a background query for the transition to the expected state 93acf54d08SAnthony Wilson # This will be killed if the transition doesn't succeed within 94acf54d08SAnthony Wilson # a timeout period. 95acf54d08SAnthony Wilson ( 96acf54d08SAnthony Wilson while ! grep -q $G_REQUESTED_STATE <<< $(handle_cmd $G_QUERY) ; do 97acf54d08SAnthony Wilson sleep 1 98acf54d08SAnthony Wilson done 99acf54d08SAnthony Wilson ) & 10060c3ac8cSAndrew Jeffery wait_child=$! 101acf54d08SAnthony Wilson 102acf54d08SAnthony Wilson # Could be bad if process is killed before 'timeout' occurs if 103acf54d08SAnthony Wilson # transition doesn't succeed. 104acf54d08SAnthony Wilson trap -- "" SIGTERM 105acf54d08SAnthony Wilson 106acf54d08SAnthony Wilson # Workaround for lack of 'timeout' command. 107acf54d08SAnthony Wilson ( 108acf54d08SAnthony Wilson sleep $timeout 10960c3ac8cSAndrew Jeffery kill $wait_child 110acf54d08SAnthony Wilson ) > /dev/null 2>&1 & 111acf54d08SAnthony Wilson 11260c3ac8cSAndrew Jeffery if ! wait $wait_child; then 113acf54d08SAnthony Wilson echo "Unable to confirm '$G_ORIG_CMD' success" \ 114acf54d08SAnthony Wilson "within timeout period (${timeout}s)" 115acf54d08SAnthony Wilson fi 11660c3ac8cSAndrew Jeffery 1178be70293SAndrew Jeffery if [ -n "$verbose_child" ]; then 11860c3ac8cSAndrew Jeffery kill $verbose_child 11960c3ac8cSAndrew Jeffery fi 120acf54d08SAnthony Wilson} 121acf54d08SAnthony Wilson 122acf54d08SAnthony Wilsonrun_cmd () 123acf54d08SAnthony Wilson{ 124acf54d08SAnthony Wilson local cmd="$@"; 125acf54d08SAnthony Wilson 126acf54d08SAnthony Wilson if [ -n "$G_WAIT" ]; then 127acf54d08SAnthony Wilson run_timeout $G_WAIT "$cmd" 128acf54d08SAnthony Wilson else 129acf54d08SAnthony Wilson $cmd 130acf54d08SAnthony Wilson fi 131acf54d08SAnthony Wilson} 132acf54d08SAnthony Wilson 1333ae0a354SAnthony Wilsonset_property () 1343ae0a354SAnthony Wilson{ 135acf54d08SAnthony Wilson run_cmd busctl set-property "$@" 1363ae0a354SAnthony Wilson} 1373ae0a354SAnthony Wilson 13879f697e0SAnthony Wilsonget_property () 13979f697e0SAnthony Wilson{ 140acf54d08SAnthony Wilson G_WAIT="" 141acf54d08SAnthony Wilson run_cmd busctl get-property "$@" 14279f697e0SAnthony Wilson} 14379f697e0SAnthony Wilson 14479f697e0SAnthony Wilsonstate_query () 14579f697e0SAnthony Wilson{ 14679f697e0SAnthony Wilson local state=$(get_property "$@" | cut -d '"' -f2) 14779f697e0SAnthony Wilson printf "%-20s: %s\n" $4 $state 14879f697e0SAnthony Wilson} 14979f697e0SAnthony Wilson 150ea87db40SAnthony Wilsonprint_usage_err () 151ea87db40SAnthony Wilson{ 152ea87db40SAnthony Wilson echo "ERROR: $1" >&2 153ea87db40SAnthony Wilson echo "$USAGE" 154ea87db40SAnthony Wilson exit 1 155ea87db40SAnthony Wilson} 156ea87db40SAnthony Wilson 1577a787dd7SVishwanatha Subbannamask_systemd_target () 1587a787dd7SVishwanatha Subbanna{ 1597a787dd7SVishwanatha Subbanna target="$@" 1607a787dd7SVishwanatha Subbanna systemctl mask $target 1617a787dd7SVishwanatha Subbanna} 1627a787dd7SVishwanatha Subbanna 1637a787dd7SVishwanatha Subbannaunmask_systemd_target () 1647a787dd7SVishwanatha Subbanna{ 1657a787dd7SVishwanatha Subbanna target="$@" 1667a787dd7SVishwanatha Subbanna systemctl unmask $target 1677a787dd7SVishwanatha Subbanna} 1687a787dd7SVishwanatha Subbanna 169a65d30d1SVishwanatha Subbannadisable_bmc_reboot () 170a65d30d1SVishwanatha Subbanna{ 171a65d30d1SVishwanatha Subbanna dir="/run/systemd/system/" 172a65d30d1SVishwanatha Subbanna file="reboot-guard.conf" 173a65d30d1SVishwanatha Subbanna units=("reboot" "poweroff" "halt") 174a65d30d1SVishwanatha Subbanna 175a65d30d1SVishwanatha Subbanna for unit in "${units[@]}"; do 176a65d30d1SVishwanatha Subbanna mkdir -p ${dir}${unit}.target.d 177a65d30d1SVishwanatha Subbanna echo -e "[Unit]\nRefuseManualStart=yes" >> ${dir}${unit}.target.d/${file} 178a65d30d1SVishwanatha Subbanna done 179a65d30d1SVishwanatha Subbanna} 180a65d30d1SVishwanatha Subbanna 181a65d30d1SVishwanatha Subbannaenable_bmc_reboot () 182a65d30d1SVishwanatha Subbanna{ 183a65d30d1SVishwanatha Subbanna dir="/run/systemd/system/" 184a65d30d1SVishwanatha Subbanna file="reboot-guard.conf" 185a65d30d1SVishwanatha Subbanna units=("reboot" "poweroff" "halt") 186a65d30d1SVishwanatha Subbanna 187a65d30d1SVishwanatha Subbanna for unit in "${units[@]}"; do 188a65d30d1SVishwanatha Subbanna rm -rf ${dir}${unit}.target.d/${file} 189a65d30d1SVishwanatha Subbanna rm -rf ${dir}${unit}.target.d 190a65d30d1SVishwanatha Subbanna done 191a65d30d1SVishwanatha Subbanna} 192a65d30d1SVishwanatha Subbanna 1933b7b5619SAndrew Geissler# will write blocking errors to stdout 1943b7b5619SAndrew Geisslercheck_boot_block_errors () 1953b7b5619SAndrew Geissler{ 1963b7b5619SAndrew Geissler # array of boot block objects 1973b7b5619SAndrew Geissler blockArray=() 1983b7b5619SAndrew Geissler 1993b7b5619SAndrew Geissler # Look for any objects under logging that implement the 2003b7b5619SAndrew Geissler # xyz.openbmc_project.Logging.ErrorBlocksTransition 2013b7b5619SAndrew Geissler subtree="$(busctl call xyz.openbmc_project.ObjectMapper \ 2023b7b5619SAndrew Geissler /xyz/openbmc_project/object_mapper \ 2033b7b5619SAndrew Geissler xyz.openbmc_project.ObjectMapper \ 2043b7b5619SAndrew Geissler GetSubTree sias "/xyz/openbmc_project/logging/" 0 1 \ 2053b7b5619SAndrew Geissler xyz.openbmc_project.Logging.ErrorBlocksTransition)" 2063b7b5619SAndrew Geissler 2073b7b5619SAndrew Geissler # remove quotation marks 2083b7b5619SAndrew Geissler subtree="$(echo $subtree | sed 's/\"//g')" 2093b7b5619SAndrew Geissler 2103b7b5619SAndrew Geissler for entry in $subtree; do 2113b7b5619SAndrew Geissler if [[ ${entry} =~ "xyz/openbmc_project/logging/block"* ]]; then 2123b7b5619SAndrew Geissler blockArray+=( $entry ) 2133b7b5619SAndrew Geissler fi 2143b7b5619SAndrew Geissler done 2153b7b5619SAndrew Geissler 2163b7b5619SAndrew Geissler # now find associated error log for each boot block error 2173b7b5619SAndrew Geissler for berror in "${blockArray[@]}"; do 2183b7b5619SAndrew Geissler assocs="$(busctl call xyz.openbmc_project.Logging $berror \ 2193b7b5619SAndrew Geissler org.freedesktop.DBus.Properties Get \ 2203b7b5619SAndrew Geissler ss xyz.openbmc_project.Association.Definitions Associations)" 2213b7b5619SAndrew Geissler 2223b7b5619SAndrew Geissler # remove quotation marks 2233b7b5619SAndrew Geissler assocs="$(echo $assocs | sed 's/\"//g')" 2243b7b5619SAndrew Geissler 2253b7b5619SAndrew Geissler for entry in $assocs; do 2263b7b5619SAndrew Geissler if [[ ${entry} =~ "xyz/openbmc_project/logging/entry"* ]]; then 2273b7b5619SAndrew Geissler echo "Blocking Error: $entry" 2283b7b5619SAndrew Geissler fi 2293b7b5619SAndrew Geissler done 2303b7b5619SAndrew Geissler done 2313b7b5619SAndrew Geissler} 2323b7b5619SAndrew Geissler 233deb6bb45SAndrew Geissler# helper function to check for boot block errors and notify user 234deb6bb45SAndrew Geisslercheck_and_warn_boot_block() 235deb6bb45SAndrew Geissler{ 236deb6bb45SAndrew Geissler blockingErrors=$(check_boot_block_errors) 237deb6bb45SAndrew Geissler if ! [ -z "$blockingErrors" ]; then 238deb6bb45SAndrew Geissler echo !!!!!!!!!! 239deb6bb45SAndrew Geissler echo "WARNING! System has blocking errors that will prevent boot" 240deb6bb45SAndrew Geissler echo "$blockingErrors" 241deb6bb45SAndrew Geissler echo !!!!!!!!!! 242deb6bb45SAndrew Geissler fi 243deb6bb45SAndrew Geissler} 244deb6bb45SAndrew Geissler 245295ee4fbSAndrew Geissler# list all phosphor-logging entries 246295ee4fbSAndrew Geisslerlist_logs() 247295ee4fbSAndrew Geissler{ 248295ee4fbSAndrew Geissler # Look for any objects under logging that implement the 249295ee4fbSAndrew Geissler # xyz.openbmc_project.Logging.Entry 250295ee4fbSAndrew Geissler busctl -j call xyz.openbmc_project.ObjectMapper \ 251295ee4fbSAndrew Geissler /xyz/openbmc_project/object_mapper \ 252295ee4fbSAndrew Geissler xyz.openbmc_project.ObjectMapper \ 253295ee4fbSAndrew Geissler GetSubTreePaths sias "/xyz/openbmc_project/logging/" 0 1 \ 254295ee4fbSAndrew Geissler xyz.openbmc_project.Logging.Entry 255295ee4fbSAndrew Geissler} 256295ee4fbSAndrew Geissler 257*d8c63204SAndrew Geissler# display input log details 258*d8c63204SAndrew Geisslershow_log() 259*d8c63204SAndrew Geissler{ 260*d8c63204SAndrew Geissler busctl -j call xyz.openbmc_project.Logging \ 261*d8c63204SAndrew Geissler $1 \ 262*d8c63204SAndrew Geissler org.freedesktop.DBus.Properties \ 263*d8c63204SAndrew Geissler GetAll s xyz.openbmc_project.Logging.Entry 264*d8c63204SAndrew Geissler} 265*d8c63204SAndrew Geissler 26679f697e0SAnthony Wilsonhandle_cmd () 26779f697e0SAnthony Wilson{ 26879f697e0SAnthony Wilson case "$1" in 2693ae0a354SAnthony Wilson chassisoff) 2703ae0a354SAnthony Wilson OBJECT=$STATE_OBJECT/chassis0 2713ae0a354SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 2723ae0a354SAnthony Wilson INTERFACE=$STATE_INTERFACE.Chassis 2733ae0a354SAnthony Wilson PROPERTY=RequestedPowerTransition 2743ae0a354SAnthony Wilson VALUE=$INTERFACE.Transition.Off 275acf54d08SAnthony Wilson G_REQUESTED_STATE=$INTERFACE.PowerState.Off 276acf54d08SAnthony Wilson G_QUERY="chassisstate" 2773ae0a354SAnthony Wilson set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE 2783ae0a354SAnthony Wilson ;; 2793ae0a354SAnthony Wilson chassison) 280deb6bb45SAndrew Geissler check_and_warn_boot_block 2813ae0a354SAnthony Wilson OBJECT=$STATE_OBJECT/chassis0 2823ae0a354SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 2833ae0a354SAnthony Wilson INTERFACE=$STATE_INTERFACE.Chassis 2843ae0a354SAnthony Wilson PROPERTY=RequestedPowerTransition 2853ae0a354SAnthony Wilson VALUE=$INTERFACE.Transition.On 286acf54d08SAnthony Wilson G_REQUESTED_STATE=$INTERFACE.PowerState.On 287acf54d08SAnthony Wilson G_QUERY="chassisstate" 2883ae0a354SAnthony Wilson set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE 2893ae0a354SAnthony Wilson ;; 2903ae0a354SAnthony Wilson poweroff) 2913ae0a354SAnthony Wilson OBJECT=$STATE_OBJECT/host0 2923ae0a354SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 2933ae0a354SAnthony Wilson INTERFACE=$STATE_INTERFACE.Host 2943ae0a354SAnthony Wilson PROPERTY=RequestedHostTransition 2953ae0a354SAnthony Wilson VALUE=$INTERFACE.Transition.Off 296acf54d08SAnthony Wilson G_REQUESTED_STATE=$INTERFACE.HostState.Off 297acf54d08SAnthony Wilson G_QUERY="hoststate" 2983ae0a354SAnthony Wilson set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE 2993ae0a354SAnthony Wilson ;; 3003ae0a354SAnthony Wilson poweron) 301deb6bb45SAndrew Geissler check_and_warn_boot_block 3023ae0a354SAnthony Wilson OBJECT=$STATE_OBJECT/host0 3033ae0a354SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 3043ae0a354SAnthony Wilson INTERFACE=$STATE_INTERFACE.Host 3053ae0a354SAnthony Wilson PROPERTY=RequestedHostTransition 3063ae0a354SAnthony Wilson VALUE=$INTERFACE.Transition.On 307acf54d08SAnthony Wilson G_REQUESTED_STATE=$INTERFACE.HostState.Running 308acf54d08SAnthony Wilson G_QUERY="hoststate" 3093ae0a354SAnthony Wilson set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "s" $VALUE 3103ae0a354SAnthony Wilson ;; 31179f697e0SAnthony Wilson bmcstate) 31279f697e0SAnthony Wilson OBJECT=$STATE_OBJECT/bmc0 31379f697e0SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 31479f697e0SAnthony Wilson INTERFACE=$STATE_INTERFACE.BMC 31579f697e0SAnthony Wilson PROPERTY=CurrentBMCState 31679f697e0SAnthony Wilson state_query $SERVICE $OBJECT $INTERFACE $PROPERTY 31779f697e0SAnthony Wilson ;; 31879f697e0SAnthony Wilson chassisstate) 31979f697e0SAnthony Wilson OBJECT=$STATE_OBJECT/chassis0 32079f697e0SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 32179f697e0SAnthony Wilson INTERFACE=$STATE_INTERFACE.Chassis 32279f697e0SAnthony Wilson PROPERTY=CurrentPowerState 32379f697e0SAnthony Wilson state_query $SERVICE $OBJECT $INTERFACE $PROPERTY 32479f697e0SAnthony Wilson ;; 32579f697e0SAnthony Wilson hoststate) 32679f697e0SAnthony Wilson OBJECT=$STATE_OBJECT/host0 32779f697e0SAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 32879f697e0SAnthony Wilson INTERFACE=$STATE_INTERFACE.Host 32979f697e0SAnthony Wilson PROPERTY=CurrentHostState 33079f697e0SAnthony Wilson state_query $SERVICE $OBJECT $INTERFACE $PROPERTY 33179f697e0SAnthony Wilson ;; 33286cffd9cSAlexander Filippov osstate) 33386cffd9cSAlexander Filippov OBJECT=$STATE_OBJECT/host0 33486cffd9cSAlexander Filippov SERVICE=$(mapper get-service $OBJECT) 33586cffd9cSAlexander Filippov INTERFACE=$STATE_INTERFACE.OperatingSystem.Status 33686cffd9cSAlexander Filippov PROPERTY=OperatingSystemState 33786cffd9cSAlexander Filippov state_query $SERVICE $OBJECT $INTERFACE $PROPERTY 33886cffd9cSAlexander Filippov ;; 33979f697e0SAnthony Wilson state|status) 34086cffd9cSAlexander Filippov for query in bmcstate chassisstate hoststate bootprogress osstate 34179f697e0SAnthony Wilson do 34279f697e0SAnthony Wilson handle_cmd $query 34379f697e0SAnthony Wilson done 344deb6bb45SAndrew Geissler check_and_warn_boot_block 34579f697e0SAnthony Wilson ;; 34650c5f88dSAnthony Wilson bootprogress) 34750c5f88dSAnthony Wilson OBJECT=$STATE_OBJECT/host0 34850c5f88dSAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 34950c5f88dSAnthony Wilson INTERFACE=$STATE_INTERFACE.Boot.Progress 35050c5f88dSAnthony Wilson PROPERTY=BootProgress 35150c5f88dSAnthony Wilson state_query $SERVICE $OBJECT $INTERFACE $PROPERTY 35250c5f88dSAnthony Wilson ;; 3530f35983dSAnthony Wilson power) 3540f35983dSAnthony Wilson OBJECT=/org/openbmc/control/power0 3550f35983dSAnthony Wilson SERVICE=$(mapper get-service $OBJECT) 3560f35983dSAnthony Wilson INTERFACE=org.openbmc.control.Power 3570f35983dSAnthony Wilson for property in pgood state pgood_timeout 3580f35983dSAnthony Wilson do 3590f35983dSAnthony Wilson # get_property can potentially return several 3600f35983dSAnthony Wilson # different formats of values, so we do the parsing outside 3610f35983dSAnthony Wilson # of get_property depending on the query. These queries 3620f35983dSAnthony Wilson # return 'i VALUE' formatted strings. 3630f35983dSAnthony Wilson STATE=$(get_property $SERVICE $OBJECT $INTERFACE $property \ 3640f35983dSAnthony Wilson | sed 's/i[ ^I]*//') 3650f35983dSAnthony Wilson printf "%s = %s\n" $property $STATE 3660f35983dSAnthony Wilson done 3670f35983dSAnthony Wilson ;; 368189cf248SAnthony Wilson chassiskill) 369189cf248SAnthony Wilson /usr/libexec/chassiskill 370189cf248SAnthony Wilson ;; 371a65d30d1SVishwanatha Subbanna hostrebootoff) 3726d3a2c54SVishwanatha Subbanna OBJECT=$CONTROL_OBJECT/host0/auto_reboot 3736d3a2c54SVishwanatha Subbanna SERVICE=$(mapper get-service $OBJECT) 3746d3a2c54SVishwanatha Subbanna INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy 3756d3a2c54SVishwanatha Subbanna PROPERTY=AutoReboot 3766d3a2c54SVishwanatha Subbanna VALUE=false 3776d3a2c54SVishwanatha Subbanna set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "b" $VALUE 3786d3a2c54SVishwanatha Subbanna ;; 379a65d30d1SVishwanatha Subbanna hostrebooton) 3806d3a2c54SVishwanatha Subbanna OBJECT=$CONTROL_OBJECT/host0/auto_reboot 3816d3a2c54SVishwanatha Subbanna SERVICE=$(mapper get-service $OBJECT) 3826d3a2c54SVishwanatha Subbanna INTERFACE=$CONTROL_INTERFACE.Boot.RebootPolicy 3836d3a2c54SVishwanatha Subbanna PROPERTY=AutoReboot 3846d3a2c54SVishwanatha Subbanna VALUE=true 3856d3a2c54SVishwanatha Subbanna set_property $SERVICE $OBJECT $INTERFACE $PROPERTY "b" $VALUE 3866d3a2c54SVishwanatha Subbanna ;; 387a65d30d1SVishwanatha Subbanna bmcrebootoff) 388a65d30d1SVishwanatha Subbanna disable_bmc_reboot 389a65d30d1SVishwanatha Subbanna ;; 390a65d30d1SVishwanatha Subbanna bmcrebooton) 391a65d30d1SVishwanatha Subbanna enable_bmc_reboot 392a65d30d1SVishwanatha Subbanna ;; 3937a787dd7SVishwanatha Subbanna recoveryoff) 394a65d30d1SVishwanatha Subbanna handle_cmd hostrebootoff 395a65d30d1SVishwanatha Subbanna handle_cmd bmcrebootoff 3967a787dd7SVishwanatha Subbanna mask_systemd_target $HOST_TIMEOUT_TARGET 39784b3b29eSVishwanatha Subbanna mask_systemd_target $HOST_CRASH_TARGET 3987a787dd7SVishwanatha Subbanna ;; 3997a787dd7SVishwanatha Subbanna recoveryon) 400a65d30d1SVishwanatha Subbanna handle_cmd hostrebooton 401a65d30d1SVishwanatha Subbanna handle_cmd bmcrebooton 4027a787dd7SVishwanatha Subbanna unmask_systemd_target $HOST_TIMEOUT_TARGET 40384b3b29eSVishwanatha Subbanna unmask_systemd_target $HOST_CRASH_TARGET 4047a787dd7SVishwanatha Subbanna ;; 4053b7b5619SAndrew Geissler listbootblock) 4063b7b5619SAndrew Geissler blockingErrors=$(check_boot_block_errors) 4073b7b5619SAndrew Geissler if [ -z "$blockingErrors" ]; then 4083b7b5619SAndrew Geissler echo "No blocking errors present" 4093b7b5619SAndrew Geissler else 4103b7b5619SAndrew Geissler echo "$blockingErrors" 4113b7b5619SAndrew Geissler fi 4123b7b5619SAndrew Geissler ;; 413295ee4fbSAndrew Geissler listlogs) 414295ee4fbSAndrew Geissler list_logs 415295ee4fbSAndrew Geissler ;; 416*d8c63204SAndrew Geissler showlog) 417*d8c63204SAndrew Geissler show_log $2 418*d8c63204SAndrew Geissler ;; 41979f697e0SAnthony Wilson *) 420ea87db40SAnthony Wilson print_usage_err "Invalid command '$1'" 42179f697e0SAnthony Wilson ;; 42279f697e0SAnthony Wilson esac 42379f697e0SAnthony Wilson} 42479f697e0SAnthony Wilson 425ea87db40SAnthony Wilsonfor arg in "$@"; do 426ea87db40SAnthony Wilson case $arg in 427acf54d08SAnthony Wilson -w|--wait) 428acf54d08SAnthony Wilson G_WAIT=30 429acf54d08SAnthony Wilson continue 430acf54d08SAnthony Wilson ;; 431ea87db40SAnthony Wilson -h|--help) 432ea87db40SAnthony Wilson print_help 433ea87db40SAnthony Wilson ;; 43460c3ac8cSAndrew Jeffery -v|--verbose) 43560c3ac8cSAndrew Jeffery G_VERBOSE=y 43660c3ac8cSAndrew Jeffery ;; 437ea87db40SAnthony Wilson -*) 438ea87db40SAnthony Wilson print_usage_err "Unknown option: $arg" 439ea87db40SAnthony Wilson ;; 440ea87db40SAnthony Wilson *) 441acf54d08SAnthony Wilson G_ORIG_CMD=$arg 442*d8c63204SAndrew Geissler # pass all arguments to handle_cmd in case command takes additional 443*d8c63204SAndrew Geissler # parameters 444*d8c63204SAndrew Geissler handle_cmd "$@" 445ea87db40SAnthony Wilson break 446ea87db40SAnthony Wilson ;; 447ea87db40SAnthony Wilson esac 448ea87db40SAnthony Wilsondone 449