cryptonas-livecd/config/chroot_local-includes/usr/lib/cryptobox-cd/devel-features.sh

84 lines
2.3 KiB
Bash
Raw Normal View History

#!/bin/sh
#
# Copyright (c) 02005 sense.lab <senselab@systemausfall.org>
#
# License: This script is distributed under the terms of version 2
# of the GNU GPL. See the LICENSE file included with the package.
#
# $Id$
#
# this script is part of the boot process of a developer's cryptobox
#
# it should really NEVER be found on a release CD
#
# called by:
# - /etc/rc2.d/S99cb-devel-features
#
set -eu
# read the default setting file, if it exists
[ -e /etc/default/cryptobox ] && . /etc/default/cryptobox
# set CONF_FILE to default value, if not configured in /etc/default/cryptobox
CONF_FILE=${CONF_FILE:-/etc/cryptobox/cryptobox.conf}
# parse config file
. "$CONF_FILE"
MIRROR_DIR=/tmp/mirror
MIRROR_ORIG_DIR=/tmp/mirror.orig
WRITE_DIRS="/usr/share/cryptobox /var/www /usr/lib/cryptobox"
ACTION="--help"
[ $# -gt 0 ] && ACTION="$1"
case "$ACTION" in
start )
# copy cryptobox files to tmpfs
for a in $WRITE_DIRS
do mkdir -p "$MIRROR_DIR/$a"
cp -a "$a/." "$MIRROR_DIR/$a"
mount --bind "$MIRROR_DIR/$a" "$a"
done
$0 set_diff_base
# cryptobox-server needs to be restarted to reopen its files
invoke-rc.d cryptobox-server restart
# start ssh daemon
[ -x /etc/init.d/ssh ] && /etc/init.d/ssh start
;;
set_diff_base )
# the present content of the tmpfs mirror get copied to
# MIRROR_ORIG_DIR for later diffs
# whenever you merged a diff, you should call this function
[ -e "$MIRROR_ORIG_DIR" ] && rm -rf "$MIRROR_ORIG_DIR"
cp -a "$MIRROR_DIR" "$MIRROR_ORIG_DIR"
;;
diff )
cd "`dirname \"$MIRROR_ORIG_DIR\"`"
# diff and remove "binary files differ"-warnings (vi-swap-files)
# ignore generated reports
# ignore cryptobox.pl and index.html, as those are the same as
# /var/www/cryptobox (symbilic links)
# replace the link name (/var/www/cryptobox) by its destination
# UGLY!
diff -ruN --exclude=report --exclude=cryptobox.pl --exclude=index.html "`basename \"$MIRROR_ORIG_DIR\"`" "`basename \"$MIRROR_DIR\"`" | grep -v "^Binary files" | sed 's#/var/www/cryptobox\t#/var/www/cgi-bin/cryptobox.pl\t#'
;;
stop )
[ -x /etc/init.d/ssh ] && /etc/init.d/ssh stop
for a in $WRITE_DIRS
do umount "$MIRROR_DIR/$a"
done
rm -rf "$MIRROR_DIR"
;;
restart )
$0 stop
$0 start
;;
* )
echo "Syntax: `basename $0` { start | stop | restart }"
;;
esac