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

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