Blob Blame History Raw
From e803d076f8689a92ae42de4f5675c51e8a9c492d Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 3 Sep 2015 12:41:06 +0200
Subject: [PATCH] iscsi/parse-iscsiroot.sh: only set initiator-name, if not
 empty

(cherry picked from commit eb87dc91d078ee942ef9c8bbc8e82f4ee4ccf0c6)
---
 modules.d/95iscsi/parse-iscsiroot.sh | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules.d/95iscsi/parse-iscsiroot.sh b/modules.d/95iscsi/parse-iscsiroot.sh
index dab58db..81be6a9 100755
--- a/modules.d/95iscsi/parse-iscsiroot.sh
+++ b/modules.d/95iscsi/parse-iscsiroot.sh
@@ -112,12 +112,14 @@ fi
 # If not given on the cmdline and initiator-name available via iBFT
 if [ -z $iscsi_initiator ] && [ -f /sys/firmware/ibft/initiator/initiator-name ] && ! [ -f /tmp/iscsi_set_initiator ]; then
     iscsi_initiator=$(while read line || [ -n "$line" ]; do echo $line;done < /sys/firmware/ibft/initiator/initiator-name)
-    echo "InitiatorName=$iscsi_initiator" > /run/initiatorname.iscsi
-    rm -f /etc/iscsi/initiatorname.iscsi
-    mkdir -p /etc/iscsi
-    ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
-    > /tmp/iscsi_set_initiator
-    systemctl try-restart iscsid && sleep 1
+    if [ -n "$iscsi_initiator" ]; then
+        echo "InitiatorName=$iscsi_initiator" > /run/initiatorname.iscsi
+        rm -f /etc/iscsi/initiatorname.iscsi
+        mkdir -p /etc/iscsi
+        ln -fs /run/initiatorname.iscsi /etc/iscsi/initiatorname.iscsi
+        > /tmp/iscsi_set_initiator
+        systemctl try-restart iscsid && sleep 1
+    fi
 fi