#!/bin/sh # # runlevel script of the cryptobox package # # Copyright (c) 02006, senselab # # see LICENSE file in this package for details # # read the default setting file, if it exists [ -e /etc/default/cryptobox ] && source /etc/default/cryptobox # startup switch defaults to zero (enabled) NO_START=${NO_START:-0} RUNAS=${RUNAS:-cryptobox} if [ "$NO_START" = "1" ] then [ $# -eq 0 ] && exit 0 [ "$1" = "status" ] && exit 1 [ "$1" = "stop" ] && exit 0 echo "CryptoBox is disabled by default" exit 0 fi CBXSERVER=CryptoBoxWebserver.py if test -e "./$CBXSERVER" then CBXPATH=$(pwd) else CBXPATH=/usr/lib/cryptobox fi PIDFILE=/var/run/cryptobox.pid DAEMON=/usr/bin/python2.4 DAEMON_OPTS=$CBXPATH/$CBXSERVER NAME=cryptoboxd DESC="CryptoBox Daemon (webinterface)" test -e "$CBXPATH/$CBXSERVER" || exit 0 case "$1" in start ) # TODO: mount config dir # TODO: create certificate # TODO: run stunnel # the lines above should go into the live-cd scripts echo -n "Starting $DESC: " start-stop-daemon --background --chdir "$CBXPATH" --chuid "$RUNAS" --start --quiet --user "$RUNAS" --make-pidfile --pidfile "$PIDFILE" --exec "$DAEMON" -- $DAEMON_OPTS echo "$NAME." ;; stop ) echo -n "Stopping $DESC: " # does the pid file exist? test ! -e "$PIDFILE" && echo "pid file ($PIDFILE) not found!" && exit 1 # kill all process with the parent pid that we saved before pkill -f -P "$(cat $PIDFILE)" -u "$RUNAS" && rm "$PIDFILE" echo "$NAME." ;; force-reload | restart ) "$0" stop "$0" start ;; * ) echo "invalid action specified - try { start | stop | restart }" >&2 exit 1 ;; esac