@ -180,9 +180,22 @@ function is_crypto_mounted()
function is_init_running( )
{
#ps -e | grep -q -E "$MKFS_DATA|$WIPE"
# this line is good for the "at" stuff - see cryptobox.pl
[ -n " $( at -l) " ]
check_at_command_queue " box-init-bg"
}
# check if a specified command is in an at-queue
# Parameter: a regular expression of the commandline
# Return: the command is part of an at-queue (0) or not (1)
function check_at_command_queue( )
{
# 1) get the available job numbers
# 2) remove empty lines (especially the last one)
# 3) check every associated command for the regexp
at -l | cut -f 1 -d " " | while read jobnum
do at -c $jobnum | sed '/^$/d' | tail -1 | grep -q " $1 " && return 0
done
return 1
}
@ -284,8 +297,7 @@ function init_cryptobox_part1()
function init_cryptobox_part2( )
# some things to be done in the background
# these are the final steps of initialisation
# thuid must be changed at the first time, therfore it needs to be
# mounted
# the uid must be changed initially, therfore it needs to be mounted
{
mkfs_crypto
mount " $CRYPTMAPPER_DEV " " $CRYPTO_DIR "
@ -311,7 +323,7 @@ ACTION=help
case " $ACTION " in
config-up )
# die cruft option hilft vielleicht bei dem Fehle r "interleaved files not (yet) supported"
# the "cruft" option could help to prevent the erro r "interleaved files not (yet) supported"
mount -o remount,cruft /
if mount_config
then echo "Cryptobox configuration successfully loaded"
@ -319,7 +331,7 @@ case "$ACTION" in
fi
; ;
config-down )
mount | grep -q " $CONFIG_DIR " && umount " $CONFIG_DIR "
umount " $CONFIG_DIR " || error_msg 4 "Could not unmount configuration partition "
; ;
network-up )
kudzu -s -q --class network
@ -328,7 +340,7 @@ case "$ACTION" in
log_msg " Configured $NET_IFACE for $conf_ip ... "
echo " Configured network interface for $NET_IFACE : $conf_ip "
log_msg "Starting the firewall ..."
$FIREWALL_SCRIPT start
" $FIREWALL_SCRIPT " start
# start stunnel
if [ -f " $CERT_FILE " ]
then USE_CERT = $CERT_FILE
@ -358,8 +370,10 @@ case "$ACTION" in
/etc/init.d/thttpd stop
; ;
box-init )
# this is good for commandline only, as it takes a lot of time
init_cryptobox_complete >>" $LOG_FILE " 2>& 1
# do complete initialization
" $0 " box-init-fg
# the background part will recall itself as an at-command
" $0 " box-init-bg
; ;
box-init-fg )
# only partitioning and configuration
@ -371,7 +385,12 @@ case "$ACTION" in
box-init-bg )
# do it in the background to provide a smoother web interface
# messages and errors get written to $LOG_FILE
init_cryptobox_part2 </dev/null >>" $LOG_FILE " 2>& 1
# make sure, that this is always called via 'at':
if check_at_command_queue " box-init-bg"
then init_cryptobox_part2 </dev/null >>" $LOG_FILE " 2>& 1
else echo -n " ' $0 ' box-init-bg " | at now
fi
; ;
is_crypto_mounted )
is_crypto_mounted
@ -382,6 +401,11 @@ case "$ACTION" in
is_init_running )
is_init_running
; ;
update_ip_address )
# reconfigure the network interface to a new IP address
# wait for 15 seconds to finish present http requests
echo -n " sleep 15; ifconfig $NET_IFACE `get_config ip` " | at now
; ;
crypto-mount )
mount_crypto
; ;
@ -399,6 +423,16 @@ case "$ACTION" in
diskinfo )
$SFDISK -L -q -l ` find_harddisk`
; ;
poweroff )
is_crypto_mounted && umount_crypto
log_msg "Turning off the CryptoBox ..."
echo "poweroff" | at now
; ;
reboot )
is_crypto_mounted && umount_crypto
log_msg "Rebooting the CryptoBox ..."
echo "reboot" | at now
; ;
get_current_ip )
get_current_ip
; ;