Blame | Last modification | View Log | RSS feed
#!/bin/sh## iscsid iSCSI daemon## chkconfig: 345 7 89# description: Starts and stops the iSCSI daemon.## processname: iscsid# pidfile: /var/run/iscsid.pid# config: /etc/iscsi/iscsid.conf### BEGIN INIT INFO# Provides: iscsid# Default-Start: 3 4 5# Default-Stop: 0 1 2 6# Short-Description: Starts and stops login iSCSI daemon.# Description: iscsid provides the iSCSI session and connection state machine# for software iscsi/iser (iscsi_tcp/ib_iser) and partialy# offloaded hardware (bnx2i).### END INIT INFO# Source function library.. /etc/rc.d/init.d/functionsexec=/sbin/iscsidprog=iscsidconfig=/etc/iscsi/iscsid.conflockfile=/var/lock/subsys/$progiscsi_lockfile=/var/lock/subsys/iscsi# FIXME this has a false positive for root on nfsroot_is_iscsi() {rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab)[[ "$rootopts" =~ "_netdev" ]]}start_iscsid() {echo -n $"Starting $prog: "modprobe -q iscsi_tcpmodprobe -q ib_isermodprobe -q cxgb3imodprobe -q cxgb4imodprobe -q bnx2imodprobe -q be2iscsidaemon iscsiuiodaemon $progretval=$?echotouch $lockfile}force_start() {start_iscsid# a force start could imply the iscsi service is started due to how it# lazy starts. We need to touch the lock file so it is shutdown latertouch $iscsi_lockfile}use_discoveryd() {grep -qrs "discovery.sendtargets.use_discoveryd = Yes" /var/lib/iscsi/send_targetsif [ $? -eq 0 ] ; thenreturn 0figrep -qrs "discovery.isns.use_discoveryd = Yes" /var/lib/iscsi/isnsif [ $? -eq 0 ] ; thenreturn 0fireturn 1}start() {[ -x $exec ] || exit 5[ -f $config ] || exit 6# only start if nodes are setup to startup automatically, root is iscsi,# or if iscsid is managing the sessions.grep -qrs "node.startup = automatic" /var/lib/iscsi/nodesif [ $? -eq 0 ] || root_is_iscsi || use_discoveryd ; thenstart_iscsidreturn $?fireturn 0}stop() {if use_discoveryd ; theniscsiadm -k 0 2>/dev/nullfideclare -a iparams=( $(iscsiadm -m session 2>/dev/null | egrep "tcp|iser|bnx2i|cxgb3i|cxgb4i|be2iscsi") )if [[ -n "${iparams[*]}" ]]; then# We have active sessions, so don't stop iscsid!!echo -n $"Not stopping $prog: iscsi sessions still active"warning $"Not stopping $prog: iscsi sessions still active"echoreturn 0fiecho -n $"Stopping $prog: "iscsiadm -k 0 2>/dev/nullechokillproc iscsiuiorm -f /var/run/iscsiuio.pid# only remove the iscsi drivers when offload is usedrmmod bnx2i 2>/dev/nullrmmod cnic 2>/dev/nullrmmod cxgb3i 2>/dev/nullrmmod cxgb4i 2>/dev/null# a bug in kobject netlink code will cause this to oops# modprobe -r be2iscsi 2>/dev/nullmodprobe -r ib_iser 2>/dev/nullmodprobe -r iscsi_tcp 2>/dev/nullrm -f $lockfilereturn 0}rh_status_q() {rh_status >/dev/null 2>&1}restart() {rh_status_quse_force_start=$?stop# if iscsid was running then make sure it starts upif [ "$use_force_start" -eq 0 ] ; thenstart_iscsidelsestartfi}reload() {return 3}force_reload() {restart}rh_status() {status $prog}case "$1" instart)rh_status_q && exit 0$1;;force-start)force_start;;stop)rh_status_q || exit 0$1;;restart)$1;;reload)rh_status_q || exit 7$1;;force-reload)force_reload;;status)rh_status;;condrestart|try-restart)rh_status_q || exit 0restart;;*)echo $"Usage: $0{start|stop|status|restart|condrestart|try-restart|reload|force-reload}"exit 2esacexit $?