#!/bin/sh CBXSERVER=CryptoBoxWebserver.py if test -e "./$CBXSERVER" then CBXPATH=$(pwd) else CBXPATH=/usr/lib/cryptobox fi set -e case "$1" in start) 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." ;; restart ) "$0" stop "$0" start ;; *) echo "Usage: $(basename $0) {start|stop|restart}" >&2 exit 1 ;; esac exit 0