initscript: added sample init.d script
authorDavid Adam (zanchey) <zanchey@ucc.gu.uwa.edu.au>
Thu, 15 Oct 2009 13:58:47 +0000 (21:58 +0800)
committerDavid Adam (zanchey) <zanchey@ucc.gu.uwa.edu.au>
Thu, 15 Oct 2009 13:58:47 +0000 (21:58 +0800)
initscript [new file with mode: 0755]

diff --git a/initscript b/initscript
new file mode 100755 (executable)
index 0000000..b6a2c7c
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          uccdoors
+# Required-Start:    $all
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start UCC door monitors at boot time
+# Description:       Enable UCC door hardware monitor and XMPP client.
+### END INIT INFO
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DESC="UCC door monitors"
+NAME=uccdoors
+BASEDIR=/home/ucc/door/uccdoor
+
+case "$1" in
+  start)
+       echo -n "Starting $DESC:"
+        echo -n " server"; start-stop-daemon --start --quiet --chuid door --background --pidfile /var/run/door-server.pid --make-pidfile --startas $BASEDIR/server.py
+        sleep 5
+        echo -n " client-xmpp"; start-stop-daemon --start --quiet --chuid door --background --pidfile /var/run/door-client-xmpp.pid --make-pidfile --startas $BASEDIR/client-xmpp.py
+       echo "."
+       ;;
+  stop)
+       echo -n "Stopping $DESC:"
+        echo -n " client-xmpp"; start-stop-daemon --stop --quiet --pidfile /var/run/door-client-xmpp.pid $BASEDIR/client-xmpp.py
+        sleep 2
+        echo -n " server"; start-stop-daemon --stop --quiet --pidfile /var/run/door-server.pid $BASEDIR/server.py
+       echo "."
+       ;;
+  restart|force-reload)
+       $0 stop
+       sleep 1
+       $0 start
+       ;;
+  *)
+       echo "Usage: $0 {start|stop|restart|force-reload}" >&2
+       exit 1
+       ;;
+esac

UCC git Repository :: git.ucc.asn.au