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