From 097e184d83ff319503c32ed42a48376236e8e5b7 Mon Sep 17 00:00:00 2001 From: realraum Date: Fri, 30 Jul 2010 04:02:04 +0000 Subject: [PATCH] initscripts --- tuer_actions.initscript | 62 ++++++++++++++++++++++++++++++++++++++++++++++ tuer_presence.initscript | 50 +++++++++++++++++++++++++++++++++++++ tuer_status.initscript | 36 ++------------------------- 3 files changed, 114 insertions(+), 34 deletions(-) create mode 100755 tuer_actions.initscript create mode 100755 tuer_presence.initscript diff --git a/tuer_actions.initscript b/tuer_actions.initscript new file mode 100755 index 0000000..cc353be --- /dev/null +++ b/tuer_actions.initscript @@ -0,0 +1,62 @@ +#!/bin/sh +# Start/stop the tuer status updater. +# +### BEGIN INIT INFO +# Provides: tuer_actions +# Required-Start: $remote_fs $syslog $time $tuer_core $tuer_presence +# Required-Stop: $remote_fs $syslog $time $tuer_core $tuer_presence +# Default-Start: 2 3 4 5 +# Default-Stop: 1 +### END INIT INFO + +EXE_SWITCH=/flash/tuer/switch-power.py +EXE_SOUND=/flash/tuer/play-sound-status.py + +CFG_SWITCH=/flash/tuer/switch-power.cfg +CFG_SOUND=/flash/tuer/play-sound-status.cfg + +. /etc/default/tuer + +PIDFILE_SWITCH=${DIR_RUN}/switch-power.pid +PIDFILE_SOUND=${DIR_RUN}/play-sound-status.pid + +test -f $EXE_SWITCH || exit 1 +test -f $EXE_SOUND || 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" "switch-power" + start-stop-daemon --start --quiet --pidfile $PIDFILE_SWITCH -b -m -c $DOOR_USR --name update-xmpp-status.py --startas $EXE_SWITCH -- $CFG_SWITCH + log_end_msg $? + log_daemon_msg "Starting door daemon" "play-sound" + start-stop-daemon --start --quiet --pidfile $PIDFILE_SOUND -b -m -c $DOOR_USR --name update-xmpp-status.py --startas $EXE_SOUND -- $CFG_SOUND + log_end_msg $? + ;; +stop) + log_daemon_msg "Stopping door daemon" "switch-power" + start-stop-daemon --stop --quiet --pidfile $PIDFILE_SWITCH -m --retry TERM/1/TERM/1/KILL + log_end_msg $? + sleep 1 + log_daemon_msg "Stopping door daemon" "play-sound" + start-stop-daemon --stop --quiet --pidfile $PIDFILE_SOUND -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 diff --git a/tuer_presence.initscript b/tuer_presence.initscript new file mode 100755 index 0000000..d7be2ea --- /dev/null +++ b/tuer_presence.initscript @@ -0,0 +1,50 @@ +#!/bin/sh +# Start/stop the tuer status updater. +# +### BEGIN INIT INFO +# Provides: tuer_presence +# 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_TRACK=/flash/tuer/track-presence.py + +CFG_TRACK=/flash/tuer/track-presence.cfg + +. /etc/default/tuer + +PIDFILE_TRACK=${DIR_RUN}/track-presence.pid +test -f $EXE_TRACK || 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" "track-presence" + start-stop-daemon --start --quiet --pidfile $PIDFILE_TRACK -b -m -c $DOOR_USR --name track-presence.py --startas $EXE_TRACK -- $CFG_TRACK + log_end_msg $? + ;; +stop) + log_daemon_msg "Stopping door daemon" "track-presence" + start-stop-daemon --stop --quiet --pidfile $PIDFILE_TRACK -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 diff --git a/tuer_status.initscript b/tuer_status.initscript index 5c1566c..f3b055a 100755 --- a/tuer_status.initscript +++ b/tuer_status.initscript @@ -3,37 +3,25 @@ # ### BEGIN INIT INFO # Provides: tuer_status -# Required-Start: $remote_fs $syslog $time $tuer_core -# Required-Stop: $remote_fs $syslog $time $tuer_core +# Required-Start: $remote_fs $syslog $time $tuer_core $tuer_presence +# Required-Stop: $remote_fs $syslog $time $tuer_core $tuer_presence # Default-Start: 2 3 4 5 # Default-Stop: 1 ### END INIT INFO -EXE_TRACK=/flash/tuer/track-presence.py EXE_UWEB=/flash/tuer/update-web-status.py EXE_XMPP=/flash/tuer/update-xmpp-status.py -EXE_SWITCH=/flash/tuer/switch-power.py -EXE_SOUND=/flash/tuer/play-sound-status.py -CFG_TRACK=/flash/tuer/track-presence.cfg CFG_UWEB=/flash/tuer/update-web-status.cfg CFG_XMPP=/flash/tuer/update-xmpp-status.cfg -CFG_SWITCH=/flash/tuer/switch-power.cfg -CFG_SOUND=/flash/tuer/play-sound-status.cfg . /etc/default/tuer -PIDFILE_TRACK=${DIR_RUN}/track-presence.pid PIDFILE_UWEB=${DIR_RUN}/update-web-status.pid PIDFILE_XMPP=${DIR_RUN}/update-xmpp-status.pid -PIDFILE_SWITCH=${DIR_RUN}/switch-power.pid -PIDFILE_SOUND=${DIR_RUN}/play-sound-status.pid -test -f $EXE_TRACK || exit 1 test -f $EXE_UWEB || exit 1 test -f $EXE_XMPP || exit 1 -test -f $EXE_SWITCH || exit 1 -test -f $EXE_SOUND || exit 1 if [ ! -d $DIR_RUN ]; then mkdir -p $DIR_RUN || exit 2 chown -R $DOOR_USR:$DOOR_GRP $DIR_RUN @@ -47,21 +35,12 @@ fi case "$1" in start) - log_daemon_msg "Starting door daemon" "track-presence" - start-stop-daemon --start --quiet --pidfile $PIDFILE_TRACK -b -m -c $DOOR_USR --name track-presence.py --startas $EXE_TRACK -- $CFG_TRACK - log_end_msg $? 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 -- $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 -- $CFG_XMPP log_end_msg $? - log_daemon_msg "Starting door daemon" "switch-power" - start-stop-daemon --start --quiet --pidfile $PIDFILE_SWITCH -b -m -c $DOOR_USR --name update-xmpp-status.py --startas $EXE_SWITCH -- $CFG_SWITCH - log_end_msg $? - log_daemon_msg "Starting door daemon" "play-sound" - start-stop-daemon --start --quiet --pidfile $PIDFILE_SOUND -b -m -c $DOOR_USR --name update-xmpp-status.py --startas $EXE_SOUND -- $CFG_SOUND - log_end_msg $? ;; stop) log_daemon_msg "Stopping door daemon" "update-web-status" @@ -70,17 +49,6 @@ stop) 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 $? - log_daemon_msg "Stopping door daemon" "switch-power" - start-stop-daemon --stop --quiet --pidfile $PIDFILE_SWITCH -m --retry TERM/1/TERM/1/KILL - log_end_msg $? - sleep 1 - log_daemon_msg "Stopping door daemon" "play-sound" - start-stop-daemon --stop --quiet --pidfile $PIDFILE_SOUND -m --retry TERM/1/TERM/1/KILL - log_end_msg $? - sleep 1 - log_daemon_msg "Stopping door daemon" "track-presence" - start-stop-daemon --stop --quiet --pidfile $PIDFILE_TRACK -m --retry TERM/1/TERM/1/KILL - log_end_msg $? ;; restart) $0 stop -- 1.7.10.4