working init.d/defaults scripts
authorTero Marttila <terom@fixme.fi>
Wed, 17 Sep 2008 20:30:54 +0300
changeset 26 a7f74dd6d4e5
parent 25 6c0a53a512d8
child 27 bce1f781f127
working init.d/defaults scripts
docs/example-defaults-script
docs/example-init.d-script
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/example-defaults-script	Wed Sep 17 20:30:54 2008 +0300
@@ -0,0 +1,20 @@
+
+
+# what the CWD should be
+RUN_DIR=/home/terom/projects/FixBot
+
+# what user to run as
+RUN_UID=fixbot-dev
+
+# common options
+OPTIONS="--api-port=34889"
+
+# nexus's options
+NEXUS_OPTIONS="$OPTIONS --irc-nickname=FixBotDev --irc-channel=#fixme-test"
+
+# logwatch's options
+LOGWATCH_OPTIONS="$OPTIONS"
+
+# plugins/moduels are loaded from RUN_DIR
+export "PYTHONPATH=$RUN_DIR"
+
--- a/docs/example-init.d-script	Wed Sep 17 19:28:42 2008 +0300
+++ b/docs/example-init.d-script	Wed Sep 17 20:30:54 2008 +0300
@@ -3,9 +3,13 @@
 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
 
+RUN_DIR=/var/lib/fixbot/
+RUN_UID=nobody RUN_GID=nogroup
+NEXUS_OPTIONS=
+LOGWATCH_OPTIONS=
+
 args_nexus= args_logwatch=
 
 [ -r /etc/default/fixbot ] && . /etc/default/fixbot
@@ -13,38 +17,43 @@
 case "$1" in
     start)
         echo "Starting fixbot:"
-        echo -n "\tnexus... "
+        echo -n "   nexus... "
 
-        start-stop-daemon --start --quiet --exec /usr/bin/twistd \
+        start-stop-daemon --start --quiet --exec /usr/bin/twistd -- \
+            --uid="$RUN_UID"                \
+            --gid="$RUN_GID"                \
             --pidfile="$pidfile_nexus"      \
-            --rundir="$rundir"              \
+            --rundir="$RUN_DIR"             \
             --logfile="$logfile_nexus"      \
             fixbot_nexus                    \
-            $args_nexus                     \
+            $NEXUS_OPTIONS                  \
         && echo "[OK]" || echo "[FAIL]"
         
-        echo -n "\tlogwatch... "
+        echo -n "   logwatch... "
 
-        start-stop-daemon --start --quiet --exec /usr/bin/twistd \
+        start-stop-daemon --start --quiet --exec /usr/bin/twistd -- \
+            --uid="$RUN_UID"                \
+            --gid="$RUN_GID"                \
             --pidfile="$pidfile_logwatch"   \
-            --rundir="$rundir"              \
+            --rundir="$RUN_DIR"             \
             --logfile="$logfile_logwatch"   \
             fixbot_logwatch                 \
-            $args_logwatch                  \
+            $LOGWATCH_OPTIONS               \
         && echo "[OK]" || echo "[FAIL]"
     ;;
 
     stop)
-        echo -n "Stopping fixbot:"
+        echo -n "Stopping fixbot:   "
         
-        echo "logwatch... "	
+        echo -n "logwatch...    "	
         start-stop-daemon --stop --quiet    \
             --pidfile "$pidfile_logwatch"
 
-        echo "nexus... "
+        echo -n "nexus...   "
         start-stop-daemon --stop --quiet    \
             --pidfile "$pidfile_nexus"
-
+        
+        echo "done"
     ;;
 
     restart)