summaryrefslogtreecommitdiff
path: root/network/open-iscsi/rc.open-iscsi
diff options
context:
space:
mode:
authorWayne Cuddy <wcuddy@gmail.com>2019-01-24 08:00:06 +0700
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2019-01-24 08:00:06 +0700
commit2fac409655bbb5b1101976f0e2befb7779a5047e (patch)
treecc1bce084a6ea75a88a15f1d84648a581ad05d19 /network/open-iscsi/rc.open-iscsi
parentedbbdbf3cb82d8c5e165088ac32c3da069cdca38 (diff)
downloadslackbuilds-2fac409655bbb5b1101976f0e2befb7779a5047e.tar.gz
network/open-iscsi: Added (RFC3720 iSCSI Initiator).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network/open-iscsi/rc.open-iscsi')
-rw-r--r--network/open-iscsi/rc.open-iscsi76
1 files changed, 76 insertions, 0 deletions
diff --git a/network/open-iscsi/rc.open-iscsi b/network/open-iscsi/rc.open-iscsi
new file mode 100644
index 0000000000..5b18f60d2d
--- /dev/null
+++ b/network/open-iscsi/rc.open-iscsi
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+# Slackware rc.open-iscsi script, derived from init.debian in the
+# open-iscsi source package.
+
+DAEMON=/sbin/iscsid
+ADM=/sbin/iscsiadm
+PIDFILE=/var/run/iscsid.pid
+
+[ -e /etc/default/open-iscsi ] && . /etc/default/open-iscsi
+
+[ -x "$DAEMON" ] || exit 0
+
+if [ ! -d /sys/class/ ]
+then
+ echo "iSCSI requires a mounted sysfs, not started." >&2
+ exit 1
+fi
+
+start() {
+ echo "Starting iSCSI initiator service" "iscsid"
+ modprobe -q iscsi_tcp 2>/dev/null || :
+ modprobe -q ib_iser 2>/dev/null || :
+ $DAEMON $ARGS
+ sleep 1
+ starttargets
+}
+
+starttargets() {
+ echo "Setting up iSCSI targets"
+ $ADM -m node --loginall=automatic
+}
+
+stoptargets() {
+ echo "Disconnecting iSCSI targets"
+ sync
+ $ADM -m node --logoutall=all
+}
+
+stop() {
+ stoptargets
+ sleep 1
+ echo "Stopping iSCSI initiator service"
+ pkill -F $PIDFILE
+ rm -f $PIDFILE
+
+ modprobe -r iscsi_tcp
+ modprobe -r ib_iser
+}
+
+restart() {
+ stop
+ sleep 1
+ start
+}
+
+restarttargets() {
+ stoptargets
+ starttargets
+}
+
+status() {
+ echo "$(pgrep -c -F $PIDFILE -f $DAEMON) $DAEMON process(es) running"
+ echo "Current active iSCSI sessions:"
+ $ADM -m session
+}
+
+case "$1" in
+ start|starttargets|stop|stoptargets|restart|restarttargets|status)
+ $1
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+ ;;
+esac