aboutsummaryrefslogtreecommitdiff
path: root/network/iscsitarget/rc.iscsi-target
diff options
context:
space:
mode:
Diffstat (limited to 'network/iscsitarget/rc.iscsi-target')
-rw-r--r--network/iscsitarget/rc.iscsi-target91
1 files changed, 91 insertions, 0 deletions
diff --git a/network/iscsitarget/rc.iscsi-target b/network/iscsitarget/rc.iscsi-target
new file mode 100644
index 000000000000..6fac6c7575b1
--- /dev/null
+++ b/network/iscsitarget/rc.iscsi-target
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+# Init script for the iSCSI Enterprise Target.
+# http://iscsitarget.sourceforge.net/
+
+# Written by Thales A. Tsailas For Slackware Linux
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+CONF=/etc/ietd.conf
+PID=$(pidof ietd)
+
+RETVAL=0
+
+start()
+{
+ # Load necessary modules
+ if [ ! "$PID" = '' ]; then
+ echo -en "iSCSI enterprise target is already running\n"
+ else
+ echo -en "Loading iSCSI enterprise target modules\n"
+ modprobe -q crc32c
+ modprobe iscsi_trgt
+ echo -en "Starting iSCSI enterprise target..."
+ /usr/sbin/ietd -c $CONF
+ sleep 1
+
+ if [ $RETVAL = "0" ]; then
+ echo -en "done.\n"
+ else
+ echo -en "failed.\n"
+ exit $RETVAL
+ fi
+ fi
+
+}
+
+stop()
+{
+ if [ "$PID" = '' ]; then
+ echo -en "iSCSI enterprise target is not running\n"
+ else
+ echo -en "Stoping iSCSI enterprise target...\n"
+ ietadm --op delete
+ kill -9 $PID
+ echo -en "Unloading iSCSI enterprise target modules"
+ modprobe -r iscsi_trgt
+ sleep 1
+ if [ $RETVAL = "0" ]; then
+ echo -en "done.\n"
+ else
+ echo -en "failed.\n"
+ exit $RETVAL
+ fi
+ fi
+
+
+}
+
+status()
+{
+ if [ "$PID" = '' ]; then
+ echo -en "iSCSI enterprise target is not running\n"
+ else
+ echo -en "iSCSI enterprise target is running with pid: \033[1m$PID\e[0m\n"
+ echo -en "Available targets:\n"
+ cat /proc/net/iet/session
+ fi
+
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ status)
+ status
+ ;;
+ *)
+ echo "Usage: {start|stop|restart|status}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0