97 lines
2.3 KiB
Bash
97 lines
2.3 KiB
Bash
#!/bin/sh
|
|
#
|
|
# runlevel script of the cryptobox package
|
|
#
|
|
# Copyright (c) 02006, senselab
|
|
#
|
|
# see LICENSE file in this package for details
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: cryptobox
|
|
# Required-Start: $network $local_fs $remote_fs
|
|
# Required-Stop: $network $local_fs $remote_fs
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: start CryptoBox webserver
|
|
### END INIT INFO
|
|
|
|
|
|
# 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 (check /etc/default/cryptobox)"
|
|
exit 0
|
|
fi
|
|
|
|
CBXSERVER=CryptoBoxWebserver.py
|
|
|
|
if test -e "./$CBXSERVER"
|
|
then CBXPATH=$(pwd)
|
|
else CBXPATH=/usr/lib/cryptobox
|
|
fi
|
|
|
|
PIDFILE=/var/run/cryptobox/webserver.pid
|
|
DAEMON=/usr/bin/python2.4
|
|
DAEMON_OPTS=$CBXPATH/$CBXSERVER
|
|
NAME=cryptoboxd
|
|
DESC="CryptoBox Daemon (webinterface)"
|
|
|
|
# check if the package is installed
|
|
test -e "$CBXPATH/$CBXSERVER" || exit 0
|
|
|
|
# include some useful functions to unify our output format
|
|
. /lib/lsb/init-functions
|
|
|
|
case "$1" in
|
|
start )
|
|
# TODO: mount config dir
|
|
# TODO: create certificate
|
|
# TODO: run stunnel
|
|
# the lines above should go into the live-cd scripts
|
|
test -e "$PIDFILE" && log_warning_msg "CryptoBox seems to running already (pid file exists) - we will try to start it anyway ..."
|
|
log_daemon_msg "Starting cryptobox webserver" "$DESC"
|
|
if start-stop-daemon \
|
|
--chdir "$CBXPATH" --chuid "$RUNAS" --quiet --start \
|
|
-oknodo --user "$RUNAS" --pidfile "$PIDFILE" \
|
|
--exec "$DAEMON" -- $DAEMON_OPTS
|
|
then log_end_msg 0
|
|
else log_end_msg 1
|
|
exit 1
|
|
fi
|
|
;;
|
|
stop )
|
|
if test ! -e "$PIDFILE"
|
|
then log_warning_msg "CryptoBox is not running (no pid file found)"
|
|
exit 0
|
|
fi
|
|
log_daemon_msg "Stopping cryptobox webserver" "$DESC"
|
|
if start-stop-daemon --quiet --stop --pidfile "$PIDFILE"
|
|
then rm "$PIDFILE"
|
|
log_end_msg 0
|
|
else log_end_msg 1
|
|
exit 1
|
|
fi
|
|
;;
|
|
reload | force-reload | restart )
|
|
"$0" stop
|
|
sleep 1
|
|
"$0" start
|
|
;;
|
|
* )
|
|
echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|
|
|