migrate to luks
-- diese und die folgenden Zeilen werden ignoriert -- A https://svn.systemausfall.org/svn/cryptobox/branches/luks
This commit is contained in:
parent
e45dfa2ed8
commit
8d1c3aa9c4
364 changed files with 21139 additions and 0 deletions
171
luks/scripts/cbox-build.sh
Executable file
171
luks/scripts/cbox-build.sh
Executable file
|
@ -0,0 +1,171 @@
|
|||
#!/bin/sh
|
||||
# $Id$
|
||||
#
|
||||
# managing our work at the cryptobox
|
||||
#
|
||||
# usual workflow:
|
||||
# dfsbuild - create the image directory with dfsbuild
|
||||
# config - apply cryptobox specific changes to the image directory
|
||||
# harden - remove unnecessary packages and disable developer features
|
||||
# iso - create the iso image
|
||||
# isoz - create a compressed iso image
|
||||
# burn - burns the image on a cd-rw
|
||||
#
|
||||
# final action:
|
||||
# release - the same as "dfsbuild config harden isoz"
|
||||
#
|
||||
#
|
||||
# problems of this script:
|
||||
# - has to run as root
|
||||
# - 'harden' is strangely integrated
|
||||
#
|
||||
# you may run this script with multiple arguments, e.g.:
|
||||
# cb-build.sh dfsbuild config isoz
|
||||
#
|
||||
# the action "release" does what it says :)
|
||||
# (all developer's features like sshd, writable templates and
|
||||
# the test-suite are deactivated, some packages get removed)
|
||||
#
|
||||
|
||||
set -ue
|
||||
|
||||
# include common functions and settings
|
||||
source $(dirname $0)/common.sh.inc
|
||||
|
||||
|
||||
################### some settings ######################
|
||||
|
||||
# dfsbuild config
|
||||
DFS_CONFIG=$(get_config_file dfs-cbox.conf)
|
||||
|
||||
|
||||
####################### functions ######################
|
||||
|
||||
function run_dfsbuild()
|
||||
{
|
||||
[ ! -e "$BUILD_DIR" ] && mkdir -p "$BUILD_DIR" && echo "das BuildDir ($BUILD_DIR) wurde angelegt ..."
|
||||
dfsbuild -c "$DFS_CONFIG" -w "$BUILD_DIR"
|
||||
|
||||
# remove iso image of dfsbuild - it is not necessary
|
||||
[ -e "$BUILD_DIR/image.iso" ] && rm "$BUILD_DIR/image.iso"
|
||||
}
|
||||
|
||||
|
||||
function create_uncompressed_iso()
|
||||
{
|
||||
echo "Creating the iso ..."
|
||||
mkisofs $MKISOFS_OPTIONS -o "$IMAGE_FILE" "$IMAGE_DIR"
|
||||
}
|
||||
|
||||
|
||||
function create_compressed_iso()
|
||||
{
|
||||
echo "Creating the compressed iso ..."
|
||||
[ -e "$IMAGEZ_DIR" ] && rm -r "$IMAGEZ_DIR"
|
||||
mkdir "$IMAGEZ_DIR"
|
||||
for a in $(ls "$IMAGE_DIR")
|
||||
do if echo "$UNCOMPRESSED_ITEMS" | grep -q -w "$a"
|
||||
then echo " Copying uncompressed item: $a ..."
|
||||
cp -a "$IMAGE_DIR/$a" "$IMAGEZ_DIR"
|
||||
else if [ -h "$IMAGE_DIR/$a" ]
|
||||
then echo " Copying link: $a ..."
|
||||
cp -a "$IMAGE_DIR/$a" "$IMAGEZ_DIR"
|
||||
else echo " Compressing item: $a ..."
|
||||
mkzftree "$IMAGE_DIR/$a" "$IMAGEZ_DIR/$a"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
mkisofs -z $MKISOFS_OPTIONS -o "$IMAGEZ_FILE" "$IMAGEZ_DIR"
|
||||
}
|
||||
|
||||
|
||||
function configure_cb()
|
||||
{
|
||||
if [ ! -e "$IMAGE_DIR" ]; then
|
||||
echo -e "Directory \"$IMAGE_DIR\" not found!"
|
||||
echo -e "Did you run \"$0 dfsbuild\"?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Copying files to the box ..."
|
||||
[ -e "$TMP_DIR" ] && rm -rf "$TMP_DIR"
|
||||
svn export --force "$TEMPLATE_DIR/." "$IMAGE_DIR"
|
||||
|
||||
echo "Configuring the cryptobox ..."
|
||||
chroot "$IMAGE_DIR" "$CHROOT_START" /usr/lib/cryptobox/configure-cryptobox.sh normal
|
||||
|
||||
# source local configure scripts
|
||||
[ -d "$CUSTOM_CONFIGURE_DIR" ] && \
|
||||
find "$CUSTOM_CONFIGURE_DIR" -xtype f | sort | while read file
|
||||
do echo "Sourcing custom configure script $(basename $file):"
|
||||
# execute it in its own environment (to be safe)
|
||||
# 'source' implicitly imports all current settings
|
||||
# indent these lines to improve the output
|
||||
( source "$file" ) 2>&1 | sed 's/^/\t/'
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
function blanknburn_cdrw()
|
||||
{
|
||||
cdrecord -v dev=$CDWRITER blank=fast
|
||||
if [ -e "$IMAGEZ_FILE" ]; then
|
||||
cdrecord -v dev=$CDWRITER $IMAGEZ_FILE
|
||||
elif [ -e "IMAGE_FILE" ]; then
|
||||
cdrecord -v dev=$CDWRITER $IMAGE_FILE
|
||||
else
|
||||
echo "can't find CryptoBox image to burn" && exit 1
|
||||
fi
|
||||
}
|
||||
################ do it! ######################
|
||||
|
||||
[ $# -eq 0 ] && echo "[`basename $0`] - no arguments supplied - maybe you want to use '--help'"
|
||||
|
||||
# initialize local directories (easier for users)
|
||||
for a in $LOCALCONF_DIR $CUSTOM_CONFIGURE_DIR
|
||||
do [ ! -e "$a" ] && mkdir "$a" && chown --reference=. "$a"
|
||||
done
|
||||
|
||||
# check for uid=0 (necessary for all operations)
|
||||
[ "$(id -u)" -ne 0 ] && echo "this script ($0) has to be called as root" >&2 && exit 1
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do case "$1" in
|
||||
dfsbuild )
|
||||
# check if we are in ROOT_DIR - otherwise we will have problems with
|
||||
# relative paths in dfs-box.conf
|
||||
[ "$ROOT_DIR" -ef "$(pwd)" ] || error_die 1 "Sorry: you have to run $0 while you are in '$ROOT_DIR'!"
|
||||
run_dfsbuild
|
||||
;;
|
||||
config )
|
||||
configure_cb normal
|
||||
;;
|
||||
iso )
|
||||
create_uncompressed_iso
|
||||
;;
|
||||
isoz )
|
||||
create_compressed_iso
|
||||
;;
|
||||
harden )
|
||||
chroot "$IMAGE_DIR" "$CHROOT_START" /usr/lib/cryptobox/configure-cryptobox.sh secure
|
||||
;;
|
||||
burn )
|
||||
blanknburn_cdrw
|
||||
;;
|
||||
release )
|
||||
$0 dfsbuild config harden isoz
|
||||
;;
|
||||
help|--help )
|
||||
echo "Syntax: `basename $0` ( release | dfsbuild | config | harden | iso | isoz | burn | help )"
|
||||
echo " (you may specify more than one action)"
|
||||
echo
|
||||
;;
|
||||
* )
|
||||
echo -e "unknown action: $1"
|
||||
echo
|
||||
$0 help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
166
luks/scripts/cbox-dev.sh
Executable file
166
luks/scripts/cbox-dev.sh
Executable file
|
@ -0,0 +1,166 @@
|
|||
#!/bin/sh
|
||||
# $Id$
|
||||
#
|
||||
# managing our work at the cryptobox
|
||||
#
|
||||
# development actions:
|
||||
# chroot - run first tests in a chroot environment
|
||||
# qemu - run the qemu emulation with the uncompressed image
|
||||
# qemuz - run the qemu emulation with the compressed image
|
||||
# upload - copy your local files to tmpfs on a running cryptobox
|
||||
# diff - compare tmpfs-files on a running cryptobox with the original
|
||||
# merge - apply the diff to the local copy
|
||||
# ssh - open a ssh connection to a running cryptobox
|
||||
#
|
||||
# problems of this script:
|
||||
# - chroot has to run as root
|
||||
#
|
||||
|
||||
set -ue
|
||||
|
||||
# include common functions and settings
|
||||
source $(dirname $0)/common.sh.inc
|
||||
|
||||
################### some settings #####################
|
||||
|
||||
# qemu network configuration file
|
||||
QEMU_IFUP_FILE=$(get_config_file qemu-ifup)
|
||||
|
||||
# to connect to a development cryptobox with ssh
|
||||
SSH_CONFIG_FILE=$(get_config_file ssh_config)
|
||||
|
||||
# extract the hostname of the cryptobox from the ssh_config file
|
||||
SSH_HOST=$(grep "^Host " "$SSH_CONFIG_FILE" | head -1 | sed 's/^Host *\(.*\)$/\1/')
|
||||
|
||||
|
||||
# read some cryptobox settings (especially "DEV_FEATURES_SCRIPT")
|
||||
if [ -e "$TEMPLATE_DIR/etc/cryptobox/cryptobox.conf" ]
|
||||
then source "$TEMPLATE_DIR/etc/cryptobox/cryptobox.conf"
|
||||
else echo "cryptobox.conf ($TEMPLATE_DIR/etc/cryptobox/cryptobox.conf) does not exist!" >&2
|
||||
fi
|
||||
|
||||
####################### functions ######################
|
||||
|
||||
|
||||
function qemu_boot()
|
||||
# parameter: iso_image_file
|
||||
{
|
||||
# create a virtual harddisk image file
|
||||
if [ ! -e "$HD_IMAGE" ]
|
||||
then echo "Creating temporary harddisk image ..."
|
||||
dd if=/dev/zero of="$HD_IMAGE" bs=1M count=20
|
||||
fi
|
||||
echo "Starting qemu ..."
|
||||
qemu -cdrom "$1" -m 96 -hda "$IMAGE_FILE" -boot d -n "$QEMU_IFUP_FILE" || true
|
||||
# remove iptables rules
|
||||
"$QEMU_IFUP_FILE" stop
|
||||
}
|
||||
|
||||
|
||||
function upload2box()
|
||||
# upload local files to a development cryptobox
|
||||
# this is necessary to use an "old" development cd with
|
||||
# new code - this affects only the web-interface and the
|
||||
# cbox-manage.sh-script (the boot behaviour stays the same)
|
||||
#
|
||||
# of course, only the directories that are mapped to tmpfs can
|
||||
# be updated this way
|
||||
{
|
||||
local DIRS="var/www usr/share/cryptobox usr/lib/cryptobox"
|
||||
echo "Uploading the following dirs: $DIRS "
|
||||
[ -e "$TMP_DIR" ] || mkdir -p "$TMP_DIR"
|
||||
for a in $DIRS
|
||||
do mkdir -p "$TMP_DIR/$a"
|
||||
cp -r "$TEMPLATE_DIR/$a/." "$TMP_DIR/$a"
|
||||
done
|
||||
find "$TMP_DIR" -type d -name '\.svn' | while read a
|
||||
do rm -rf "$a"
|
||||
done
|
||||
echo "Copying local files to the cryptobox ... "
|
||||
if scp -F "$SSH_CONFIG_FILE" -rpq "$TMP_DIR/." cryptobox:/tmp/mirror
|
||||
then echo "Set the base for future diffs to current state ..."
|
||||
ssh -F "$SSH_CONFIG_FILE" "$SSH_HOST" "$DEV_FEATURES_SCRIPT" set_diff_base
|
||||
else echo 'ERROR: copying failed!'
|
||||
fi
|
||||
rm -rf "$TMP_DIR"
|
||||
}
|
||||
|
||||
|
||||
function merge_from_box()
|
||||
# merge a diff from a running development cryptobox into
|
||||
# your local copy
|
||||
{
|
||||
echo "Check for collisions ... (dry-run)"
|
||||
if box_diff | patch --dry-run -p1 -d "$TEMPLATE_DIR"
|
||||
then echo
|
||||
echo "Applying diff ..."
|
||||
box_diff | patch -p1 -d "$TEMPLATE_DIR"
|
||||
echo
|
||||
echo "Set the base for future diffs to current state ..."
|
||||
ssh -F "$SSH_CONFIG_FILE" "$SSH_HOST" "$DEV_FEATURES_SCRIPT" set_diff_base
|
||||
else echo "Merging will fail - do it manually!"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# get the diff of a running cryptobox system between its current state
|
||||
# and its original content
|
||||
function box_diff()
|
||||
{
|
||||
ssh -F "$SSH_CONFIG_FILE" "$SSH_HOST" "$DEV_FEATURES_SCRIPT" diff
|
||||
}
|
||||
|
||||
|
||||
############################# main #####################################
|
||||
|
||||
[ $# -eq 0 ] && echo "[`basename $0`] - no arguments supplied - maybe you want to use '--help'" && exit 1
|
||||
|
||||
ACTION=--help
|
||||
[ $# -gt 1 ] && ACTION=$1
|
||||
|
||||
case "$1" in
|
||||
diff )
|
||||
# get a diff from a running development cryptobox
|
||||
box_diff
|
||||
;;
|
||||
merge )
|
||||
merge_from_box
|
||||
;;
|
||||
upload )
|
||||
upload2box
|
||||
;;
|
||||
chroot )
|
||||
# chroot may only be called as root
|
||||
[ "$(id -u)" -ne 0 ] && echo "the action 'chroot' may only be called as root!" >&2 && exit 1
|
||||
if [ ! -x "$IMAGE_DIR/$CHROOT_START" ]
|
||||
then echo "the chroot init script ("$IMAGE_DIR/$CHROOT_START") is not executable"
|
||||
echo "maybe you should run '`basename $0` cb-config' first"
|
||||
else echo
|
||||
echo "##############################################################################"
|
||||
echo "# BEWARE: you can severly harm your real harddisk in the chroot environment! #"
|
||||
echo "##############################################################################"
|
||||
echo
|
||||
chroot "$IMAGE_DIR" "$CHROOT_START"
|
||||
fi
|
||||
;;
|
||||
qemu )
|
||||
qemu_boot "$IMAGE_FILE"
|
||||
;;
|
||||
qemuz )
|
||||
qemu_boot "$IMAGEZ_FILE"
|
||||
;;
|
||||
ssh )
|
||||
ssh -F "$SSH_CONFIG_FILE" "$SSH_HOST"
|
||||
;;
|
||||
help|--help )
|
||||
echo "Syntax: `basename $0` ( qemu | qemuz | chroot | upload | diff | merge | ssh | help )"
|
||||
echo
|
||||
;;
|
||||
* )
|
||||
echo -e "unknown action: $1"
|
||||
echo
|
||||
$0 help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
61
luks/scripts/common.sh.inc
Normal file
61
luks/scripts/common.sh.inc
Normal file
|
@ -0,0 +1,61 @@
|
|||
#
|
||||
# common settings and functions for cryptobox scripts
|
||||
#
|
||||
|
||||
#################### some functions ####################
|
||||
|
||||
# get the path of a configuration file - local configuration files
|
||||
# supersede default files
|
||||
# parameter: base name of the configuration file
|
||||
function get_config_file()
|
||||
{
|
||||
[ -e "$LOCALCONF_DIR/$1" ] && echo "$LOCALCONF_DIR/$1" && return 0
|
||||
[ -e "$DEFAULTCONF_DIR/$1" ] && echo "$DEFAULTCONF_DIR/$1" && return 0
|
||||
echo "configuration file ($1) not found!" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function error_die()
|
||||
{
|
||||
echo "$2" >&2
|
||||
exit $1
|
||||
}
|
||||
|
||||
|
||||
################### general settings ###################
|
||||
|
||||
# the base directory of your local development files
|
||||
ROOT_DIR=$(dirname "$0")/..
|
||||
|
||||
# the template (default) configuration directory
|
||||
DEFAULTCONF_DIR="$ROOT_DIR/etc-defaults.d"
|
||||
|
||||
# your local configuration directory (existing files supersede the defaults)
|
||||
LOCALCONF_DIR="$ROOT_DIR/etc-local.d"
|
||||
|
||||
# local configuration directory - contains scripts to be executed after
|
||||
# 'configure'
|
||||
CUSTOM_CONFIGURE_DIR="$ROOT_DIR/configure-local.d"
|
||||
|
||||
# template directory for cryptobox specific configuration
|
||||
TEMPLATE_DIR="cbox-tree.d"
|
||||
|
||||
# the chroot-wrapper within the cryptobox
|
||||
CHROOT_START="/usr/lib/cryptobox/chroot-start.sh"
|
||||
|
||||
|
||||
############# include local configuration ##############
|
||||
|
||||
if [ -e "$(get_config_file cbox-dev.conf)" ]
|
||||
then source "$(get_config_file cbox-dev.conf)"
|
||||
else echo "local cbox-dev.conf ($(get_config_file cbox-dev.conf)) does not exist!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# image directory created by dfsbuild
|
||||
# the BUILD_DIR is defined in the local cbox-dev.conf
|
||||
IMAGE_DIR="$BUILD_DIR/image"
|
||||
IMAGEZ_DIR="$BUILD_DIR/image.z"
|
||||
IMAGEZ_FILE="${IMAGE_FILE/\.iso/_compressed.iso}"
|
||||
UNCOMPRESSED_ITEMS="_offline autorun.inf start.html var boot opt"
|
||||
|
3
luks/scripts/show_TODO.sh
Executable file
3
luks/scripts/show_TODO.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
grep "TODO" $(find "$(dirname $0)/.." -type f | grep -v "\.svn" | grep -v "$(basename $0)")
|
126
luks/scripts/userdocexport.sh
Executable file
126
luks/scripts/userdocexport.sh
Executable file
|
@ -0,0 +1,126 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# export wiki pages to the cryptobox development tree
|
||||
# this creates static and integrated pages
|
||||
#
|
||||
|
||||
set -ue
|
||||
|
||||
# root directory of the cryptobox development environment
|
||||
ROOT_DIR="$(dirname $0)/.."
|
||||
|
||||
# retrieve these pages from the wiki
|
||||
PAGES="CryptoBox CryptoBoxUser CryptoBoxUserGettingStarted
|
||||
CryptoBoxUserConfiguration CryptoBoxUserDailyUse CryptoBoxDev
|
||||
CryptoBoxDevPreparation CryptoBoxDevCustomBuild CryptoBoxDevWorkFlow
|
||||
CryptoBoxDevValidation CryptoBoxDevCustomConfigure CryptoBoxDevBackground
|
||||
CryptoBoxDevKnownProblems"
|
||||
#PAGES="CryptoBox"
|
||||
|
||||
# base URL
|
||||
WIKI_HOST="https://systemausfall.org"
|
||||
# the trailing slash is important
|
||||
WIKI_URL=/trac/cryptobox/wiki/
|
||||
|
||||
CBOX_CGI="/cryptobox?action=doc\&page="
|
||||
|
||||
LANGUAGES="de en"
|
||||
|
||||
DEST_DIR="$ROOT_DIR/cbox-tree.d/usr/share/doc/cryptobox/html"
|
||||
OFFLINE_DIR="$ROOT_DIR/cbox-tree.d/_offline/doc"
|
||||
IMAGE_DIR="$ROOT_DIR/cbox-tree.d/var/www/cryptobox-img"
|
||||
TMP_DIR=/tmp/$(basename $0)-$$.d
|
||||
|
||||
HEADER_FILE=doc_header.inc
|
||||
FOOTER_FILE=doc_footer.inc
|
||||
|
||||
[ ! -e "$DEST_DIR" ] && echo "$DEST_DIR does not exist" && exit 1
|
||||
|
||||
for LANG in $LANGUAGES; do
|
||||
for PAGE in $PAGES; do
|
||||
PAGE_SRC="$WIKI_HOST$WIKI_URL$PAGE/$LANG"
|
||||
echo "Importing $PAGE/$LANG:"
|
||||
|
||||
# replace sub-page-style '/' like moin does it (by '_2f')
|
||||
TMP_FILE=$TMP_DIR/${PAGE}.html
|
||||
mkdir -p "$TMP_DIR"
|
||||
|
||||
echo " downloading the page ..."
|
||||
wget --quiet --output-document="$TMP_FILE" "$PAGE_SRC" || { echo "Downloading ($PAGE_SRC) failed!"; exit 1; }
|
||||
|
||||
# check if this moin page exists (by looking for the template selection)
|
||||
if grep -q "^describe $PAGE/$LANG here$" "$TMP_FILE"
|
||||
then rm "$TMP_FILE"
|
||||
PAGE_SRC=$(dirname $PAGE_SRC)
|
||||
echo " trying to download default language page instead"
|
||||
wget --quiet --output-document="$TMP_FILE" "$PAGE_SRC" || { echo "Downloading ($PAGE_SRC) failed!" >&2; exit 1; }
|
||||
# check, if there is even no default page
|
||||
grep -q "^describe $PAGE/$LANG here$" "$TMP_FILE" && echo "This page ($PAGE_SRC) was not found!" >&2 && exit 1
|
||||
fi
|
||||
|
||||
echo " removing header and footer ..."
|
||||
# break lines before start of content
|
||||
sed -i 's#<div id="content" class="wiki">#_END_OF_HEADER_\n#' "$TMP_FILE"
|
||||
# the 'edit' buttons mark the end of the page
|
||||
sed -i 's#<div class="buttons">#\n_START_OF_FOOTER_#' "$TMP_FILE"
|
||||
# cut off a possible comment - section
|
||||
sed -i "s#<form action=[^>]*\#commentpreview#\n_START_OF_FOOTER_#" "$TMP_FILE"
|
||||
# remove all lines before and after "body"
|
||||
sed -i '1,/_END_OF_HEADER_/d; /_START_OF_FOOTER_/,$d' "$TMP_FILE"
|
||||
|
||||
# close open divs
|
||||
while [ "$(grep '<div' "$TMP_FILE" | wc -l)" -gt "$(grep '</div>' "$TMP_FILE" | wc -l)" ]
|
||||
do echo "</div>" >>"$TMP_FILE"
|
||||
done
|
||||
|
||||
#echo " removing link images (moin specific) ..."
|
||||
# remove inter-wiki images
|
||||
#sed -i 's#<[^<]*moin-inter.png[^>]*>##g' "$TMP_FILE"
|
||||
# remove moin-www images
|
||||
#sed -i 's#<[^<]*moin-www.png[^>]*> ##g' "$TMP_FILE"
|
||||
|
||||
# not necessary, because everything is a part of the repository
|
||||
#echo " downloading requisites ..."
|
||||
#wget --quiet --ignore-tags=a --no-clobber --page-requisites --convert-links --no-directories --base="$WIKI_HOST$WIKI_URL" --directory-prefix="$TMP_DIR" --html-extension --force-html --input-file="$TMP_FILE" || { echo "Downloading requisites for ($PAGE_SRC) failed!"; exit 1; }
|
||||
|
||||
echo " adjusting links for images ..."
|
||||
sed -i "s#='[^']*/cryptobox-img/\([^']*\)'#='/cryptobox-img/\1'#g" "$TMP_FILE"
|
||||
|
||||
echo " adjusting wiki links ..."
|
||||
# redirect wiki links to cryptobox cgi
|
||||
sed -i "s#=\"$WIKI_URL\([^\.]*\)\"#=\"$CBOX_CGI\1\"#g" "$TMP_FILE"
|
||||
# do it twice - somehow, the "g" flag does not work (it should replace multiple occurrences on a line)
|
||||
sed -i "s#=\"$WIKI_URL\([^\.]*\)\"#=\"$CBOX_CGI\1\"#g" "$TMP_FILE"
|
||||
# remove language specific part of moin link
|
||||
for TLANG in $LANGUAGES
|
||||
do sed -i "s#=\"$CBOX_CGI\([^\"]*\)/$TLANG#=\"$CBOX_CGI\1#g" "$TMP_FILE"
|
||||
done
|
||||
|
||||
|
||||
# build the static pages
|
||||
echo " building static doc page"
|
||||
offline_file=$OFFLINE_DIR/$LANG/$(basename $TMP_FILE)
|
||||
mkdir -p "$OFFLINE_DIR/$LANG"
|
||||
cat "$OFFLINE_DIR/$HEADER_FILE" "$OFFLINE_DIR/$LANG/$HEADER_FILE" "$TMP_FILE" "$OFFLINE_DIR/$LANG/$FOOTER_FILE" "$OFFLINE_DIR/$FOOTER_FILE" >"$offline_file"
|
||||
sed -i "s%=\"$CBOX_CGI\([^\"#]*\)%=\"\1.html%g" "$offline_file"
|
||||
# do it twice - this should not be necessary
|
||||
sed -i "s%=\"$CBOX_CGI\([^#\"]*\)%=\"\1.html%g" "$offline_file"
|
||||
sed -i "s#='/cryptobox-img#='../../../var/www/cryptobox-img#g" "$offline_file"
|
||||
|
||||
# split language specific part of moin link and replace it by current language
|
||||
for TLANG in $LANGUAGES
|
||||
do sed -i "s#=\"\([^/]*\)/${TLANG}.html\"#=\"\1.html\"#g" "$offline_file"
|
||||
done
|
||||
|
||||
# some last changes to the dynamic pages (must be done _after_ the static pages)
|
||||
# add weblang for current language to query string
|
||||
sed -i "s#=\"$CBOX_CGI\(.*\)\"#=\"$CBOX_CGI\1\&weblang=$LANG\"#g" "$TMP_FILE"
|
||||
# move cgi-doc
|
||||
mv "$TMP_FILE" "$DEST_DIR/$LANG"
|
||||
|
||||
echo " finished!"
|
||||
done
|
||||
done
|
||||
|
||||
[ -n "$(find "$TMP_DIR" -type f)" ] && mv "$TMP_DIR"/* "$IMAGE_DIR"
|
||||
rmdir "$TMP_DIR"
|
141
luks/scripts/validate.sh
Executable file
141
luks/scripts/validate.sh
Executable file
|
@ -0,0 +1,141 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# do a validation
|
||||
#
|
||||
# use "--help" for a list of possible actions
|
||||
#
|
||||
|
||||
set -eu
|
||||
|
||||
# include common functions and settings
|
||||
source $(dirname $0)/common.sh.inc
|
||||
|
||||
# extract confirmation text from language file
|
||||
confirmtext=$(grep "\<ConfirmInit\>" "$TEMPLATE_DIR/usr/share/cryptobox/lang/${VALIDATE_LANGUAGE}.hdf" | sed 's/[^=]*=[^a-zA-Z]*\(.*\)$/\1/; s/ /%20/g; s/!/%21/g; s/,/%2C/g')
|
||||
|
||||
##################### some functions ########################
|
||||
|
||||
function do_single()
|
||||
# Parameter: "test case dir" "output directory for results"
|
||||
{
|
||||
local TESTNAME=$(basename $1)
|
||||
# replace IPs and ports in the curl-file by local settings
|
||||
cat "$1/input.curl" | substitute_constants | curl --insecure --silent --output "${2}/${TESTNAME}.html" --config -
|
||||
# remove possible refresh-redirect
|
||||
sed -i 's/<meta http-equiv="refresh"[^>]*>//g' "${2}/${TESTNAME}.html"
|
||||
# there is no status in certain cases - e.g. for error 404
|
||||
if [ -e "${2}/${TESTNAME}.html" ]
|
||||
then sed "1,/CBOX-STATUS-begin/d; /CBOX-STATUS-end/,\$d" "${2}/${TESTNAME}.html" >"${2}/${TESTNAME}.status"
|
||||
# the diff option "-B" is required, because the status output of
|
||||
# the cryptobox.pl script contains some blank lines
|
||||
cat "$1/output" | substitute_constants | diff -NB - "${2}/${TESTNAME}.status" | sed 's/</\</g; s/>/\>/g' >"${2}/${TESTNAME}.diff" || true
|
||||
rm "${2}/${TESTNAME}.status"
|
||||
fi
|
||||
cp "$1/description" "${2}/${TESTNAME}.desc"
|
||||
# sleep, if a file called 'delay' exists
|
||||
[ -e "$1/delay" ] && sleep "$(<$1/delay)"
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
function do_series()
|
||||
# parameter: name of the test case
|
||||
{
|
||||
[ -d "$VALIDATE_REPORT_DIR/$1" ] && rm -r "$VALIDATE_REPORT_DIR/$1"
|
||||
mkdir -p "$VALIDATE_REPORT_DIR/$1"
|
||||
find "$VALIDATE_TEST_CASES_DIR/$1" -maxdepth 1 -mindepth 1 -type d | grep -v "/\.[^/]*$" | sort | while read a
|
||||
do do_single "$a" "$VALIDATE_REPORT_DIR/$1"
|
||||
done
|
||||
create_summary "$1" >"$VALIDATE_REPORT_DIR/summary-$1.html"
|
||||
}
|
||||
|
||||
|
||||
function create_summary()
|
||||
# parameter: name of test series
|
||||
{
|
||||
cat "$VALIDATE_SUMMARY_TEMPLATE_DIR/header"
|
||||
find "$VALIDATE_REPORT_DIR/$1" -maxdepth 1 -type f -name \*.desc | sort | while read a
|
||||
do TESTNAME=$(basename ${a%.desc})
|
||||
TESTDESCRIPTION=$(cat $a)
|
||||
sed "s#_TESTSERIES_#$1#g; s#_TESTNAME_#$TESTNAME#g; s/_TESTDESCRIPTION_/$TESTDESCRIPTION/" "$VALIDATE_SUMMARY_TEMPLATE_DIR/single_header"
|
||||
local DIFF_FILE=${a%.desc}.diff
|
||||
if [ -s "$DIFF_FILE" ]
|
||||
then cat "$VALIDATE_SUMMARY_TEMPLATE_DIR/result-error"
|
||||
sed 's#$#<br/>#' "$DIFF_FILE"
|
||||
else cat "$VALIDATE_SUMMARY_TEMPLATE_DIR/result-ok"
|
||||
echo "no differences found"
|
||||
# remove empty diff
|
||||
[ -e "$DIFF_FILE" ] && rm "$DIFF_FILE"
|
||||
fi
|
||||
cat "$VALIDATE_SUMMARY_TEMPLATE_DIR/single_footer"
|
||||
# remove description file
|
||||
rm "$a"
|
||||
done
|
||||
cat "$VALIDATE_SUMMARY_TEMPLATE_DIR/footer"
|
||||
}
|
||||
|
||||
|
||||
function import_style()
|
||||
# get the stylesheet file and images
|
||||
# change the stylesheet link
|
||||
{
|
||||
[ -d "$VALIDATE_REPORT_DIR/cryptobox-img" ] && rm -r "$VALIDATE_REPORT_DIR/cryptobox-img"
|
||||
mkdir -p "$VALIDATE_REPORT_DIR/cryptobox-img"
|
||||
[ -e "$VALIDATE_REPORT_DIR/cryptobox.css" ] && rm "$VALIDATE_REPORT_DIR/cryptobox.css"
|
||||
wget -q -O "$VALIDATE_REPORT_DIR/cryptobox.css" http://$VALIDATE_HOST_IP_DEFAULT/cryptobox.css
|
||||
# extract image file names
|
||||
grep "url(cryptobox-img/" "$VALIDATE_REPORT_DIR/cryptobox.css" | sed 's#^.*url(cryptobox-img/\(.*\)).*$#\1#' | while read a
|
||||
do wget -q -O "$VALIDATE_REPORT_DIR/cryptobox-img/$a" "http://$VALIDATE_HOST_IP_DEFAULT/cryptobox-img/$a"
|
||||
done
|
||||
|
||||
# change the stylesheet link in every html file in REPORT_DIR
|
||||
find "$VALIDATE_REPORT_DIR" -type f -name \*.html | while read a
|
||||
do sed -i '/stylesheet/s#href=\"/cryptobox.css\"#href=\"../cryptobox.css\"#g' "$a"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
function substitute_constants()
|
||||
{
|
||||
sed "s/_HOST_IP_DEFAULT_/$VALIDATE_HOST_IP_DEFAULT/g; \
|
||||
s/_HOST_IP_CHANGED_/$VALIDATE_HOST_IP_CHANGED/g; \
|
||||
s/_IFACE_LANG_/$VALIDATE_LANGUAGE/g;
|
||||
s/_CONFIRM_TEXT_/$confirmtext/g"
|
||||
}
|
||||
|
||||
##################### main ###########################
|
||||
|
||||
# do all checks, if nothing is specified
|
||||
ACTION="check_all"
|
||||
[ $# -gt 0 ] && ACTION=$1
|
||||
|
||||
case "$ACTION" in
|
||||
list )
|
||||
find "$VALIDATE_TEST_CASES_DIR" -maxdepth 1 -mindepth 1 -type d | grep -v "/\.[^/]*$" | sort | while read a
|
||||
do echo $(basename "$a")
|
||||
done
|
||||
;;
|
||||
check )
|
||||
[ $# -ne 2 ] && error_die 1 "Syntax: $(basename $0) check NAME"
|
||||
case_dir="$VALIDATE_TEST_CASES_DIR/$2"
|
||||
[ ! -d "$case_dir" ] && error_die 2 "the test case was not found ($case_dir)!"
|
||||
do_series "$2"
|
||||
import_style
|
||||
;;
|
||||
check_all )
|
||||
# default action
|
||||
"$0" list | sort | while read a
|
||||
do echo -n "Validating $a ..."
|
||||
"$0" check "$a"
|
||||
echo
|
||||
done
|
||||
;;
|
||||
* )
|
||||
echo "Syntax of $(basename $0)"
|
||||
echo -e "\t check_all \t - execute all test cases [default]"
|
||||
echo -e "\t check NAME \t - execute a test case"
|
||||
echo -e "\t list \t\t - show a list of available test cases"
|
||||
echo -e "\t help \t\t - this syntax information"
|
||||
echo
|
||||
;;
|
||||
esac
|
Loading…
Add table
Add a link
Reference in a new issue