From dde1fede1f832f029742a1d27290cfe252ab1bc5 Mon Sep 17 00:00:00 2001 From: "Thang Q. Nguyen" Date: Thu, 4 Nov 2021 08:30:27 +0000 Subject: meta-ampere: fix shellcheck issues Fix all issues from the shellcheck checked on bash shells under meta-ampere. Tested: Verify the following features: 1. Power control (on,off, cycle, graceful shutdown, hard reset). 2. UART switching. 3. UEFI firmware update. Signed-off-by: Thang Q. Nguyen Change-Id: Idabf839b7521ecadb642230cc8bb3472c787002e --- .../phosphor-software-manager/firmware_update.sh | 37 ++++++++++------------ 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh') diff --git a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh index af3e2bead..cc39f30fc 100755 --- a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh +++ b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh @@ -21,31 +21,29 @@ usage () { echo "Usage:" - echo " $(basename $0) " + echo " $(basename "$0") " echo "Where:" echo " : the path link to folder, which include image file and MANIFEST" echo "Example:" - echo " $(basename $0) /tmp/images/ghdh1393" + echo " $(basename "$0") /tmp/images/ghdh1393" } IMG_PATH="$1" -if [ ! -d $IMG_PATH ]; then - echo $IMG_PATH +if [ ! -d "$IMG_PATH" ]; then echo "The folder $IMG_PATH does not exist" usage exit 1 fi MANIFEST_PATH="${IMG_PATH}/MANIFEST" -if [ ! -f $MANIFEST_PATH ]; then - echo $MANIFEST_PATH +if [ ! -f "$MANIFEST_PATH" ]; then echo "The MANIFEST file $MANIFEST_PATH does not exist" usage exit 1 fi -EXTENDED_VERSION=$(awk '/ExtendedVersion/ {print}' ${MANIFEST_PATH} | cut -d "=" -f 2) +EXTENDED_VERSION=$(awk '/ExtendedVersion/ {print}' "${MANIFEST_PATH}" | cut -d "=" -f 2) # If the ExtendedVersion is empty, set default to update UEFI/EDKII on primary device if [ -z "$EXTENDED_VERSION" ] @@ -56,28 +54,28 @@ fi # Assign the command based on the ExtendedVersion case ${EXTENDED_VERSION} in "primary") - export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \)) - export CMD='/usr/sbin/ampere_flash_bios.sh $IMAGE 1' + IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \)) + CMD="/usr/sbin/ampere_flash_bios.sh $IMAGE 1" ;; "secondary") - export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \)) - export CMD='/usr/sbin/ampere_flash_bios.sh $IMAGE 2' + IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \)) + CMD="/usr/sbin/ampere_flash_bios.sh $IMAGE 2" ;; "scp-primary") - export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \)) - export CMD='/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 1' + IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \)) + CMD="/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 1" ;; "scp-secondary") - export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \)) - export CMD='/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 2' + IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \)) + CMD="/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 2" ;; "fru") - export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.bin" \)) - export CMD='/usr/sbin/ampere_firmware_upgrade.sh fru $IMAGE' + IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.bin" \)) + CMD="/usr/sbin/ampere_firmware_upgrade.sh fru $IMAGE" ;; *) @@ -91,11 +89,10 @@ if [ -z "$IMAGE" ] then echo "ERROR: The image file: No such file or directory" exit 1 -else - eval $CMD fi -if [[ $? -ne 0 ]]; then +if ! eval "$CMD"; +then echo "ERROR: The firmware update not successfull" exit 1 fi -- cgit v1.2.3