split tuer initscript in core services and status updater
[svn42.git] / tuer_status.initscript
diff --git a/tuer_status.initscript b/tuer_status.initscript
new file mode 100644 (file)
index 0000000..bad4806
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/sh
+# Start/stop the tuer status updater.
+#
+### BEGIN INIT INFO
+# Provides:          tuer_status
+# Required-Start:    $remote_fs $syslog $time $tuer_core
+# Required-Stop:     $remote_fs $syslog $time $tuer_core
+# Default-Start:     2 3 4 5
+# Default-Stop:      1
+### END INIT INFO
+
+EXE_UWEB=/flash/tuer/update-web-status.py
+EXE_XMPP=/flash/tuer/update-xmpp-status.py
+
+CFG_UWEB=/flash/tuer/update-web-status.cfg
+CFG_XMPP=/flash/tuer/update-xmpp-status.cfg
+
+. /etc/default/tuer
+
+PIDFILE_UWEB=${DIR_RUN}/update-web-status.pid
+PIDFILE_XMPP=${DIR_RUN}/update-xmpp-status.pid
+
+test -f $EXE_UWEB  || exit 1
+test -f $EXE_XMPP  || exit 1
+if [ ! -d $DIR_RUN ]; then
+       mkdir -p $DIR_RUN || exit 2
+       chown -R $DOOR_USR:$DOOR_GRP $DIR_RUN
+fi
+
+. /lib/lsb/init-functions
+
+# Read the system's locale and set cron's locale. This locale
+# will be inherited by cron (used to set charset of emails)
+# and tasks running under it.
+
+case "$1" in
+start) 
+       log_daemon_msg "Starting door daemon" "update-web-status"
+        start-stop-daemon --start --quiet --pidfile $PIDFILE_UWEB -b -m -c $DOOR_USR --name update-web-status.py --startas $EXE_UWEB  -- $DOOR_SOCKET $CFG_UWEB
+        log_end_msg $? 
+       log_daemon_msg "Starting door daemon" "update-xmpp-status"
+        start-stop-daemon --start --quiet --pidfile $PIDFILE_XMPP -b -m -c $DOOR_USR --name update-xmpp-status.py --startas $EXE_XMPP  -- $DOOR_SOCKET $CFG_XMPP
+        log_end_msg $? 
+       ;;
+stop)
+       log_daemon_msg "Stopping door daemon" "update-web-status"
+        start-stop-daemon --stop --quiet --pidfile $PIDFILE_UWEB -m --retry TERM/1/TERM/1/KILL 
+        log_end_msg $? 
+       log_daemon_msg "Stopping door daemon" "update-xmpp-status"
+        start-stop-daemon --stop --quiet --pidfile $PIDFILE_XMPP -m --retry TERM/1/TERM/1/KILL 
+        log_end_msg $? 
+        ;;
+restart) 
+       $0 stop
+       $0 start
+        ;;
+*)     log_action_msg "Usage: $0 {start|stop|restart|reload|force-reload}"
+        exit 2
+        ;;
+esac
+exit 0