From 33bf244e897459a570b6ff2d7ea0694c67b14f3a Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Thu, 26 Sep 2013 17:19:40 +0000 Subject: [PATCH] initscripts --- tuer_cardidlookup.initscript | 52 ++++++++++++++++++++++++++++++++++++++++++ tuer_core.initscript | 35 +++++++++------------------- 2 files changed, 63 insertions(+), 24 deletions(-) create mode 100755 tuer_cardidlookup.initscript diff --git a/tuer_cardidlookup.initscript b/tuer_cardidlookup.initscript new file mode 100755 index 0000000..6dd274b --- /dev/null +++ b/tuer_cardidlookup.initscript @@ -0,0 +1,52 @@ +#!/bin/sh +# Start/stop the tuer daemon core. +# +### BEGIN INIT INFO +# Provides: tuer_cardidlookup +# Required-Start: $remote_fs $syslog $time +# Required-Stop: $remote_fs $syslog $time +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +### END INIT INFO + +EXE_KEYLOOKUP=/flash/tuer/door_nick_lookup_zmq +DOOR_DEV=/dev/door + +. /etc/default/tuer + +PIDFILE_KEYLOOKUP=${DIR_RUN}/door_nick_lookup_server.pid + +test -e $EXE_KEYLOOKUP || exit 1 +if [ ! -d $DIR_RUN ]; then + mkdir -p $DIR_RUN || exit 2 + chown -R $DOOR_USR:$DOOR_GRP $DIR_RUN +fi +chown $DOOR_USR:$DOOR_GRP $DOOR_DEV + +. /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 CardID Lookup Server" "door_nick_lookup_zmq" + start-stop-daemon --start --quiet --pidfile $PIDFILE_KEYLOOKUP -c $DOOR_USR -m -g $DOOR_GRP -b --name door_nick_lookup_zmq --startas $EXE_KEYLOOKUP -- --server + log_end_msg $? + ;; +stop) + log_daemon_msg "Stopping CardID Lookup Server" "door_nick_lookup_zmq" + start-stop-daemon --stop --quiet --pidfile $PIDFILE_KEYLOOKUP -m --name door_nick_lookup_zmq + 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_core.initscript b/tuer_core.initscript index b2d875a..34dd4f5 100755 --- a/tuer_core.initscript +++ b/tuer_core.initscript @@ -9,19 +9,14 @@ # Default-Stop: 0 1 6 ### END INIT INFO -EXE_DOOR=/flash/tuer/door_daemon -EXE_CARD=/flash/tuer/checkcard.pl - -DOOR_LOG="--log syslog:3,door_daemon,local1" +EXE_DOOR=/flash/tuer/door_daemon_zmq DOOR_DEV=/dev/door . /etc/default/tuer PIDFILE_DOOR=${DIR_RUN}/door_daemon.pid -PIDFILE_CARD=${DIR_RUN}/checkcard.pid -test -f $EXE_DOOR || exit 1 -test -f $EXE_CARD || exit 1 +test -e $EXE_DOOR || exit 1 if [ ! -d $DIR_RUN ]; then mkdir -p $DIR_RUN || exit 2 chown -R $DOOR_USR:$DOOR_GRP $DIR_RUN @@ -35,25 +30,17 @@ chown $DOOR_USR:$DOOR_GRP $DOOR_DEV # and tasks running under it. case "$1" in -start) - log_daemon_msg "Starting door daemon" "door_daemon" - start-stop-daemon --start --quiet --pidfile $PIDFILE_DOOR --name door_daemon --startas $EXE_DOOR -- -d $DOOR_DEV -s $DOOR_SOCKET -u $DOOR_USR -g $DOOR_GRP -P $PIDFILE_DOOR $DOOR_LOG - log_end_msg $? - log_daemon_msg "Starting door daemon" "checkcard" - #start-stop-daemon --start --quiet --pidfile $PIDFILE_CARD -b -m --name checkcard.pl --startas $EXE_CARD -- $DOOR_SOCKET - start-stop-daemon --start --quiet --pidfile $PIDFILE_CARD -c $DOOR_USR -b -m --name checkcard.pl --startas $EXE_CARD -- $DOOR_SOCKET - log_end_msg $? - ;; +start) + log_daemon_msg "Starting door daemon" "door_daemon_zmq" + start-stop-daemon --start --quiet --pidfile $PIDFILE_DOOR -c $DOOR_USR -m -g $DOOR_GRP -b --name door_daemon_zmq --startas $EXE_DOOR -- --device $DOOR_DEV --cmdport "$DOOR_SOCKET" --syslog + log_end_msg $? + ;; stop) - log_daemon_msg "Stopping door daemon" "door_daemon" - start-stop-daemon --stop --quiet --pidfile $PIDFILE_DOOR -m --name door_daemon - log_end_msg $? - log_daemon_msg "Stopping door daemon" "checkcard" - start-stop-daemon --stop --quiet --pidfile $PIDFILE_CARD -m --name checkcard.pl - log_end_msg $? - killall "mifare-read" 2>/dev/null + log_daemon_msg "Stopping door daemon" "door_daemon_zmq" + start-stop-daemon --stop --quiet --pidfile $PIDFILE_DOOR -m --name door_daemon_zmq + log_end_msg $? ;; -restart) +restart) $0 stop $0 start ;; -- 1.7.10.4