78 lines
1.3 KiB
Bash
Executable File
78 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# chkconfig: - 13 89
|
|
# description: Logs into iSCSI targets needed at system startup
|
|
#
|
|
# Source function library.
|
|
. /etc/init.d/functions
|
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
|
RETVAL=0
|
|
|
|
start()
|
|
{
|
|
|
|
status iscsid
|
|
RETVAL=$?
|
|
|
|
if [ $RETVAL -ne 0 ]; then
|
|
/etc/init.d/iscsid start
|
|
fi
|
|
|
|
echo -n $"Setting up iSCSI targets: "
|
|
# this script is normally called from startup so log into
|
|
# nodes marked node.startup=automatic
|
|
iscsiadm -m node --loginall=automatic
|
|
touch /var/lock/subsys/iscsi
|
|
success
|
|
echo
|
|
}
|
|
|
|
stop()
|
|
{
|
|
rm -f /var/lock/subsys/iscsi
|
|
|
|
# If this is a final shutdown/halt, do nothing since
|
|
# lvm/dm, md, power path, etc do not always handle this
|
|
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
|
|
|
|
iscsiadm -m node --logoutall=all
|
|
/etc/init.d/iscsid stop
|
|
success
|
|
}
|
|
|
|
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
|