#!/bin/sh # # chkconfig: 345 7 89 # description: Starts and stops the iSCSI daemon. # # processname: iscsid # pidfile: /var/run/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 daemon: " modprobe -q iscsi_tcp modprobe -q ib_iser daemon iscsid RETVAL=$? echo [ $RETVAL -eq 0 ] || return touch /var/lock/subsys/iscsid success echo } stop() { rm -f /var/lock/subsys/iscsid # If this is a final shutdown/halt, do nothing since # we may need iscsid for as long as possible (halt script kills # us at the last second) if [ "$RUNLEVEL" = "6" -o "$RUNLEVEL" = "0" -o "$RUNLEVEL" = "1" ]; then success return fi # don't turn off iscsi if root is possibly on a iscsi disk rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab) if [[ "$rootopts" =~ "_netdev" ]] ; then echo $"Can not shutdown iSCSI. Root is on a iSCSI disk." exit 1 fi echo -n $"Stopping iSCSI daemon: " # iscsid does not have a nice shutdown process. # It really should never be stopped pkill -KILL iscsid echo 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/iscsid ] && restart ;; *) echo $"Usage: $0 {start|stop|restart|status|condrestart}" exit 1 esac exit $RETVAL