]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix: shellcheck for modules.d/99base/module-setup.sh
authorHarald Hoyer <harald@redhat.com>
Fri, 12 Feb 2021 12:26:14 +0000 (13:26 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 15 Feb 2021 10:00:37 +0000 (11:00 +0100)
modules.d/99base/module-setup.sh

index c9e3ebcba7921a8f325fcc3fd986732340031188..bf037bb6773e6b1ce98c63a9f19b4c31699bfbc1 100755 (executable)
@@ -13,8 +13,6 @@ depends() {
 
 # called by dracut
 install() {
-    local _d
-
     inst_multiple mount mknod mkdir sleep chroot chown \
         sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink setsid \
         modprobe
@@ -30,9 +28,9 @@ install() {
     # use password for hostonly images to facilitate secure sulogin in emergency console
     [[ $hostonly ]] && pwshadow='x'
     grep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo  "root:$pwshadow:0:0::/root:/bin/sh" >> "$initdir/etc/passwd"
-    grep '^nobody:' $dracutsysrootdir/etc/passwd >> "$initdir/etc/passwd"
+    grep '^nobody:' "$dracutsysrootdir"/etc/passwd >> "$initdir/etc/passwd"
 
-    [[ $hostonly ]] && grep '^root:' $dracutsysrootdir/etc/shadow >> "$initdir/etc/shadow"
+    [[ $hostonly ]] && grep '^root:' "$dracutsysrootdir"/etc/shadow >> "$initdir/etc/shadow"
 
     # install our scripts and hooks
     inst_script "$moddir/init.sh" "/init"
@@ -40,14 +38,14 @@ install() {
     inst_script "$moddir/loginit.sh" "/sbin/loginit"
     inst_script "$moddir/rdsosreport.sh" "/sbin/rdsosreport"
 
-    [ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib
-    mkdir -m 0755 -p ${initdir}/lib/dracut
-    mkdir -m 0755 -p ${initdir}/lib/dracut/hooks
+    [ -e "${initdir}/lib" ] || mkdir -m 0755 -p "${initdir}"/lib
+    mkdir -m 0755 -p "${initdir}"/lib/dracut
+    mkdir -m 0755 -p "${initdir}"/lib/dracut/hooks
 
-    mkdir -p ${initdir}/tmp
+    mkdir -p "${initdir}"/tmp
 
     inst_simple "$moddir/dracut-lib.sh" "/lib/dracut-lib.sh"
-    mkdir -p "${initdir}/var"
+    mkdir -p "${initdir}"/var
 
     if ! dracut_module_included "systemd"; then
         inst_multiple switch_root || dfatal "Failed to install switch_root"
@@ -71,9 +69,9 @@ install() {
     local VERSION=""
     local PRETTY_NAME=""
     # Derive an os-release file from the host, if it exists
-    if [ -e $dracutsysrootdir/etc/os-release ]; then
-        . $dracutsysrootdir/etc/os-release
-        grep -hE -ve '^VERSION=' -ve '^PRETTY_NAME' $dracutsysrootdir/etc/os-release >${initdir}/usr/lib/initrd-release
+    if [[ -e $dracutsysrootdir/etc/os-release ]]; then
+        . "$dracutsysrootdir"/etc/os-release
+        grep -hE -ve '^VERSION=' -ve '^PRETTY_NAME' "$dracutsysrootdir"/etc/os-release >"${initdir}"/usr/lib/initrd-release
         [[ -n ${VERSION} ]] && VERSION+=" "
         [[ -n ${PRETTY_NAME} ]] && PRETTY_NAME+=" "
     else
@@ -95,18 +93,18 @@ install() {
         # to easily detect the dracut version if need be without
         # having it mixed in with the real underlying OS version.
         echo DRACUT_VERSION=\"${DRACUT_VERSION}\"
-    } >> $initdir/usr/lib/initrd-release
-    echo dracut-$DRACUT_VERSION > $initdir/lib/dracut/dracut-$DRACUT_VERSION
+    } >> "$initdir"/usr/lib/initrd-release
+    echo "dracut-$DRACUT_VERSION" > "$initdir/lib/dracut/dracut-$DRACUT_VERSION"
     ln -sf ../usr/lib/initrd-release $initdir/etc/initrd-release
     ln -sf initrd-release $initdir/usr/lib/os-release
     ln -sf initrd-release $initdir/etc/os-release
 
     ## save host_devs which we need bring up
     if [[ $hostonly_cmdline == "yes" ]]; then
-        if [[ -n "${host_devs[@]}" ]]; then
+        if [[ -n "${host_devs[*]}" ]]; then
             dracut_need_initqueue
         fi
-        if [[ -f "$initdir/lib/dracut/need-initqueue" ]] || ! dracut_module_included "systemd"; then
+        if [[ -f $initdir/lib/dracut/need-initqueue ]] || ! dracut_module_included "systemd"; then
             (
                 if dracut_module_included "systemd"; then
                     DRACUT_SYSTEMD=1