cryptonas/bin/init-script.sh

58 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
#
# runlevel script of the cryptobox package
#
# Copyright (c) 02006, senselab
#
# see LICENSE file in this package for details
#
# 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}
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
# 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 . "$CONF_FILE"
else echo "[$(basename $0)] - configuration file ($CONF_FILE) not found!" >&2
exit 1
fi
case "$1" in
start )
# nothing to be done
;;
stop )
# unmount all active containers
ls ~$CRYPTOBOX_USER/mnt/ | while read mnt_dir
do grep -q " ~$CRYPTOBOX_USER/mnt/$mnt_dir " /proc/mounts || continue
"$LIB_DIR/cbox-manage.sh" crypto-down "$mnt_dir"
done
;;
restart )
"$0" stop
"$0" start
;
* )
echo "invalid action specified - try { start | stop | restart }" >&2
exit 1
;;
esac