From 4d692453cd1a04ae07af7f0f0ff2ba2bea9f6878 Mon Sep 17 00:00:00 2001 From: lars Date: Tue, 31 Oct 2006 18:40:11 +0000 Subject: [PATCH] improved init.d file --- pythonrewrite/bin/cryptoboxd | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pythonrewrite/bin/cryptoboxd b/pythonrewrite/bin/cryptoboxd index f183e60..85258bd 100755 --- a/pythonrewrite/bin/cryptoboxd +++ b/pythonrewrite/bin/cryptoboxd @@ -1,11 +1,15 @@ #!/bin/sh -CBXPATH="/home/age/svn/cryptobox/branches/pythonrewrite/bin/" -CBXSERVER="CryptoBoxWebserver.py" -DAEMON="/usr/bin/python2.4 ${CBXPATH}CryptoBoxWebserver.py" +#TODO: CBXPATH=/usr/lib/cryptobox +CBXPATH=$(pwd) +CBXSERVER=CryptoBoxWebserver.py +PIDFILE=/var/run/cryptobox.pid +DAEMON=/usr/bin/python2.4 +DAEMON_OPTS=${CBXPATH}/CryptoBoxWebserver.py NAME=cryptoboxd DESC="CryptoBox Daemon (webinterface)" -RUNAS=age +#TODO: RUNAS=cryptobox +RUNAS=$USERNAME #test -x $DAEMON -a -f /etc/exports || exit 0 @@ -14,19 +18,20 @@ set -e case "$1" in start) echo -n "Starting $DESC: " - start-stop-daemon --background --chdir $CBXPATH --chuid $RUNAS --start --quiet --oknodo --exec $DAEMON \ + start-stop-daemon --background --chdir "$CBXPATH" --chuid "$RUNAS" --start --quiet --oknodo --user "$RUNAS" --make-pidfile --pidfile "$PIDFILE" --exec "$DAEMON" \ -- $DAEMON_OPTS echo "$NAME." ;; stop) echo -n "Stopping $DESC: " - start-stop-daemon --stop --oknodo --exec $DAEMON + #FIXME: this is the same as "killall python2.4" + # using a pid file instead prevents problems, but does not kill children??? + start-stop-daemon --stop --oknodo --exec "$DAEMON" echo "$NAME." ;; *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop}" >&2 + echo "Usage: $(basename $0) {start|stop}" >&2 exit 1 ;; esac