3888c9
From 0df65c3c001fb5656838274b172c247c41dc0442 Mon Sep 17 00:00:00 2001
3888c9
From: Martin Wilck <mwilck@suse.de>
3888c9
Date: Thu, 4 Apr 2019 17:12:07 +0200
3888c9
Subject: [PATCH] iscsiroot: remove bashisms
3888c9
3888c9
According to the dracut README, module code to be run in
3888c9
the initrd must be POSIX-compliant. Replace remaining
3888c9
bashisms (as reported by checkbashisms) with POSIX compliant
3888c9
code.
3888c9
3888c9
The use of "type" is not strictly POSIX compliant, but it's
3888c9
all over the place in dracut code. dash supports it, anyway.
3888c9
---
3888c9
 modules.d/95iscsi/iscsiroot.sh | 26 +++++++++++++-------------
3888c9
 1 file changed, 13 insertions(+), 13 deletions(-)
3888c9
3888c9
diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh
3888c9
index e8e0b4b8..4ab0b6a0 100755
3888c9
--- a/modules.d/95iscsi/iscsiroot.sh
3888c9
+++ b/modules.d/95iscsi/iscsiroot.sh
3888c9
@@ -54,11 +54,11 @@ handle_firmware()
3888c9
     if ! iscsiadm -m fw; then
3888c9
         warn "iscsiadm: Could not get list of targets from firmware."
3888c9
     else
3888c9
-        ifaces=( $(echo /sys/firmware/ibft/ethernet*) )
3888c9
+        ifaces=$(set -- /sys/firmware/ibft/ethernet*; echo $#)
3888c9
         retry=$(cat /tmp/session-retry)
3888c9
 
3888c9
-        if [ $retry -lt ${#ifaces[*]} ]; then
3888c9
-            let retry++
3888c9
+        if [ $retry -lt $ifaces ]; then
3888c9
+            retry=$((retry+1))
3888c9
             echo $retry > /tmp/session-retry
3888c9
             return 1
3888c9
         else
3888c9
@@ -88,6 +88,7 @@ handle_netroot()
3888c9
     local iscsi_iface_name iscsi_netdev_name
3888c9
     local iscsi_param param
3888c9
     local p found
3888c9
+    local login_retry_max_seen=
3888c9
 
3888c9
     # override conf settings by command line options
3888c9
     arg=$(getarg rd.iscsi.initiator -d iscsi_initiator=)
3888c9
@@ -103,7 +104,9 @@ handle_netroot()
3888c9
     arg=$(getarg rd.iscsi.in.password -d iscsi_in_password=)
3888c9
     [ -n "$arg" ] && iscsi_in_password=$arg
3888c9
     for p in $(getargs rd.iscsi.param -d iscsi_param); do
3888c9
-        iscsi_param="$iscsi_param $p"
3888c9
+        [ "${p%=*}" = node.session.initial_login_retry_max ] && \
3888c9
+            login_retry_max_seen=yes
3888c9
+            iscsi_param="$iscsi_param $p"
3888c9
     done
3888c9
 
3888c9
     # this sets iscsi_target_name and possibly overwrites most
3888c9
@@ -116,15 +119,12 @@ handle_netroot()
3888c9
     fi
3888c9
 
3888c9
     #limit iscsistart login retries
3888c9
-    case "$iscsi_param" in
3888c9
-        *node.session.initial_login_retry_max*) ;;
3888c9
-        *)
3888c9
-            retries=$(getargnum 3 0 10000 rd.iscsi.login_retry_max)
3888c9
-            if [ $retries -gt 0 ]; then
3888c9
-                iscsi_param="${iscsi_param% } node.session.initial_login_retry_max=$retries"
3888c9
-            fi
3888c9
-        ;;
3888c9
-    esac
3888c9
+    if [ "$login_retry_max_seen" != yes ]; then
3888c9
+        retries=$(getargnum 3 0 10000 rd.iscsi.login_retry_max)
3888c9
+        if [ $retries -gt 0 ]; then
3888c9
+            iscsi_param="${iscsi_param% } node.session.initial_login_retry_max=$retries"
3888c9
+        fi
3888c9
+    fi
3888c9
 
3888c9
 # XXX is this needed?
3888c9
     getarg ro && iscsirw=ro
3888c9