summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Dewender <github@JonnyJD.net>2013-10-26 17:45:50 +0200
committerJohannes Dewender <github@JonnyJD.net>2013-10-26 19:18:25 +0200
commitc0caf838e0d21301c5ae8d519bcea5659662383f (patch)
tree57140f34ac8dce06bec7475457f8d8f8db6be0a9
parente1c4628c4d05e3c0f533f8edccbc9229f2bf93da (diff)
downloadtargetcli-c0caf838e0d21301c5ae8d519bcea5659662383f.tar.gz
debian: add init script
Signed-off-by: Johannes Dewender <github@JonnyJD.net>
-rw-r--r--debian/control2
-rwxr-xr-xdebian/rules3
-rw-r--r--debian/target.init54
-rw-r--r--debian/targetcli-fb.prerm4
4 files changed, 62 insertions, 1 deletions
diff --git a/debian/control b/debian/control
index ead2073..1c93204 100644
--- a/debian/control
+++ b/debian/control
@@ -10,7 +10,7 @@ Package: targetcli-fb
Architecture: all
Depends: ${python:Depends}, ${misc:Depends}, python-configshell-fb, python-rtslib-fb
Suggests: targetcli-fb-doc
-Conflicts: targetcli, targetcli-frozen
+Conflicts: targetcli, targetcli-frozen, lio-utils
Description: CLI shell for the RisingTide Systems target (free branch).
.
This package contains the targetcli CLI.
diff --git a/debian/rules b/debian/rules
index 0287663..ac0a879 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,6 +11,9 @@ export http_proxy = http://127.0.0.1:9
%:
dh $@ --with python2
+override_dh_installinit:
+ dh_installinit --name target
+
override_dh_auto_clean:
dh_auto_clean
rm -rf build
diff --git a/debian/target.init b/debian/target.init
new file mode 100644
index 0000000..6d9fe3b
--- /dev/null
+++ b/debian/target.init
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+### BEGIN INIT INFO
+# Provides: target
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Required-Start: $local_fs $network
+# Required-Stop: $local_fs $network
+# Short-Description: Start LIO targets
+# Description: Loads configfs and restores LIO config with targetcli
+### END INIT INFO
+
+
+case "$1" in
+ start)
+ if [ ! -d /sys/kernel/config ]; then
+ echo "Mounting configfs"
+ modprobe configfs
+ mount -t configfs configfs /sys/kernel/config
+ if [ $? != 0 ]; then
+ exit 1
+ fi
+ fi
+ echo "Starting lio targets"
+ /usr/bin/targetcli restoreconfig clear_existing=true
+ if [[ $? -gt 0 ]]; then
+ exit 1
+ fi
+ ;;
+
+ stop)
+ echo "Stopping lio targets"
+ /usr/bin/targetcli clearconfig confirm=true
+ if [[ $? -gt 0 ]]; then
+ exit 1
+ fi
+ ;;
+
+ restart|force-reload)
+ $0 stop
+ sleep 3
+ $0 start
+ ;;
+
+ status)
+ echo "Checking status of lio targets";
+ /usr/bin/targetcli sessions
+ ;;
+
+ *)
+ echo "usage: $0 {start|stop|restart|force-reload|status}"
+esac
+
+exit 0
diff --git a/debian/targetcli-fb.prerm b/debian/targetcli-fb.prerm
new file mode 100644
index 0000000..8fe902f
--- /dev/null
+++ b/debian/targetcli-fb.prerm
@@ -0,0 +1,4 @@
+# manual cleanup
+# debhelpers uses targetcli again to stop the service after cleanup
+# so we have to clean again
+rm -rf /usr/lib/python*/dist-packages/targetcli/*.pyc