Fixed "scripts/cbox-dev.sh diff" (must run devel-features.sh manually first); cleaned up some pre-0.4 files
This commit is contained in:
parent
9d4f3d4f1e
commit
52d19f4ffe
17 changed files with 54 additions and 963 deletions
|
@ -1,237 +0,0 @@
|
|||
#!/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
|
|
@ -21,6 +21,12 @@
|
|||
# problems of this script:
|
||||
# - chroot has to run as root
|
||||
#
|
||||
# jwc 9/08: started modifications to work with CryptoNAS Live
|
||||
|
||||
#Note: It appears to have been a long time since this script was maintained.
|
||||
#(For example, where *was* $DEV_FEATURES_SCRIPT defined previously?)
|
||||
#It may work or it may fail.
|
||||
DEV_FEATURES_SCRIPT="/usr/share/cryptonas-live/devel-features.sh"
|
||||
|
||||
set -ue
|
||||
|
||||
|
@ -61,7 +67,7 @@ function upload2box()
|
|||
# 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"
|
||||
local DIRS="var/www usr/share/cryptobox-server usr/share/cryptonas-live"
|
||||
echo "Uploading the following dirs: $DIRS "
|
||||
[ -e "$TMP_DIR" ] || mkdir -p "$TMP_DIR"
|
||||
for a in $DIRS
|
||||
|
@ -137,14 +143,11 @@ case "$1" in
|
|||
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 "Syntax: `basename $0` ( qemu | chroot | upload | diff | merge | ssh | help )"
|
||||
echo
|
||||
;;
|
||||
* )
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
#!/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