summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authoraaizman <aaizman@d7303112-9cec-0310-bdd2-e83a94d6c2b6>2005-11-04 16:12:16 +0000
committeraaizman <aaizman@d7303112-9cec-0310-bdd2-e83a94d6c2b6>2005-11-04 16:12:16 +0000
commita44a861bf0f2df8d31bd43f32bcbf11fd8cef10f (patch)
tree73cab06bed0fa72b4376b8717fd9c87f16aeb97c /etc
parent3e9dc5da488514651acb8accabf12a884c59737a (diff)
downloadopen-iscsi-a44a861bf0f2df8d31bd43f32bcbf11fd8cef10f.tar.gz
Albert Pauw: got rid of /etc/sysconfig/openiscsi file
- automatic login into target - cleaned up start/stop stuff In order to have an automatic login into a target a parameter in the target database should be set: iscsiadm -m node -r <rec-id> -o update -n node.conn[0].startup -v automatic This parameter is set default to manual. git-svn-id: svn://svn.berlios.de/open-iscsi@438 d7303112-9cec-0310-bdd2-e83a94d6c2b6
Diffstat (limited to 'etc')
-rw-r--r--etc/initd/initd.redhat149
1 files changed, 79 insertions, 70 deletions
diff --git a/etc/initd/initd.redhat b/etc/initd/initd.redhat
index 0f8b8d3..01b673f 100644
--- a/etc/initd/initd.redhat
+++ b/etc/initd/initd.redhat
@@ -16,95 +16,104 @@ else
fi
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
-RETVAL=0
-CONFIG="/etc/sysconfig/openiscsi"
-if [ ! -f ${CONFIG} ] ; then
- echo "#" > ${CONFIG}
- echo "# open-iscsi config file" >> ${CONFIG}
- echo "#" >> ${CONFIG}
- echo "# Contains path to iscsiadm and iscsid" >> ${CONFIG}
- echo "#" >> ${CONFIG}
- echo "# Use TARGETS=\"<record id> <record id>\"" >> ${CONFIG}
- echo "# to log in automatically when starting up service" >> ${CONFIG}
- echo "#" >> ${CONFIG}
- ISCSID=`which iscsid`
- echo "ISCSID=\"${ISCSID}\"" >> ${CONFIG}
- ISCSIADM=`which iscsiadm`
- echo "ISCSIADM=\"${ISCSIADM}\"" >> ${CONFIG}
- echo "TARGETS=\"\"" >> ${CONFIG}
-fi
-
-. ${CONFIG}
+ISCSID=`which iscsid`
+ISCSIADM=`which iscsiadm`
-if [ -z ${ISCSID} ] ; then
- echo "No iscsid daemon found. Please edit /etc/sysconfig/openiscsi"
- exit 1
+if [ -z $ISCSID ] || [ -z $ISCSIADM ]
+then
+ echo "open-iscsi not installed."
+ exit 1
fi
-if [ -z ${ISCSIADM} ] ; then
- echo "No iscsiadm daemon found. Please edit /etc/sysconfig/openiscsi"
- exit 1
-fi
+start_iscsid()
+{
+ RETVAL=0
+ modprobe -q iscsi_tcp
+ daemon $ISCSID
+ RETVAL=$?
+ TARGETS=`$ISCSIADM -m node | sed 's@\[\(.*\)\] .*@\1@g'`
+ for rec in $TARGETS
+ do
+ STARTUP=`$ISCSIADM -m node -r $rec | grep "node.conn\[0\].startup" | cut -d' ' -f3`
+ if [ $STARTUP = "automatic" ]
+ then
+ $ISCSIADM -m node -r $rec -l
+ fi
+ done
+ return $RETVAL
+}
-start()
+stop_iscsid()
{
-echo -n "Starting iSCSI initiator service: "
-modprobe -q iscsi_tcp
-daemon ${ISCSID}
-RETVAL=$?
-for RECORD in ${TARGETS}
-do
- ${ISCSIADM} -m node -r ${RECORD} --login
-done
-if [ ${RETVAL} == "0" ]; then
- echo_success
-else
- echo_failure
-fi
-echo
-return ${RETVAL}
+ RETVAL=0
+ sync
+ TARGETS=`$ISCSIADM | grep "\[*\]" | sed 's@\[\(.*\)\] .*@\1@g'`
+ for rec in $TARGETS
+ do
+ $ISCSIADM -m node -r $rec -u
+ done
+ pkill -KILL `basename $ISCSID`
+ modprobe -r iscsi_tcp
+ RETVAL=$?
+ return $RETVAL
+}
+start()
+{
+ RETVAL=0
+ echo -n "Starting iSCSI initiator service: "
+ PID=`pidofproc $ISCSID`
+ if [ -z $PID ]
+ then
+ start_iscsid
+ fi
+ if [ $RETVAL == "0" ]
+ then
+ echo_success
+ else
+ echo_failure
+ fi
+ echo
+ return $RETVAL
}
stop()
{
-echo -n "Stopping iSCSI initiator service: "
-sync
-for RECORD in ${TARGETS}
-do
- ${ISCSIADM} -m node -r ${RECORD} --logout
-done
-pkill -KILL `basename ${ISCSID}`
-modprobe -r iscsi_tcp
-RETVAL=$?
-if [ $RETVAL == "0" ]; then
- echo_success
-else
- echo_failure
-fi
-echo
-return ${RETVAL}
-
+ RETVAL=0
+ echo -n "Stopping iSCSI initiator service: "
+ PID=`pidofproc $ISCSID`
+ if [ $PID ]
+ then
+ stop_iscsid
+ fi
+ if [ $RETVAL == "0" ]
+ then
+ echo_success
+ else
+ echo_failure
+ fi
+ echo
+ return $RETVAL
}
+
restart()
{
- stop
- start
-
+ stop
+ start
}
status()
{
-PID=`pidofproc ${ISCSID}`
-if [ ! ${PID} ]; then
- echo "iSCSI initiator is stopped."
- exit 1
-else
- echo "iSCSI initiator is running."
-fi
-
+ PID=`pidofproc $ISCSID`
+ if [ ! $PID ]
+ then
+ echo "iSCSI initiator is stopped."
+ exit 1
+ else
+ echo "iSCSI initiator is running."
+ fi
}
case "$1" in