File 0022-rc.target.suse-Save-configuration-during-shutdown.patch of Package lio-utils.216

From 933c950ccef79e17330f76a3bb74a71279bf17f4 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Fri, 1 Feb 2013 15:47:13 +0100
Subject: rc.target.suse: Save configuration during shutdown

We need to save the configuration during shutdown, so that we
can start with the same configuration after booting.

References: bnc#787195

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 scripts/rc.target.suse | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/scripts/rc.target.suse b/scripts/rc.target.suse
index dacdb77..20fc454 100644
--- a/scripts/rc.target.suse
+++ b/scripts/rc.target.suse
@@ -239,17 +239,12 @@ start () {
 		rc_status -v
 		return 0
 	fi
-	if test "x `lsmod | grep ${MODNAME} | awk '{ if ($$1 == "${MODNAME}") print $$1 }'`" == x ; then
-		return 0
-	else
-		if [ -e ${LOCK_TARGET} ]; then
-			rm -f ${LOCK_TARGET}
-		fi
+	if [ -e ${LOCK_TARGET} ]; then
+		rm -f ${LOCK_TARGET}
 	fi
 
-# Prevent multiple driver panics from hanging system (probably via scsi or target driver).
-# HINT: Most likely cause is a problem within '/etc/iscsi/install.target'.
-# Save a backup of the file, then NULL'd it to troubleshoot this variant.
+	# Prevent multiple driver panics from hanging system
+	# (probably via iscsi or target driver).
 	if [ -e ${SEMA_TARGET} ]; then
 		RETVAL=1
 		echo -n "See ${SEMA_TARGET}"
@@ -257,8 +252,8 @@ start () {
 		return $RETVAL
 	fi
 
-# Put message in semaphore file to aid in troubleshooting should
-# the file still exist during a subsequent boot.
+	# Put message in semaphore file to aid in troubleshooting should
+	# the file still exist during a subsequent boot.
 	echo "$0: Created: " `date` > ${SEMA_TARGET}
 	echo "$0: " >> ${SEMA_TARGET}
 	echo "$0: This file has been created as a result of a potentially" >> ${SEMA_TARGET}
@@ -269,12 +264,6 @@ start () {
 	echo "$0: You must remove /var/crash/target.fault before attempting" >> ${SEMA_TARGET}
 	echo "$0: to start again." >> ${SEMA_TARGET}
 	echo "$0: " >> ${SEMA_TARGET}
-	echo "$0: Continued startup problems might be researched by saving" >> ${SEMA_TARGET}
-	echo "$0: off the current /etc/iscsi/install.target file and then" >> ${SEMA_TARGET}
-	echo "$0: replacing it with a dummy file which contains no entries." >> ${SEMA_TARGET}
-	echo "$0: If bootup is then successful, contact the iSCSI Target" >> ${SEMA_TARGET}
-	echo "$0: Stack manufacturer for assistance with problems within" >> ${SEMA_TARGET}
-	echo "$0: the target configuration file." >> ${SEMA_TARGET}
 
 	if [ -e ${LOCK_TARGET} ]; then
 		rm -f ${SEMA_TARGET}
@@ -315,10 +304,14 @@ stop () {
 	    rc_status -v
 	    return;
 	fi
+	# Save configuration
+	lio_dump --stdout > $CONFIGFS_SCRIPT_DIR/lio_setup.sh
+	tcm_dump --stdout > $CONFIGFS_SCRIPT_DIR/tcm_setup.sh
+	# Unload stack
 	unload_tcm_mod
 	RET=$?
 	if [ $RET == 0 ]; then
-	    rm -f ${LOCK_TARGET}
+		rm -f ${LOCK_TARGET}
 	fi
 	return $RET
 }
-- 
1.8.1.4

openSUSE Build Service is sponsored by