71 lines
1.8 KiB
Bash
71 lines
1.8 KiB
Bash
|
#!/bin/sh
|
||
|
#
|
||
|
# 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
|
||
|
|
||
|
# 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 )
|
||
|
# 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
|
||
|
|
||
|
# 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
|