From 552e93e6ec8d72befcbe7ea59c3a57968f6603dc Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Wed, 27 Oct 2021 10:15:20 -0500 Subject: meta-facebook: fix shellcheck issues in scripts Signed-off-by: Patrick Williams Change-Id: I62cf17d414795e91d673d468a196d4f0a6c0a71b --- .../flash/phosphor-software-manager/bios-update.sh | 35 +++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'meta-facebook/recipes-phosphor/flash/phosphor-software-manager/bios-update.sh') 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" -- cgit v1.2.3