From 29f335070ac812497b37d9e052bd75bd58fe546e Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 30 Mar 2021 10:40:12 +0200 Subject: [PATCH] fix(dracut-initramfs-restore.sh): shellcheck for dracut-initramfs-restore.sh --- dracut-initramfs-restore.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh index 872a5fbd..8fe23df0 100644 --- a/dracut-initramfs-restore.sh +++ b/dracut-initramfs-restore.sh @@ -10,9 +10,9 @@ KERNEL_VERSION="$(uname -r)" [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut SKIP="$dracutbasedir/skipcpio" -[[ -x $SKIP ]] || SKIP=cat +[[ -x $SKIP ]] || SKIP="cat" -[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id +[[ -f /etc/machine-id ]] && read -r MACHINE_ID < /etc/machine-id mount -o ro /boot &> /dev/null || true @@ -48,8 +48,7 @@ else fi if [[ -d squash ]]; then - unsquashfs -no-xattrs -f -d . squash-root.img > /dev/null - if [ $? -ne 0 ]; then + if ! unsquashfs -no-xattrs -f -d . squash-root.img > /dev/null; then echo "Squash module is enabled for this initramfs but failed to unpack squash-root.img" >&2 rm -f -- /run/initramfs/shutdown exit 1 @@ -58,7 +57,7 @@ fi if [ -e /etc/selinux/config -a -x /usr/sbin/setfiles ]; then . /etc/selinux/config - /usr/sbin/setfiles -v -r /run/initramfs /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts /run/initramfs > /dev/null + /usr/sbin/setfiles -v -r /run/initramfs /etc/selinux/"${SELINUXTYPE}"/contexts/files/file_contexts /run/initramfs > /dev/null fi exit 0