]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut-initramfs-restore.sh): shellcheck for dracut-initramfs-restore.sh
authorHarald Hoyer <harald@redhat.com>
Tue, 30 Mar 2021 08:40:12 +0000 (10:40 +0200)
committerHarald Hoyer <harald@hoyer.xyz>
Wed, 31 Mar 2021 07:32:33 +0000 (09:32 +0200)
dracut-initramfs-restore.sh

index 872a5fbdb7c731e3b3f46b930d40695e425bb37a..8fe23df0d29171d8be3e63875b8491c8d77bae8b 100644 (file)
@@ -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