summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authormnc <mnc@d7303112-9cec-0310-bdd2-e83a94d6c2b6>2006-11-09 17:12:15 +0000
committermnc <mnc@d7303112-9cec-0310-bdd2-e83a94d6c2b6>2006-11-09 17:12:15 +0000
commit72d8c989f352a9078fd27c720e0ace87293d5d53 (patch)
treecd59a4bcc8173891eb9f30a21c5369b685d5cd57 /etc
parent8fbbfac7982fbe8b877321d3929c849e31e6f706 (diff)
downloadopen-iscsi-72d8c989f352a9078fd27c720e0ace87293d5d53.tar.gz
update scripts to use login/logout all and pull in debain and suse fixes
git-svn-id: svn://svn.berlios.de/open-iscsi@725 d7303112-9cec-0310-bdd2-e83a94d6c2b6
Diffstat (limited to 'etc')
-rw-r--r--etc/initd/initd.debian162
-rw-r--r--etc/initd/initd.redhat24
-rw-r--r--etc/initd/initd.suse67
3 files changed, 99 insertions, 154 deletions
diff --git a/etc/initd/initd.debian b/etc/initd/initd.debian
index 6e6963b..d6e3d83 100644
--- a/etc/initd/initd.debian
+++ b/etc/initd/initd.debian
@@ -1,99 +1,91 @@
-#!/bin/sh
-#
-# chkconfig: - 39 35
-# description: Starts and stops the iSCSI initiator
-# debianized start-stop script
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:
+# Required-Start:
+# Required-Stop:
+# Default-Start:
+# Default-Stop:
+# Short-Description: Starts and stops the iSCSI initiator services and logins to default targets
+### END INIT INFO
-PID_FILE=/var/run/iscsid.pid
-CONFIG_FILE=/etc/iscsid.conf
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/sbin/iscsid
+ADM=/sbin/iscsiadm
+PIDFILE=/var/run/iscsid.pid
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
+[ -x "$DAEMON" ] || exit 0
+
+. /lib/lsb/init-functions
+
+if [ ! -d /sys/class/ ]; then
+ log_failure_msg "iSCSI requires a mounted sysfs, not started."
+ exit 1
+fi
+
+nodestartup_re='s/^node\.conn\[0]\.startup[ ]*=[ ]*//p'
RETVAL=0
-iscsid_start()
-{
- echo -n "Starting iSCSI initiator service: "
- modprobe scsi_transport_iscsi
- modprobe libiscsi
- modprobe iscsi_tcp
- start-stop-daemon --start --exec $DAEMON --quiet
+start() {
+ log_daemon_msg "Starting iSCSI initiator service" "iscsid"
+ modprobe -q iscsi_tcp 2>/dev/null || :
+ modprobe -q ib_iser 2>/dev/null || :
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
RETVAL=$?
- if [ $RETVAL == "0" ]; then
- echo "succeeded."
- else
- echo "failed."
- fi
+ log_end_msg $RETVAL
+ starttargets
}
-
-iscsid_stop()
-{
- echo -n "Stopping iSCSI initiator service: "
- start-stop-daemon --stop --quiet --exec $DAEMON --pidfile $PID_FILE
- RETVAL=$?
- if [ $RETVAL == "0" ]; then
- echo "succeeded."
- else
- echo "failed."
- fi
- # ugly, but pid file is not removed by iscsid
- rm -f $PID_FILE
- echo -n "Removing iSCSI enterprise target modules: "
- modprobe -r iscsi_tcp
- modprobe -r libiscsi
- modprobe -r scsi_transport_iscsi
- RETVAL=$?
- if [ $RETVAL == "0" ]; then
- echo "succeeded."
- else
- echo "failed."
- exit 1
- fi
+starttargets() {
+ log_daemon_msg "Setting up iSCSI targets"
+ $ADM -m node --loginall=automatic
+ done
+ log_end_msg 0
+}
+
+stoptargets() {
+ log_daemon_msg "Disconnecting iSCSI targets"
+ sync
+ $ADM -m node --logoutall=automatic
+ done
+ log_end_msg 0
+}
+
+stop() {
+ stoptargets
+ log_daemon_msg "Stopping iSCSI initiator service"
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON
+ rm -f $PIDFILE
+ modprobe -r ib_iser 2>/dev/null
+ modprobe -r iscsi_tcp 2>/dev/null
+ log_end_msg 0
+}
+
+restart() {
+ stop
+ start
+}
+
+restarttargets() {
+ stoptargets
+ starttargets
+}
+
+status() {
+ #XXX FIXME: what to do here?
+ #status iscsid
+ # list active sessions
+ echo Current active iSCSI sessions:
+ $ADM -m session
}
case "$1" in
- start)
- iscsid_start
- ;;
- stop)
- iscsid_stop
- ;;
- restart)
- iscsid_stop
- sleep 1
- iscsid_start
- ;;
- status)
- PID=`pidof iscsid`
- if [ $PID ]; then
- echo "iSCSI initiator is running at pid $PID"
- else
- echo "no iSCSI initiator found!"
+ start|starttargets|stop|stoptargets|restart|restarttargets|status)
+ $1
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|status}"
exit 1
- fi
- ;;
- dump)
- DUMP=`tempfile -p iscsid`
- RETVAL=$?
- if [ $RETVAL != "0" ]; then
- echo "Failed to create dump file $DUMP"
- exit 1
- fi
- iscsiadm -m node --record 0a45f8 >$DUMP
- RETVAL=$?
- if [ $RETVAL != "0" ]; then
- echo "Error dumping config from daemon"
- rm $DUMP
- exit 1
- fi
- mv -u $DUMP $CONFIG_FILE
- echo "Config dumped to $CONFIG_FILE"
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|status|dump}"
- exit 1
+ ;;
esac
-
-exit 0
+exit $RETVAL
diff --git a/etc/initd/initd.redhat b/etc/initd/initd.redhat
index 330023a..0d058c0 100644
--- a/etc/initd/initd.redhat
+++ b/etc/initd/initd.redhat
@@ -18,6 +18,7 @@ start()
{
echo -n $"Starting iSCSI initiator service: "
modprobe -q iscsi_tcp
+ modprobe -q ib_iser
daemon iscsid
RETVAL=$?
success
@@ -27,15 +28,7 @@ start()
touch /var/lock/subsys/open-iscsi
echo -n $"Setting up iSCSI targets: "
- TARGETS=`iscsiadm -m node 2>/dev/null | sed 's/ /@/g'`
- for node in $TARGETS; do
- target=`echo $node | cut -d@ -f2`
- port=`echo $node | cut -d@ -f1`
- STARTUP=`iscsiadm -m node -T $target -p $port | grep "node.conn\[0\].startup" | cut -d' ' -f3`
- if [ "$STARTUP" = "automatic" ]; then
- iscsiadm -m node -T $target -p $port -l
- fi
- done
+ iscsiadm -m node --loginall=automatic
success
echo
@@ -45,22 +38,13 @@ stop()
{
echo -n $"Stopping iSCSI initiator service: "
sync
- TARGETS=`iscsiadm -m session 2>/dev/null| sed 's/ /@/g'`
- if [ "$TARGETS" != "no@active@sessions" ] ; then
- for sess in $TARGETS; do
- target=`echo $sess | cut -d@ -f4`
- port=`echo $sess | cut -d@ -f3`
- STARTUP=`iscsiadm -m node -T $target -p $port | grep "node.conn\[0\].startup" | cut -d' ' -f3`
- if [ "$STARTUP" != "onboot" ] ; then
- iscsiadm -m node -T $target -p $port -u
- fi
- done
- fi
+ iscsiadm -m node --logoutall=automatic
pkill -KILL iscsid
rm -f /var/run/iscsid.pid
#killproc iscsid
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-iscsi
modprobe -r iscsi_tcp 2>/dev/null
+ modprobe -r ib_iser 2>/dev/null
success
echo
diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse
index 6d4cbd8..afc77f4 100644
--- a/etc/initd/initd.suse
+++ b/etc/initd/initd.suse
@@ -23,73 +23,42 @@ ARGS="-c $CONFIG_FILE -p $PID_FILE"
# Source LSB init functions
. /etc/rc.status
-. /etc/sysconfig/open-iscsi
-
# Reset status of this service
rc_reset
-iscsi_discovery()
-{
- $ISCSIADM -m discovery --type=$ISCSI_DISCOVERY --portal=$ISCSI_PORTAL > /dev/null
-}
-
iscsi_login_all_nodes()
{
- $ISCSIADM -m node 2> /dev/null | while read line; do
- set ${line}
- TARGET=$(echo $line | cut -d" " -f2)
- PORTAL=$(echo $line | cut -d"," -f1)
- STARTUP=`$ISCSIADM -m node --targetname $TARGET -p $PORTAL | grep "node.conn\[0\].startup" | cut -d' ' -f3`
- NODE=`$ISCSIADM -m node --targetname $TARGET -p $PORTAL | grep "node.name" | cut -d' ' -f3`
- if [ $STARTUP = "automatic" ] ; then
- echo -n "Logging into $NODE: "
- $ISCSIADM -m node --targetname $TARGET -p $PORTAL -l
- rc_status -v
- fi
- done
+ echo -n "Setting up iSCSI targets: "
+ $ISCSIADM -m node --loginall=automatic
+ rc_status -v
}
iscsi_logout_all_nodes()
{
- # Check for active sessions
- if $ISCSIADM -m session > /dev/null; then
- return 0
- fi
- # Logout from all active sessions
- $ISCSIADM -m session | while read line; do
- set ${line}
- TARGET=$(echo $line | cut -d" " -f4)
- PORTAL=$(echo $line | cut -d" " -f3 | sed 's/,.*//')
- STARTUP=`$ISCSIADM -m node --targetname $TARGET -p $PORTAL | grep "node.conn\[0\].startup" | cut -d' ' -f3`
- NODE=`$ISCSIADM -m node --targetname $TARGET -p $PORTAL | grep "node.name" | cut -d' ' -f3`
- if [ $STARTUP != "onboot" ] ; then
- echo -n "Logging out from $NODE: "
- if $ISCSIADM -m node --targetname $TARGET -p $PORTAL --logout ; then
+ # Logout from all active sessions
+ if $ISCSIADM -m node --logoutall=automatic ; then
rc_status -v
- else
+ else
RETVAL=$?
rc_failed $RETVAL
- fi
fi
- done
- # Not sure whether this is still needed
- sleep 1
- return ${RETVAL:-0}
+
+ # Not sure whether this is still needed
+ sleep 1
+ return ${RETVAL:-0}
}
iscsi_list_all_nodes()
{
- TARGETS=$($ISCSIADM -m session | sed 's@\[[^:]*:\(.*\)\] .*@\1@g')
- if [ "$TARGETS" != "no active sessions" ] ; then
- echo "Active connections:"
- $ISCSIADM -m session | while read line; do
- set ${line}
- TARGET=$(echo $line | cut -d" " -f4)
- PORTAL=$(echo $line | cut -d" " -f3 | sed 's/,.*//')
- NODE=`$ISCSIADM -m node --targetname $TARGET -p $PORTAL | grep "node.name" | cut -d' ' -f3`
- echo -e "\t$NODE"
- done
+ # Check for active sessions
+ if $ISCSIADM -m session > /dev/null; then
+ return 0
fi
+ echo "Active connections:"
+ $ISCSIADM -m session | while read proto num PORTAL TARGET ; do
+ PORTAL=${PORTAL%,*}
+ echo -e "\t$TARGET at $PORTAL"
+ done
}
case "$1" in