diff options
4 files changed, 66 insertions, 68 deletions
diff --git a/meta-facebook/recipes-fb/fb-powerctrl/files/power-util b/meta-facebook/recipes-fb/fb-powerctrl/files/power-util index 30fa34cc8..d00dfde7f 100755 --- a/meta-facebook/recipes-fb/fb-powerctrl/files/power-util +++ b/meta-facebook/recipes-fb/fb-powerctrl/files/power-util @@ -1,83 +1,83 @@ #!/bin/bash # Usage of this utility function usage() { - echo "usage: power-util mb [on|off|status|cycle|reset]"; - echo " power-util sled-cycle" + echo "usage: power-util mb [on|off|status|cycle|reset]"; + echo " power-util sled-cycle" } power_off() { - echo "Shutting down Server $2" - busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.Off + echo "Shutting down Server" + busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.Off } power_on() { - echo "Powering on Server $2" - busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.On + echo "Powering on Server" + busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.On } power_status() { - st=$(busctl get-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis CurrentPowerState | cut -d"." -f6) - if [ "$st" == "On\"" ]; then - echo "on" - else - echo "off" - fi + st=$(busctl get-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis CurrentPowerState | cut -d"." -f6) + if [ "$st" == "On\"" ]; then + echo "on" + else + echo "off" + fi } power_reset() { - echo "Reset on server $2" - busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.Reset + echo "Reset on server" + busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.Reset } sled_cycle() { - i2cset -y 7 0x45 0xd9 c + i2cset -y 7 0x45 0xd9 c } -if [ $1 == "sled-cycle" ]; then - echo "SLED_CYCLE starting at $(date)" - sled_cycle - exit 0; +if [ "$1" == "sled-cycle" ]; then + echo "SLED_CYCLE starting at $(date)" + sled_cycle + exit 0; fi if [ $# -lt 2 ]; then - echo "Total number of parameter=$#" - echo "Insufficient parameter" - usage; - exit 0; + echo "Total number of parameter=$#" + echo "Insufficient parameter" + usage; + exit 0; fi -if [ $1 != "mb" ]; then - echo "Invalid parameter1=$1" - usage; - exit 0; +if [ "$1" != "mb" ]; then + echo "Invalid parameter1=$1" + usage; + exit 0; fi -if [ $2 = "on" ]; then - if [ $(power_status) == "off" ]; then - power_on +if [ "$2" = "on" ]; then + if [ "$(power_status)" == "off" ]; then + power_on fi -elif [ $2 = "off" ]; then - if [ $(power_status) == "on" ]; then - power_off +elif [ "$2" = "off" ]; then + if [ "$(power_status)" == "on" ]; then + power_off fi -elif [ $2 == "cycle" ]; then - if [ $(power_status) == "on" ]; then - power_off +elif [ "$2" == "cycle" ]; then + if [ "$(power_status)" == "on" ]; then + power_off else echo "WARNING: Powering on server" fi - power_on -elif [ $2 == "reset" ]; then - if [ $(power_status) == "on" ]; then - power_reset + power_on +elif [ "$2" == "reset" ]; then + if [ "$(power_status)" == "on" ]; then + power_reset else echo "ERROR: Server not powered on" fi -elif [ $2 == "status" ]; then - power_status +elif [ "$2" == "status" ]; then + power_status else - echo "Invalid parameter2=$2" - usage; + echo "Invalid parameter2=$2" + usage; fi exit 0; diff --git a/meta-facebook/recipes-fb/fb-powerctrl/files/setup_gpio.sh b/meta-facebook/recipes-fb/fb-powerctrl/files/setup_gpio.sh index 2624abd0d..cac3b20c7 100755 --- a/meta-facebook/recipes-fb/fb-powerctrl/files/setup_gpio.sh +++ b/meta-facebook/recipes-fb/fb-powerctrl/files/setup_gpio.sh @@ -7,16 +7,16 @@ function set_gpio_active_low() { return; fi - echo $1 > /sys/class/gpio/export - echo $2 > /sys/class/gpio/gpio$1/direction + echo "$1" > /sys/class/gpio/export + echo "$2" > "/sys/class/gpio/gpio$1/direction" } GPIO_BASE=$(cat /sys/class/gpio/gpio*/base) # FM_BMC_READY_N, GPIO S1, active low -set_gpio_active_low $((${GPIO_BASE} + 144 +1)) low +set_gpio_active_low $((GPIO_BASE + 144 +1)) low # FP_PECI_MUX, active low -set_gpio_active_low $((${GPIO_BASE} + 212)) high +set_gpio_active_low $((GPIO_BASE + 212)) high exit 0; diff --git a/meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh b/meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh index fd1c52b2a..4b99f0be4 100755 --- a/meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh +++ b/meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh @@ -20,16 +20,16 @@ set_gpio_to_bmc() echo "switch bios GPIO to bmc" if [ ! -d /sys/class/gpio/gpio$GPIO ]; then cd /sys/class/gpio - echo $GPIO > export + echo $GPIO > "export" cd gpio$GPIO else cd /sys/class/gpio/gpio$GPIO fi - direc=`cat direction` - if [ $direc == "in" ]; then + direc=$(cat direction) + if [ "$direc" == "in" ]; then echo "out" > direction fi - data=`cat value` + data=$(cat value) if [ "$data" == "0" ]; then echo 1 > value fi @@ -41,16 +41,16 @@ set_gpio_to_pch() echo "switch bios GPIO to pch" if [ ! -d /sys/class/gpio/gpio$GPIO ]; then cd /sys/class/gpio - echo $GPIO > export + echo $GPIO > "export" cd gpio$GPIO else cd /sys/class/gpio/gpio$GPIO fi - direc=`cat direction` - if [ $direc == "in" ]; then + direc=$(cat direction) + if [ "$direc" == "in" ]; then echo "out" > direction fi - data=`cat value` + data=$(cat value) if [ "$data" == "1" ]; then echo 0 > value fi @@ -65,17 +65,18 @@ echo "Bios upgrade started at $(date)" echo "Power off host server" $POWER_CMD off sleep 15 -if [ $($POWER_CMD status) != "off" ]; +if [ "$($POWER_CMD status)" != "off" ]; then echo "Host server didn't power off" echo "Bios upgrade failed" - exit -1 + exit 1 fi echo "Host server powered off" #Set ME to recovery mode echo "Set ME to recovery mode" -busctl call $IPMB_OBJ $IPMB_PATH $IPMB_INTF $IPMB_CALL $ME_CMD_RECOVER +# shellcheck disable=SC2086 +busctl call "$IPMB_OBJ" "$IPMB_PATH" "$IPMB_INTF" $IPMB_CALL $ME_CMD_RECOVER sleep 5 #Flip GPIO to access SPI flash used by host. @@ -93,11 +94,10 @@ then echo "Bios image is $IMAGE_FILE" for d in mtd6 mtd7 ; do if [ -e "/dev/$d" ]; then - mtd=`cat /sys/class/mtd/$d/name` - if [ $mtd == "pnor" ]; then + mtd=$(cat /sys/class/mtd/$d/name) + if [ "$mtd" == "pnor" ]; then echo "Flashing bios image to $d..." - flashcp -v $IMAGE_FILE /dev/$d - if [ $? -eq 0 ]; then + if flashcp -v "$IMAGE_FILE" /dev/$d; then echo "bios updated successfully..." else echo "bios update failed..." @@ -125,7 +125,8 @@ sleep 5 #Reset ME to boot from new bios echo "Reset ME to boot from new bios" -busctl call $IPMB_OBJ $IPMB_PATH $IPMB_INTF $IPMB_CALL $ME_CMD_RESET +# shellcheck disable=SC2086 +busctl call "$IPMB_OBJ" "$IPMB_PATH" "$IPMB_INTF" $IPMB_CALL $ME_CMD_RESET sleep 10 #Power on server @@ -134,7 +135,7 @@ $POWER_CMD on sleep 5 # Retry to power on once again if server didn't powered on -if [ $($POWER_CMD status) != "on" ]; +if [ "$($POWER_CMD status)" != "on" ]; then sleep 5 echo "Powering on server again" diff --git a/meta-phosphor/scripts/run-repotest b/meta-phosphor/scripts/run-repotest index c841b6528..b9802a3ad 100755 --- a/meta-phosphor/scripts/run-repotest +++ b/meta-phosphor/scripts/run-repotest @@ -96,9 +96,6 @@ meta-ampere/meta-jade/recipes-phosphor/gpio/id-button/toggle_identify_led.sh meta-ampere/meta-jade/recipes-phosphor/gpio/psu-hotswap-reset/ampere_psu_reset_hotswap.sh meta-bytedance/meta-g220a/recipes-network/network/static-mac-addr/mac-check meta-bytedance/meta-g220a/recipes-phosphor/datetime/me-time-sync/me-time-sync.sh -meta-facebook/recipes-fb/fb-powerctrl/files/power-util -meta-facebook/recipes-fb/fb-powerctrl/files/setup_gpio.sh -meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh |