diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2023-04-14 22:03:05 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2023-04-18 19:00:32 +0300 |
commit | 2345ace954c2db96da60b871735281a1bb4fa374 (patch) | |
tree | 74818716520ddcbd50c5f481116cd3e3b9d9064e /meta-phosphor/recipes-phosphor | |
parent | 5f87057d2a821cdd12f056c904aa150e30e2dc93 (diff) | |
download | openbmc-2345ace954c2db96da60b871735281a1bb4fa374.tar.xz |
meta-phosphor: phosphor-mmc-init: fix shellcheck
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I1f668e1e40c937e016c60af13705ea60936ed739
Diffstat (limited to 'meta-phosphor/recipes-phosphor')
-rw-r--r-- | meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh index 316bffce8a..cc1c0dda5c 100644 --- a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh +++ b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh @@ -2,9 +2,9 @@ # Get the value of the root env variable found in /proc/cmdline get_root() { - local cmdline="$(cat /proc/cmdline)" + _cmdline="$(cat /proc/cmdline)" root= - for opt in $cmdline + for opt in $_cmdline do case $opt in root=PARTLABEL=*) @@ -14,7 +14,7 @@ get_root() { ;; esac done - [ -n "$root" ] && echo $root + [ -n "$root" ] && echo "$root" } fslist="proc sys dev run" @@ -23,7 +23,7 @@ mmcdev="/dev/mmcblk0" rwfsdev="/dev/disk/by-partlabel/rwfs" cd / -mkdir -p $fslist +mkdir -p "$fslist" mount dev dev -tdevtmpfs mount sys sys -tsysfs mount proc proc -tproc @@ -48,7 +48,7 @@ if ! tail -c 512 "${mmcdev}" | hexdump -C -n 8 | grep -q "EFI PART"; then fi # There eMMC GPT labels for the rootfs are rofs-a and rofs-b, and the label for -# the read-write partition is rwfs. Run udev to make the partition labels show +# the read-write partition is rwfs. Run udev to make the partition labels show # up. Mounting by label allows for partition numbers to change if needed. udevd --daemon udevadm trigger --type=devices --action=add @@ -62,25 +62,24 @@ fi # Determine if a factory reset has been requested mkdir -p /var/lock resetval=$(fw_printenv -n rwreset 2>/dev/null) -gpiopresent=$(gpiofind factory-reset-toggle) -if [ $? -eq 0 ]; then - gpioval=$(gpioget $gpiopresent) +if gpiopresent=$(gpiofind factory-reset-toggle) ; then + gpioval=$(gpioget "$gpiopresent") else gpioval="" fi # Prevent unnecessary resets on first boot -if [ -n "$gpioval" -a -z "$resetval" ]; then - fw_setenv rwreset $gpioval +if [ -n "$gpioval" ] && [ -z "$resetval" ]; then + fw_setenv rwreset "$gpioval" resetval=$gpioval fi -if [ "$resetval" = "true" -o -n "$gpioval" -a "$resetval" != "$gpioval" ]; then +if [ "$resetval" = "true" ] || [ -n "$gpioval" ] && [ "$resetval" != "$gpioval" ]; then echo "Factory reset requested." if ! mkfs.ext4 -F "${rwfsdev}"; then echo "Reformat for factory reset failed." /bin/sh else # gpioval will be an empty string if factory-reset-toggle was not found - fw_setenv rwreset $gpioval + fw_setenv rwreset "$gpioval" echo "rwfs has been formatted." fi fi @@ -95,7 +94,7 @@ mkdir -p $rodir/var/persist/etc $rodir/var/persist/etc-work $rodir/var/persist/h mount overlay $rodir/etc -t overlay -o lowerdir=$rodir/etc,upperdir=$rodir/var/persist/etc,workdir=$rodir/var/persist/etc-work for f in $fslist; do - mount --move $f $rodir/$f + mount --move "$f" "$rodir/$f" done exec switch_root $rodir /sbin/init |