712866
From d9b00731c81fa2facd5c6088a08bdd579d550eba Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Wed, 12 Aug 2015 15:14:11 +0200
712866
Subject: [PATCH] iscsi/parse-iscsiroot.sh: use iBFT initiator name
712866
712866
(cherry picked from commit feb8dc685dca1229c517de9ec9854367b8c49524)
712866
---
712866
 modules.d/95iscsi/parse-iscsiroot.sh | 14 +++++++++++++-
712866
 1 file changed, 13 insertions(+), 1 deletion(-)
712866
712866
diff --git a/modules.d/95iscsi/parse-iscsiroot.sh b/modules.d/95iscsi/parse-iscsiroot.sh
5c6c2a
index 6a21b503..2939e58a 100755
712866
--- a/modules.d/95iscsi/parse-iscsiroot.sh
712866
+++ b/modules.d/95iscsi/parse-iscsiroot.sh
712866
@@ -60,7 +60,7 @@ if [ -n "$iscsiroot" ] ; then
712866
 fi
712866
 
712866
 # iscsi_firmware does not need argument checking
712866
-if [ -n "$iscsi_firmware" ] ; then
712866
+if [ -n "$iscsi_firmware" ] || getargbool 0 rd.iscsi.ibft -d "ip=ibft"; then
712866
     [ -z "$netroot" ] && netroot=iscsi:
712866
     modprobe -b -q iscsi_boot_sysfs 2>/dev/null
712866
     modprobe -b -q iscsi_ibft
712866
@@ -103,6 +103,18 @@ if arg=$(getarg rd.iscsi.initiator -d iscsi_initiator=) && [ -n "$arg" ]; then
712866
     fi
712866
 fi
712866
 
712866
+# If not given on the cmdline and initiator-name available via iBFT
712866
+if [ -z $iscsi_initiator ] && [ -f /sys/firmware/ibft/initiator/initiator-name ] && ! [ -f /tmp/iscsi_set_initiator ]; then
712866
+    iscsi_initiator=$(while read line || [ -n "$line" ]; do echo $line;done < /sys/firmware/ibft/initiator/initiator-name)
712866
+    echo "InitiatorName=$iscsi_initiator" > /run/initiatorname.iscsi
712866
+    rm -f /etc/iscsi/initiatorname.iscsi
712866
+    mkdir -p /etc/iscsi
712866
+    ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
712866
+    systemctl restart iscsid
712866
+    sleep 1
712866
+    > /tmp/iscsi_set_initiator
712866
+fi
712866
+
712866
 if [ -n "$iscsi_firmware" ] ; then
712866
     echo "[ -f '/tmp/iscsistarted-firmware' ]" > $hookdir/initqueue/finished/iscsi_started.sh
712866
 else