aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support/tgt/files/tgtd.init
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openstack/recipes-support/tgt/files/tgtd.init')
-rw-r--r--meta-openstack/recipes-support/tgt/files/tgtd.init61
1 files changed, 61 insertions, 0 deletions
diff --git a/meta-openstack/recipes-support/tgt/files/tgtd.init b/meta-openstack/recipes-support/tgt/files/tgtd.init
new file mode 100644
index 00000000..656a2437
--- /dev/null
+++ b/meta-openstack/recipes-support/tgt/files/tgtd.init
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+DESC="tgtd"
+DAEMON="/usr/sbin/tgtd"
+PIDFILE="/var/run/tgtd.pid"
+
+start ()
+{
+ if [ -e $PIDFILE ]; then
+ PIDDIR=/proc/$(cat $PIDFILE)
+ if [ -d ${PIDDIR} ]; then
+ echo "$DESC already running."
+ exit 1
+ else
+ echo "Removing stale PID file $PIDFILE"
+ rm -f $PIDFILE
+ fi
+ fi
+
+ echo -n "Starting $DESC..."
+
+ start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
+ --make-pidfile --exec ${DAEMON}
+
+ if [ $? -eq 0 ]; then
+ echo "done."
+ else
+ echo "failed."
+ fi
+}
+
+stop ()
+{
+ echo -n "Stopping $DESC..."
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE
+ if [ $? -eq 0 ]; then
+ echo "done."
+ else
+ echo "failed."
+ fi
+ rm -f $PIDFILE
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart|force-reload)
+ stop
+ start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|force-reload|restart}"
+ exit 1
+ ;;
+esac
+
+exit 0