diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2023-02-03 23:46:48 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2023-02-22 20:16:10 +0300 |
commit | 6764c56f08bdd95ee1bb38a634ef2c9a61f66265 (patch) | |
tree | 3c9081d2ee947c6b13cf31b2a7d59f1a79a983d0 | |
parent | 7f95dae13b419922c827a965b49e3d220527d4fd (diff) | |
download | openbmc-6764c56f08bdd95ee1bb38a634ef2c9a61f66265.tar.xz |
meta-phosphor: preinit-mounts: shellcheck and prettysh
Clean up this script a bit by formatting with prettysh and cleaning
up all the shellcheck warnings.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ic7e6d1ba8ab01b047efcb3ac53e16667e9ac82eb
-rw-r--r-- | meta-phosphor/recipes-phosphor/preinit-mounts/preinit-mounts/init | 71 | ||||
-rwxr-xr-x | meta-phosphor/scripts/run-repotest | 1 |
2 files changed, 35 insertions, 37 deletions
diff --git a/meta-phosphor/recipes-phosphor/preinit-mounts/preinit-mounts/init b/meta-phosphor/recipes-phosphor/preinit-mounts/preinit-mounts/init index ad81327982..134bbad60d 100644 --- a/meta-phosphor/recipes-phosphor/preinit-mounts/preinit-mounts/init +++ b/meta-phosphor/recipes-phosphor/preinit-mounts/preinit-mounts/init @@ -1,30 +1,30 @@ #!/bin/sh mount_overlay() { - if ! mount overlay /etc -t overlay -o defaults,lowerdir=/etc,upperdir=/var/persist/etc,workdir=/var/persist/etc-work; then - mount overlay /etc -t overlay -o defaults,lowerdir=/etc:/var/persist/etc - fi + if ! mount overlay /etc -t overlay -o defaults,lowerdir=/etc,upperdir=/var/persist/etc,workdir=/var/persist/etc-work; then + mount overlay /etc -t overlay -o defaults,lowerdir=/etc:/var/persist/etc + fi } recreate_overlay() { - # Attempt to re-create the overlay by moving out the overlay contents and - # copying them back to /etc, which would create them back in the overlay - cd - if ! umount /etc; then - return - fi - rm -rf /var/persist/etc-save - mv /var/persist/etc /var/persist/etc-save - mkdir -p /var/persist/etc - mount_overlay - cp -rp /var/persist/etc-save/* /etc/ - rm -rf /var/persist/etc-save + # Attempt to re-create the overlay by moving out the overlay contents and + # copying them back to /etc, which would create them back in the overlay + cd / + if ! umount /etc; then + return + fi + rm -rf /var/persist/etc-save + mv /var/persist/etc /var/persist/etc-save + mkdir -p /var/persist/etc + mount_overlay + cp -rp /var/persist/etc-save/* /etc/ + rm -rf /var/persist/etc-save } if ! mount ubi0:rwfs /var -t ubifs -o defaults; then - if ! mount ubi0:rwfs /var -t ubifs -o defaults,ro; then - mount tmpfs /var -t tmpfs -o defaults - fi + if ! mount ubi0:rwfs /var -t ubifs -o defaults,ro; then + mount tmpfs /var -t tmpfs -o defaults + fi fi mkdir -p /var/persist/etc /var/persist/etc-work /var/persist/home/root @@ -39,26 +39,25 @@ mount_overlay # overlay by doing an 'ls' command error="/var/overlay-error" recreate_overlay_done= -cd /var/persist/etc/ -files=$(find . -type f) +files=$(find /var/persist/etc -type f | sed 's#/var/persist/etc/##') for i in $files; do - ls -i /etc/$i >/dev/null 2>${error}; - if [[ -s ${error} ]]; then - # We don't have a way to print this error to the journal, delete it - rm -f ${error} - if test -n "$recreate_overlay_done"; then - recreate_overlay - recreate_overlay_done="true" - fi - # Check file once more - ls -i /etc/$i >/dev/null 2>${error}; - if [[ -s ${error} ]]; then - # File still corrupted, delete it from the overlay - echo "Removing corrupted file from overlay: $i" - rm -f ${error} - rm -f /var/persist/etc/$i + ls -i "/etc/$i" >/dev/null 2>${error}; + if [ -s ${error} ]; then + # We don't have a way to print this error to the journal, delete it + rm -f ${error} + if test -n "$recreate_overlay_done"; then + recreate_overlay + recreate_overlay_done="true" + fi + # Check file once more + ls -i "/etc/$i" >/dev/null 2>${error}; + if [ -s ${error} ]; then + # File still corrupted, delete it from the overlay + echo "Removing corrupted file from overlay: $i" + rm -f ${error} + rm -f "/var/persist/etc/$i" + fi fi - fi done exec /lib/systemd/systemd diff --git a/meta-phosphor/scripts/run-repotest b/meta-phosphor/scripts/run-repotest index ac31f74d4b..a13c2b7dae 100755 --- a/meta-phosphor/scripts/run-repotest +++ b/meta-phosphor/scripts/run-repotest @@ -153,7 +153,6 @@ meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-shutdown.sh meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-update.sh meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh meta-phosphor/recipes-phosphor/interfaces/bmcweb/run-ptest -meta-phosphor/recipes-phosphor/preinit-mounts/preinit-mounts/init meta-phosphor/recipes-support/nss-pam-ldapd/files/nslcd.init meta-quanta/meta-common/recipes-quanta/network/usb-network/usb-network.sh meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-update.sh |