Blame SOURCES/0293-iscsi-parse-iscsiroot.sh-use-iBFT-initiator-name.patch

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