Created new branch for Debian Live live-cd build system development. This
commit includes the default configuration files, which don't work with Debian "etch".
This commit is contained in:
commit
ec818dbbc3
253 changed files with 6460 additions and 0 deletions
237
scripts/cbox-build.sh
Executable file
237
scripts/cbox-build.sh
Executable file
|
@ -0,0 +1,237 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 02005-02006 sense.lab <devel@senselab.org.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$
|
||||
#
|
||||
# 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)
|
||||
|
||||
# debian package of cryptobox-server
|
||||
DEB_PACKAGE=$ROOT_DIR/packages/cryptobox-server.deb
|
||||
|
||||
|
||||
####################### functions ######################
|
||||
|
||||
# samba fails to install if /proc/ is empty
|
||||
# we force samba to skip startup during configuring
|
||||
function workaround_samba_proc()
|
||||
{
|
||||
# let dfsbuild start first
|
||||
sleep 15
|
||||
local DEFAULT_DIR=$IMAGE_DIR/etc/default
|
||||
mkdir -p "$DEFAULT_DIR"
|
||||
echo "exit" >"$DEFAULT_DIR/samba"
|
||||
}
|
||||
|
||||
|
||||
function run_dfsbuild()
|
||||
{
|
||||
# we need a secret gpg key for apt-move/reprepro(?) - very strange
|
||||
# see: http://lists.debian.org/debian-user/2005/09/msg03288.html
|
||||
if test -z "$(gpg --list-secret-keys 2>/dev/null)"
|
||||
then echo "*************************************************************"
|
||||
echo "* Sorry - for some strange reason you/root need a secret *"
|
||||
echo "* gpg key without a passphrase! *"
|
||||
echo "* Please create a key first: 'gpg --gen-key' *"
|
||||
echo "*************************************************************"
|
||||
exit 1
|
||||
fi >&2
|
||||
if [ -e "$BUILD_DIR" ]
|
||||
then ## umount all other directories below
|
||||
mount | cut -d " " -f 3- | sed "s/ type .*$//" | grep "$IMAGE_DIR" | while read mdir
|
||||
do umount "$mdir"
|
||||
done
|
||||
echo "removing the build directory ($BUILD_DIR) to guarantee a clean build ..."
|
||||
rm -r "$BUILD_DIR"
|
||||
fi
|
||||
|
||||
workaround_samba_proc &
|
||||
|
||||
# build the target directory
|
||||
LANG=C 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"
|
||||
|
||||
# finish package installation
|
||||
echo "dpkg --configure --pending" | chroot_image
|
||||
}
|
||||
|
||||
|
||||
function create_uncompressed_iso()
|
||||
{
|
||||
# check for a mounted procfs
|
||||
mount | grep -q " $IMAGE_DIR/proc " && umount "$IMAGE_DIR/proc"
|
||||
echo "Creating the iso ..."
|
||||
mkisofs $MKISOFS_OPTIONS -o "$IMAGE_FILE" "$IMAGE_DIR"
|
||||
}
|
||||
|
||||
|
||||
function create_compressed_iso()
|
||||
{
|
||||
# check for a mounted procfs
|
||||
mount | grep -q " $IMAGE_DIR/proc " && umount "$IMAGE_DIR/proc"
|
||||
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 ..."
|
||||
svn export --force "$TEMPLATE_DIR/." "$IMAGE_DIR"
|
||||
|
||||
echo "Configuring the cryptobox ..."
|
||||
echo "/usr/lib/cryptobox-cd/configure-cryptobox.sh normal" | chroot_image
|
||||
|
||||
# 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 install_package()
|
||||
{
|
||||
## first disable automatic startup to avoid conflicts with local servers
|
||||
local conf_file=$IMAGE_DIR/etc/default/cryptobox-server
|
||||
test -e "$conf_file" && sed -i 's/^NO_START=.*$/NO_START=1/' "$conf_file"
|
||||
local chroot_deb_file=/cryptobox-server.deb
|
||||
cp "$DEB_PACKAGE" "$IMAGE_DIR$chroot_deb_file"
|
||||
echo "dpkg -i $chroot_deb_file" | chroot_image
|
||||
rm "$IMAGE_DIR$chroot_deb_file"
|
||||
}
|
||||
|
||||
|
||||
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 )
|
||||
install_package
|
||||
configure_cb normal
|
||||
;;
|
||||
iso )
|
||||
create_uncompressed_iso
|
||||
;;
|
||||
isoz )
|
||||
create_compressed_iso
|
||||
;;
|
||||
harden )
|
||||
echo "/usr/lib/cryptobox-cd/configure-cryptobox.sh normal" | chroot_image
|
||||
echo "/usr/lib/cryptobox-cd/configure-cryptobox.sh secure" | chroot_image
|
||||
;;
|
||||
burn )
|
||||
blanknburn_cdrw
|
||||
;;
|
||||
release )
|
||||
"$0" dfsbuild config harden isoz
|
||||
md5sum $IMAGEZ_FILE > ${IMAGEZ_FILE}.md5sum
|
||||
sha1sum $IMAGEZ_FILE > ${IMAGEZ_FILE}.sha1sum
|
||||
;;
|
||||
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
|
157
scripts/cbox-dev.sh
Executable file
157
scripts/cbox-dev.sh
Executable file
|
@ -0,0 +1,157 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# 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$
|
||||
#
|
||||
# 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 #####################
|
||||
|
||||
# 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/')
|
||||
|
||||
|
||||
####################### 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=$HD_IMAGE_SIZE
|
||||
fi
|
||||
echo "Starting qemu ..."
|
||||
qemu -hda "$HD_IMAGE" -cdrom "$1" -boot d -m 96 -net nic -net tap || true
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
echo
|
||||
echo "##############################################################################"
|
||||
echo "# BEWARE: you can severly harm your real harddisk in the chroot environment! #"
|
||||
echo "##############################################################################"
|
||||
echo
|
||||
chroot_image
|
||||
;;
|
||||
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
|
||||
|
4
scripts/cleanup_target.sh
Executable file
4
scripts/cleanup_target.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
umount "$1/proc"
|
||||
|
88
scripts/common.sh.inc
Normal file
88
scripts/common.sh.inc
Normal file
|
@ -0,0 +1,88 @@
|
|||
#
|
||||
# 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
|
||||
}
|
||||
|
||||
function chroot_image()
|
||||
{
|
||||
MNT_SRC=$IMAGE_DIR/opt/dfsruntime/runtimerd
|
||||
MNT_DST=$IMAGE_DIR/opt/dfsruntime/runtimemnt
|
||||
TMP_DIR=/tmp/cryptobox-chroot-$(basename $0)-$$
|
||||
[ -d "$TMP_DIR" ] && rm -rf "$TMP_DIR"
|
||||
|
||||
cp -a "$MNT_SRC/." "$TMP_DIR"
|
||||
mount --bind "$TMP_DIR" "$MNT_DST"
|
||||
|
||||
[ ! -e "$TMP_DIR/dev/null" ] && mknod "$TMP_DIR/dev/null" c 1 3 && chmod 666 "$TMP_DIR/dev/null"
|
||||
[ ! -e "$TMP_DIR/dev/urandom" ] && mknod "$TMP_DIR/dev/urandom" c 1 9 && chmod 444 "$TMP_DIR/dev/urandom"
|
||||
[ ! -e "$TMP_DIR/dev/console" ] && mknod "$TMP_DIR/dev/console" c 1 5 && chmod 660 "$TMP_DIR/dev/console"
|
||||
|
||||
# remember, if proc was mounted before (e.g. because of a running chroot)
|
||||
local PROC_WAS_MOUNTED=no
|
||||
mount -t proc proc "$IMAGE_DIR/proc" 2>/dev/null || PROC_WAS_MOUNTED=yes
|
||||
|
||||
# default language setting - prevents dpkg error messages
|
||||
# set default terminal (good if you are running in a screen session)
|
||||
LANG=C TERM=linux chroot "$IMAGE_DIR" /bin/bash
|
||||
|
||||
umount "$MNT_DST"
|
||||
[ "$PROC_WAS_MOUNTED" = "no" ] && umount "$IMAGE_DIR/proc"
|
||||
rm -r "$TMP_DIR"
|
||||
}
|
||||
|
||||
################### general settings ###################
|
||||
|
||||
# the base directory of your local development files
|
||||
ROOT_DIR=$(dirname "$0")/..
|
||||
ROOT_DIR=$(cd "$ROOT_DIR"; pwd)
|
||||
|
||||
# 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"
|
||||
|
||||
# the chroot-wrapper within the cryptobox
|
||||
CHROOT_START="/usr/lib/cryptobox-cd/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/target
|
||||
IMAGEZ_DIR=$BUILD_DIR/target.z
|
||||
IMAGEZ_FILE="${IMAGE_FILE%.iso}_compressed.iso"
|
||||
UNCOMPRESSED_ITEMS="_offline autorun.inf start.html boot opt boot.catalog"
|
||||
|
||||
HD_IMAGE=$ROOT_DIR/test.img
|
||||
HD_IMAGE_SIZE=256
|
||||
|
141
scripts/mirror_offline_doc.sh
Executable file
141
scripts/mirror_offline_doc.sh
Executable file
|
@ -0,0 +1,141 @@
|
|||
#!/bin/sh
|
||||
|
||||
PROJ_DIR=$(dirname "$0")/..
|
||||
PROJ_DIR=$(cd "$PROJ_DIR"; pwd)
|
||||
DEST_DIR="$PROJ_DIR/live-cd-tree.d/_offline/doc"
|
||||
WIKI_PAGES="doc/0.3/CryptoBoxUserGettingStarted/en
|
||||
doc/0.3/CryptoBoxUserDailyUse/en
|
||||
CryptoBoxUser/en
|
||||
faq"
|
||||
|
||||
|
||||
function prepare_wiki_page()
|
||||
{
|
||||
sed -i '1,/<div class="wikipage">/d' "$1"
|
||||
# remove the "comment" or "edit" stuff
|
||||
sed -i '/<h2>Comments<\/h2>/,$d' "$1"
|
||||
sed -i '/<div class="buttons">/,$d' "$1"
|
||||
# remove the last horizontal line
|
||||
sed -i '$,$d' "$1"
|
||||
# add anchor ids to every head line
|
||||
sed -i 's#<h\([1-4]\)>\(.*\)</h#<h\1 id="\2">\2</h#g' "$1"
|
||||
while grep -q '<h[1-4] id="\([a-zA-Z]*\)[^a-zA-Z"]' "$1"
|
||||
do sed -i 's#<h\([1-4]\) id="\([a-zA-Z]*\)[^a-zA-Z"]#<h\1 id="\2#g' "$1"
|
||||
done
|
||||
# convert wiki links
|
||||
sed -i 's#="/wiki/\([^"/]*\)/#="/wiki/\1_#g' "$1"
|
||||
sed -i 's#="/wiki/\([^"/]*\)/#="/wiki/\1_#g' "$1"
|
||||
sed -i 's#="/wiki/\([^"/]*\)/#="/wiki/\1_#g' "$1"
|
||||
sed -i 's#="/wiki/\([^"/]*\)/#="/wiki/\1_#g' "$1"
|
||||
sed -i 's#="/wiki/\([^"#]*\)\([#"]\)#="\1.html\2#g' "$1"
|
||||
# remove outdated documentation
|
||||
sed -i 's#</ol>#</ol>\n#g' "$1"
|
||||
sed -i '/outdated/,/<\/ol>/d' "$1"
|
||||
# remove "searchable" ids (blue coloring of head lines)
|
||||
sed -i 's#<div id="searchable">#<div>#g' "$1"
|
||||
# fix image sources
|
||||
sed -i 's#src="/file/[^"]*/\([^/\?]*\)["\?]#src="\1"#g' "$1"
|
||||
}
|
||||
|
||||
|
||||
function wrap_wiki_page()
|
||||
{
|
||||
# add header and footer
|
||||
(
|
||||
echo "$page_header"
|
||||
echo '<div class="centercontent">'
|
||||
cat "$1"
|
||||
echo '</div>'
|
||||
echo "$page_footer"
|
||||
) >"${1}.new"
|
||||
mv "${1}.new" "$1"
|
||||
}
|
||||
|
||||
|
||||
function rename_files()
|
||||
{
|
||||
ls | grep "\?format=raw$" | while read fname
|
||||
do local real_name=$(echo "$fname" | sed 's/\?.*$//')
|
||||
mv "$fname" "$real_name"
|
||||
done
|
||||
ls | grep "\.[0-9]*$" | while read fname
|
||||
do rm "$fname"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
function redirect_homepage_links()
|
||||
{
|
||||
ls *.html | while read fname
|
||||
do while grep -q '="http://devel.cryptobox.org/wiki/[^/"]*/' "$fname"
|
||||
do sed -i 's#\(="http://devel.cryptobox.org/wiki/[^/"]*\)/#\1_#g' "$fname"
|
||||
done
|
||||
sed -i 's#="http://devel.cryptobox.org/wiki/\([^"\#]*\)\(["\#]\)#="\1.html\2"#g' "$fname"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
function remove_useless_files()
|
||||
{
|
||||
rm -f robots.txt
|
||||
}
|
||||
|
||||
|
||||
function rename_one_file()
|
||||
{
|
||||
find . -type f | grep -v "/\.svn" | while read fname
|
||||
do sed -i "s#\([^a-zA-Z0-9]\)$1#\1$2#g" "$fname"
|
||||
done
|
||||
mv "$1" "$2"
|
||||
}
|
||||
|
||||
|
||||
function rename_long_files()
|
||||
{
|
||||
# this is necessary to avoid problems with the 31-character restriction of iso9660
|
||||
# on windows systems
|
||||
find . -type f | grep -v "/\.svn" | while read fname
|
||||
do if test 14 -lt "${#fname}"
|
||||
then local neu_prefix=$(echo "${fname:2:6}" | sed 's#/#_#g')
|
||||
local neu_num=0
|
||||
local neu_suffix=$(echo "$fname"| sed 's#^.*\.\([^\.]*\)$#.\1#g')
|
||||
test 5 -lt "${#neu_suffix}" && neu_suffix=.${neu_suffix:-4}
|
||||
while test -e "$neu_prefix$neu_num$neu_suffix"
|
||||
do local i=$((neu_num+1))
|
||||
# we should use the additional step (using 'i') to avoid a bash-specific
|
||||
# handling of self-increment
|
||||
neu_num=$i
|
||||
done
|
||||
rename_one_file "${fname:2}" "$neu_prefix$neu_num$neu_suffix"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
test ! -d "$DEST_DIR" && echo "Destination directory does not exist: $DEST_DIR" && exit 1
|
||||
|
||||
# cleanup destination directory
|
||||
test -e "$DEST_DIR/index.html" && find "$DEST_DIR/" -type f | grep -v "/\.svn" | xargs rm
|
||||
|
||||
cd "$DEST_DIR"
|
||||
|
||||
# retrieve pages from cryptobox.org
|
||||
wget --mirror --page-requisites --no-directories --convert-links --quiet http://cryptobox.org
|
||||
wget --output-document=header.jpg --quiet http://cryptobox.org/gfx/header.jpg
|
||||
|
||||
page_header=$(sed -n '1,/<!-- content starts here -->/p' index.html)
|
||||
page_footer=$(sed -n '/<!-- content ends here -->/,$p' index.html)
|
||||
|
||||
for page in $WIKI_PAGES
|
||||
do filename=${page//\//_}.html
|
||||
wget --no-directories --page-requisites --quiet "http://devel.cryptobox.org/wiki/$page"
|
||||
mv "$(basename $page)" "$filename"
|
||||
prepare_wiki_page "$filename" "$page"
|
||||
wrap_wiki_page "$filename"
|
||||
done
|
||||
|
||||
rename_files
|
||||
redirect_homepage_links
|
||||
remove_useless_files
|
||||
rename_long_files
|
||||
|
5
scripts/prepare_target.sh
Executable file
5
scripts/prepare_target.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
# the samba package requires /proc to be present
|
||||
mount --bind /proc "$1/proc"
|
||||
|
9
scripts/show_TODO.sh
Executable file
9
scripts/show_TODO.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/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.
|
||||
#
|
||||
|
||||
grep "TODO" $(find "$(dirname $0)/.." -type f | grep -v "\.svn" | grep -v "$(basename $0)")
|
147
scripts/validate.sh
Executable file
147
scripts/validate.sh
Executable file
|
@ -0,0 +1,147 @@
|
|||
#!/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$
|
||||
#
|
||||
# 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-misc" ] && rm -r "$VALIDATE_REPORT_DIR/cryptobox-misc"
|
||||
mkdir -p "$VALIDATE_REPORT_DIR/cryptobox-misc"
|
||||
wget -q -O "$VALIDATE_REPORT_DIR/cryptobox-misc/cryptobox.css" http://$VALIDATE_HOST_IP_DEFAULT/cryptobox-misc/cryptobox.css
|
||||
# extract image file names
|
||||
grep "url(" "$VALIDATE_REPORT_DIR/cryptobox.css" | sed 's#^.*url(\(.*\)).*$#\1#' | while read a
|
||||
do wget -q -O "$VALIDATE_REPORT_DIR/cryptobox-misc/$a" "http://$VALIDATE_HOST_IP_DEFAULT/cryptobox-misc/$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-misc/cryptobox.css\"#href=\"../cryptobox-misc/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