]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(nvmf): shellcheck for modules.d/95nvmf
authorHarald Hoyer <harald@redhat.com>
Fri, 26 Mar 2021 09:29:28 +0000 (10:29 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 29 Mar 2021 09:39:52 +0000 (11:39 +0200)
modules.d/95nvmf/.shchkdir [new file with mode: 0644]
modules.d/95nvmf/module-setup.sh
modules.d/95nvmf/parse-nvmf-boot-connections.sh

diff --git a/modules.d/95nvmf/.shchkdir b/modules.d/95nvmf/.shchkdir
new file mode 100644 (file)
index 0000000..e69de29
index 1d06b7c1858e879d260466fe64eafe5e630d4dae..f2bd5ed1600308957542769d5a830bdacf49de4b 100755 (executable)
@@ -29,7 +29,7 @@ check() {
         pushd . > /dev/null
         for_each_host_dev_and_slaves is_nvmf
         local _is_nvmf=$?
-        popd > /dev/null
+        popd > /dev/null || exit
         [[ $_is_nvmf == 0 ]] || return 255
         if [ ! -f /sys/class/fc/fc_udev_device/nvme_discovery ]; then
             if [ ! -f /etc/nvme/discovery.conf ]; then
@@ -76,7 +76,7 @@ cmdline() {
         done
 
         [ -z "$trtype" ] && return 0
-        nvme list-subsys ${PWD##*/} | while read x dev trtype traddr host_traddr state ana; do
+        nvme list-subsys "${PWD##*/}" | while read -r _ _ trtype traddr host_traddr _; do
             [ "$trtype" != "${trtype#NQN}" ] && continue
             echo -n " nvmf.discover=$trtype,${traddr#traddr=},${host_traddr#host_traddr=}"
         done
@@ -94,14 +94,15 @@ cmdline() {
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         pushd . > /dev/null
         for_each_host_dev_and_slaves gen_nvmf_cmdline
-        popd > /dev/null
+        popd > /dev/null || exit
     }
 }
 
 # called by dracut
 install() {
     if [[ $hostonly_cmdline == "yes" ]]; then
-        local _nvmf_args=$(cmdline)
+        local _nvmf_args
+        _nvmf_args=$(cmdline)
         [[ "$_nvmf_args" ]] && printf "%s" "$_nvmf_args" >> "${initdir}/etc/cmdline.d/95nvmf-args.conf"
     fi
     inst_simple "/etc/nvme/hostnqn"
index d75f780acd4b7aef6990b6a899dd8f08e999ce9b..0822bec916c15f38e8eb29420d4ce4afc3a22685 100755 (executable)
@@ -32,7 +32,7 @@ validate_ip_conn() {
         return 1
     fi
 
-    local_address=$(ip -o route get to $traddr | sed -n 's/.*src \([0-9a-f.:]*\).*/\1/p')
+    local_address=$(ip -o route get to "$traddr" | sed -n 's/.*src \([0-9a-f.:]*\).*/\1/p')
 
     # confirm we got a local IP address
     if ! is_ip "$local_address"; then
@@ -40,7 +40,7 @@ validate_ip_conn() {
         return 1
     fi
 
-    ifname=$(ip -o route get to $local_address | sed -n 's/.*dev \([^ ]*\).*/\1/p')
+    ifname=$(ip -o route get to "$local_address" | sed -n 's/.*dev \([^ ]*\).*/\1/p')
 
     if ip l show "$ifname" > /dev/null 2>&1; then
         warn "invalid network interface $ifname"
@@ -61,7 +61,8 @@ parse_nvmf_discover() {
     trsvcid=4420
     OLDIFS="$IFS"
     IFS=,
-    set $1
+    # shellcheck disable=SC2086
+    set -- $1
     IFS="$OLDIFS"
 
     case $# in
@@ -133,7 +134,7 @@ done
 if [ -f "/etc/nvme/discovery.conf" ]; then
     /sbin/initqueue --settled --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all
     if [ "$trtype" = "tcp" ]; then
-        > /tmp/net.$ifname.did-setup
+        : > /tmp/net."$ifname".did-setup
     fi
 else
     # No nvme command line arguments present, try autodiscovery