iscsi-initiator-utils/iscsi.init
katzj ae8f3d08fe * Tue Jun 20 2006 Jeremy Katz <katzj@redhat.com> - 6.0.5.595-1
- ensure that we respect %{optflags}
- cleaned up initscript to make use of standard functions, return right
  values and start by default
- build iscsistart as a static binary for use in initrds
2006-06-21 03:56:34 +00:00

87 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
#
# chkconfig: 345 13 89
# description: Starts and stops the iSCSI initiator
#
# processname: iscsid
# pidfile: /var/run/iscsid.pid
# config: /etc/iscsid.conf
# Source function library.
. /etc/init.d/functions
PATH=/sbin:/bin:/usr/sbin:/usr/bin
RETVAL=0
start()
{
echo -n $"Starting iSCSI initiator service: "
modprobe -q iscsi_tcp
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@\[\(.*\)\] .*@\1@g'`
for rec in $TARGETS; do
STARTUP=`iscsiadm -m node -r $rec | grep "node.startup" | cut -d' ' -f3`
if [ $STARTUP = "automatic" ]; then
iscsiadm -m node -r $rec -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 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