example init.d script
authorterom@fixme.fi
Mon, 15 Sep 2008 01:06:00 +0300
changeset 24 0cdbd2735993
parent 23 67e71e9170e5
child 25 6c0a53a512d8
example init.d script
docs/example-init.d-script
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/example-init.d-script	Mon Sep 15 01:06:00 2008 +0300
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+pidfile_nexus=/var/run/fixbot_nexus.pid pidfile_logwatch=/var/run/fixbot_logwatch.pid
+rundir=/var/lib/fixbot/
+logfile_nexus=/var/log/fixbot_nexus.log logfile_logwatch=/var/log/fixbot_logwatch.log
+
+args_nexus= args_logwatch=
+
+[ -r /etc/default/fixbot ] && . /etc/default/fixbot
+
+case "$1" in
+    start)
+        echo "Starting fixbot:"
+        echo -n "\tnexus... "
+
+        start-stop-daemon --start --quiet --exec /usr/bin/twistd \
+            --pidfile=$pidfile_nexus        \
+            --rundir=$rundir                \
+            --logfile=$logfile_nexus        \
+            nexus                           \
+            $args_nexus                     \
+        && echo "[OK]" || echo "[FAIL]"
+        
+        echo -n "\tlogwatch... "
+
+        start-stop-daemon --start --quiet --exec /usr/bin/twistd \
+            --pidfile=$pidfile_logwatch     \
+            --rundir=$rundir                \
+            --logfile=$logfile_logwatch     \
+            logwatch                        \
+            $args_logwatch                  \
+        && echo "[OK]" || echo "[FAIL]"
+    ;;
+
+    stop)
+        echo -n "Stopping fixbot:"
+        
+        echo "logwatch... "	
+        start-stop-daemon --stop --quiet              --pidfile $pidfile_logwatch
+
+        echo "nexus... "
+        start-stop-daemon --stop --quiet              --pidfile $pidfile_nexus
+
+    ;;
+
+    restart)
+        $0 stop
+        $0 start
+    ;;
+
+    force-reload)
+        $0 restart
+    ;;
+
+    *)
+        echo "Usage: /etc/init.d/fixbot {start|stop|restart|force-reload}" >&2
+        exit 1
+    ;;
+esac
+
+exit 0