#!/bin/sh set -eu # # we give some hints for users, sitting in front of the cryptobox waiting for a login prompt # # check if the cryptobox is installed [ -e "/usr/lib/cryptobox/cbox-manage.sh" ] || exit 0 # read the default setting file, if it exists [ -e /etc/default/cryptobox ] && . /etc/default/cryptobox # startup switch defaults to zero (enabled) NO_START=${NO_START:-0} # check startup switch [ "$NO_START" = "1" ] && echo "CryptoBox is disabled" && exit 0 # stop-on-errors set -eu # set CONF_FILE to default value, if not configured in /etc/default/cryptobox CONF_FILE=${CONF_FILE:-/etc/cryptobox/cryptobox.conf} # parse config file if [ -e "$CONF_FILE" ] then echo "[$(basename $0)] - configuration file ($CONF_FILE) not found!" >&2 exit 1 else . "$CONF_FILE" fi case "$1" in start ) # stop if already running "$0" status && "$0" stop # initialize "$CB_SCRIPT" config-up "$CB_SCRIPT" network-up "$CB_SCRIPT" services-up # check if we are on a developers CryptoBox # if not give some usage hints # otherwise give a warning and start the devel features if [ ! -e "$DEV_FEATURES_SCRIPT" ]; then echo echo "Hints for usage:" echo " * for some reasons you can not login here :)" echo " * point a webbrowser from another computer to 'http://$(/usr/lib/cryptobox/cbox-manage.sh get_current_ip)'" echo " * configure your CryptoBox via a webbrowser" echo else echo echo "+---------------------------------------------------------------+" echo "| WARNING: Some CryptoBox development features are enabled |" echo "| This should definitely NOT happen for a production CD. |" echo "| as it offers no security at all. |" echo "| If you don't plan to refine this CD, don't use it! |" echo "+---------------------------------------------------------------+" echo $DEV_FEATURES_SCRIPT "$@" fi ;; stop ) # exit if not running "$0" status || exit 0 # shut down "$CB_SCRIPT" services-up "$CB_SCRIPT" network-up "$CB_SCRIPT" config-up ;; restart | reload | force-reload ) $0 stop $0 start ;; status ) if "$CB_SCRIPT" is_config_mounted then exit 0 else exit 1 fi ;; * ) echo "Syntax: $0 { start | stop | restart | reload | force-reload | status }" ;; esac