cryptonas/cryptobox.conf.d/usr/lib/cryptobox/devel-features.sh

66 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
#
# this script is part of the boot process of a developer's cryptobox
#
# it should really NEVER be executed on a production system
#
# called by:
# - /etc/rc2.d/S99cb-devel-features (only if $DEVELPMENT_MARKER exists)
#
set -eu
# parse config file
. /etc/cryptobox/cryptobox.conf
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 )
# start ssh daemon
/etc/init.d/ssh 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
# thttpd needs to be restarted to reopen its files
/etc/init.d/thttpd restart
;;
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)
diff -ruN "`basename \"$MIRROR_ORIG_DIR\"`" "`basename \"$MIRROR_DIR\"`" | grep -v "^Binary files"
;;
stop )
/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