iscsi-initiator-utils/iscsi.init
2007-03-20 19:39:20 +00:00

99 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
#
# chkconfig: 345 13 89
# description: Starts and stops the iSCSI initiator
#
# processname: iscsid
# pidfile: /etc/iscsi/iscsid.pid
# config: /etc/iscsi/iscsid.conf
# Source function library.
. /etc/init.d/functions
PATH=/sbin:/bin:/usr/sbin:/usr/bin
RETVAL=0
start()
{
echo -n $"Turning off network shutdown."
# we do not want iscsi or network to run during system shutdown
# incase there are RAID or multipath devices using
# iscsi disks
chkconfig --level 06 network off
rm /etc/rc0.d/*network
rm /etc/rc6.d/*network
echo -n $"Starting iSCSI initiator service: "
modprobe -q iscsi_tcp
modprobe -q ib_iser
daemon iscsid
RETVAL=$?
echo
[ $RETVAL -eq 0 ] || return
touch /var/lock/subsys/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
success
echo
}
stop()
{
echo -n $"Stopping iSCSI initiator service: "
sync
# TARGETS=`iscsiadm -m session | grep "\[*\]" | sed 's@\[\(.*\)\] .*@\1@g'`
# for rec in $TARGETS; do
# iscsiadm -m node -r $rec -u
# done
killproc iscsid
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/iscsi
modprobe -r ib_iser 2>/dev/null
modprobe -r iscsi_tcp 2>/dev/null
}
restart()
{
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status iscsid
RETVAL=$?
;;
condrestart)
[ -f /var/lock/subsys/iscsi ] && restart
;;
*)
echo $"Usage: $0 {start|stop|restart|status|condrestart}"
exit 1
esac
exit $RETVAL