File open-iscsi-update-suse-init-scripts of Package open-iscsi

From e734d56e6a45eb85cbd8d728310a793970e90757 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Wed, 12 Nov 2008 15:25:55 +0100
Subject: [PATCH] Update SUSE init scripts

Update SUSE init scripts to work properly for root-on-iSCSI.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 etc/initd/boot.suse  |   15 +++++++--------
 etc/initd/initd.suse |   36 ------------------------------------
 2 files changed, 7 insertions(+), 44 deletions(-)

diff --git a/etc/initd/boot.suse b/etc/initd/boot.suse
index e4a54a6..3e93cad 100644
--- a/etc/initd/boot.suse
+++ b/etc/initd/boot.suse
@@ -4,7 +4,7 @@
 #
 ### BEGIN INIT INFO
 # Provides:          iscsiboot
-# Required-Start:    boot.proc
+# Required-Start:    
 # Should-Start:      
 # Required-Stop:     $null
 # Should-Stop:
@@ -26,16 +26,16 @@ ARGS="-c $CONFIG_FILE -p $PID_FILE"
 . /etc/rc.status
 
 #
-# This service is run right after booting. So all activated targets
-# must be enabled during mkinitrd run and thus should not be removed
-# when the open-iscsi service is stopped.
+# This service is run right after booting. So all targets activated
+# during mkinitrd run should not be removed when the open-iscsi
+# service is stopped.
 #
 iscsi_mark_root_nodes()
 {
     $ISCSIADM -m session 2> /dev/null | while read t num i target ; do
 	ip=${i%%:*}
-	STARTUP=`$ISCSIADM -m node -p $ip -T $target | grep "node.conn\[0\].startup" | cut -d' ' -f3`
-	if [ "$STARTUP" != "onboot" ] ; then
+	STARTUP=`$ISCSIADM -m node -p $ip -T $target 2> /dev/null | grep "node.conn\[0\].startup" | cut -d' ' -f3`
+	if [ "$STARTUP" -a "$STARTUP" != "onboot" ] ; then
 	    $ISCSIADM -m node -p $ip -T $target -o update -n node.conn[0].startup -v onboot
 	fi
     done
@@ -52,7 +52,6 @@ fi
 
 case "$1" in
     start)
-	[ ! -d /var/lib/open-iscsi ] && mkdir -p /var/lib/open-iscsi
 	echo -n "Starting iSCSI initiator for the root device: "
 	startproc $DAEMON $ARGS
 	rc_status -v
diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse
index 5c42b88..69b681b 100644
--- a/etc/initd/initd.suse
+++ b/etc/initd/initd.suse
@@ -103,38 +103,6 @@ iscsi_list_all_nodes()
     done
 }
 
-iscsi_discover_all_targets()
-{
-	# Strip off any existing ID information
-	RAW_NODE_LIST=`iscsiadm -m node | sed -nre 's/^(\[[0-9a-f]*\] )?(.*)$/\2/p'`
-	# Obtain IPv4 list
-	IPV4_NODE_LIST=`echo "$RAW_NODE_LIST" | sed -nre 's/^([0-9]{1,3}(\.[0-9]{1,3}){3}):[^: ]* (.*)$/\1 \3/p'`
-	# Now obtain IPv6 list
-	IPV6_NODE_LIST=`echo "$RAW_NODE_LIST" | sed -nre 's/^([0-9a-f]{1,4}(:[0-9a-f]{0,4}){6}:[0-9a-f]{1,4}):[^: ]* (.*)$/\1 \3/p'`
-
-	DISC_TARGETS=""
-	while read NODE_ADDR NODE_NAME; do
-		[ -z "$NODE_ADDR" -a -z "$NODE_NAME" ] && continue
-		NODE_ATTRS=`iscsiadm -m node -p "$NODE_ADDR" -T "$NODE_NAME"`
-		NODE_STATUS=`echo "$NODE_ATTRS" | sed -nre 's/^.*node\.conn\[0\]\.startup = ([a-z]*).*$/\1/p'`
-
-		if [ "$NODE_STATUS" == 'automatic' ]; then
-			DISC_TARGETS=`echo "$DISC_TARGETS" | sed -re '/'"$NODE_ADDR"'/!{s/(.*)/\1 '"$NODE_ADDR"'/}'`
-		fi
-	done < <(echo "$IPV4_NODE_LIST"; echo "$IPV6_NODE_LIST")
-
-	for TARGET_ADDR in $DISC_TARGETS; do
-		echo -n "Attempting discovery on target at ${TARGET_ADDR}: "
-		iscsiadm -m discovery -t st -p "$TARGET_ADDR" > /dev/null 2>&1
-		if [ "$?" -ne 0 ]; then
-			rc_failed 1
-			rc_status -v
-			return 1
-		fi
-		rc_status -v
-	done
-}
-
 case "$1" in
     start)
 	[ ! -d /var/lib/iscsi ] && mkdir -p /var/lib/iscsi
@@ -149,10 +117,6 @@ case "$1" in
 	    rc_status -v
 	fi
 	if [ "$RETVAL" == "0" ]; then
-	    iscsi_discover_all_targets
-	    RETVAL=$?
-	fi
-	if [ "$RETVAL" == "0" ]; then
 	    iscsi_login_all_nodes
 	fi
 	;;
-- 
1.6.0.2