summaryrefslogtreecommitdiff
path: root/testing/scripts
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2006-05-22 05:12:18 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2006-05-22 05:12:18 +0000
commitaa0f5b38aec14428b4b80e06f90ff781f8bca5f1 (patch)
tree95f3d0c8cb0d59d88900dbbd72110d7ab6e15b2a /testing/scripts
parent7c383bc22113b23718be89fe18eeb251942d7356 (diff)
downloadvyos-strongswan-aa0f5b38aec14428b4b80e06f90ff781f8bca5f1.tar.gz
vyos-strongswan-aa0f5b38aec14428b4b80e06f90ff781f8bca5f1.zip
Import initial strongswan 2.7.0 version into SVN.
Diffstat (limited to 'testing/scripts')
-rwxr-xr-xtesting/scripts/build-hostconfig103
-rwxr-xr-xtesting/scripts/build-sshkeys88
-rwxr-xr-xtesting/scripts/build-umlhostfs78
-rwxr-xr-xtesting/scripts/build-umlkernel134
-rwxr-xr-xtesting/scripts/build-umlrootfs174
-rwxr-xr-xtesting/scripts/function.sh82
-rwxr-xr-xtesting/scripts/kstart-umls113
-rwxr-xr-xtesting/scripts/load-testconfig64
-rwxr-xr-xtesting/scripts/restore-defaults53
-rwxr-xr-xtesting/scripts/start-switches39
-rwxr-xr-xtesting/scripts/start-umls113
-rwxr-xr-xtesting/scripts/xstart-umls113
12 files changed, 1154 insertions, 0 deletions
diff --git a/testing/scripts/build-hostconfig b/testing/scripts/build-hostconfig
new file mode 100755
index 000000000..0df8861c8
--- /dev/null
+++ b/testing/scripts/build-hostconfig
@@ -0,0 +1,103 @@
+#!/bin/bash
+# build the hosts configuration directory with the actual IP addresses
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: build-hostconfig,v 1.3 2005/02/08 10:40:48 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
+[ -d $DIR/../hosts ] || die "!! Directory 'hosts' not found"
+
+source $DIR/../testing.conf
+
+if [ ! -d $BUILDDIR ]
+then
+ cecho " * Creating directory '$BUILDDIR'"
+ mkdir $BUILDDIR
+fi
+
+########################################
+# copy default host configs to $BUILDDIR
+#
+
+HOSTCONFIGDIR=${BUILDDIR}/hosts
+
+if [ -d $HOSTCONFIGDIR ]
+then
+ rm -r $HOSTCONFIGDIR
+fi
+
+mkdir $HOSTCONFIGDIR
+cp -rfp ${UMLTESTDIR}/testing/hosts $BUILDDIR
+
+cecho " * Copied default host config directory to '$HOSTCONFIGDIR'"
+
+########################################
+# assign IP for each host to hostname
+#
+
+cecho-n " * Generate default config for.."
+
+HOSTIP=`ifconfig eth0 |grep inet |sed -e "s/.*inet addr://" -e "s/ Bcast.*//"`
+
+for host in $STRONGSWANHOSTS
+do
+ cecho-n "${host}.."
+ eval ip_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $1 }' | awk '{ print $1 }'`"
+
+ [ "`eval echo \\\$ip_${host}`" != "$HOSTIP" ] || die "$host has the same IP as eth0 (Host)! Please change that."
+
+ case $host in
+ moon)
+ eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
+ [ "`eval echo \\\$ip1_${host}`" != "$HOSTIP" ] || die "eth1 of $host has the same IP as eth0 (Host)! Please change that."
+ searchandreplace PH_IP_MOON $ip_moon $HOSTCONFIGDIR
+ searchandreplace PH_IP1_MOON $ip1_moon $HOSTCONFIGDIR
+ ;;
+ sun)
+ eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
+ [ "`eval echo \\\$ip1_${host}`" != "$HOSTIP" ] || die "eth1 of $host has the same IP as eth0 (Host)! Please change that."
+ searchandreplace PH_IP_SUN $ip_sun $HOSTCONFIGDIR
+ searchandreplace PH_IP1_SUN $ip1_sun $HOSTCONFIGDIR
+ ;;
+ alice)
+ searchandreplace PH_IP_ALICE $ip_alice $HOSTCONFIGDIR
+ ;;
+ venus)
+ searchandreplace PH_IP_VENUS $ip_venus $HOSTCONFIGDIR
+ ;;
+ bob)
+ searchandreplace PH_IP_BOB $ip_bob $HOSTCONFIGDIR
+ ;;
+ carol)
+ eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
+ searchandreplace PH_IP_CAROL $ip_carol $HOSTCONFIGDIR
+ searchandreplace PH_IP1_CAROL $ip1_carol $HOSTCONFIGDIR
+ ;;
+ dave)
+ eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
+ searchandreplace PH_IP_DAVE $ip_dave $HOSTCONFIGDIR
+ searchandreplace PH_IP1_DAVE $ip1_dave $HOSTCONFIGDIR
+ ;;
+ winnetou)
+ searchandreplace PH_IP_WINNETOU $ip_winnetou $HOSTCONFIGDIR
+ ;;
+ esac
+done
+
+cecho "done"
diff --git a/testing/scripts/build-sshkeys b/testing/scripts/build-sshkeys
new file mode 100755
index 000000000..f4d584d6b
--- /dev/null
+++ b/testing/scripts/build-sshkeys
@@ -0,0 +1,88 @@
+#!/bin/bash
+# build the hosts configuration directory with the actual IP addresses
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: build-sshkeys,v 1.2 2005/02/15 14:12:16 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
+[ -d $DIR/../hosts ] || die "!! Directory 'hosts' not found"
+
+source $DIR/../testing.conf
+
+if [ ! -d $BUILDDIR ]
+then
+ cecho " * Creating directory '$BUILDDIR'"
+ mkdir $BUILDDIR
+fi
+
+LOGFILE=${BUILDDIR}/testing.log
+
+if [ ! -f $LOGFILE ]
+then
+ cecho-n " * Logfile '$LOGFILE' does not exist..creating.."
+ touch $LOGFILE
+ cecho "done"
+fi
+
+if [ ! -d ~/.ssh ]
+then
+ cecho-n " * Creating directory '~/.ssh'.."
+ mkdir ~/.ssh
+ cecho "done"
+fi
+
+if [ -f ~/.ssh/known_hosts ]
+then
+ cecho-n " * Backing up ~/.ssh/known_hosts to '~/.ssh/known_hosts.before_uml'.."
+ cp -fp ~/.ssh/known_hosts ~/.ssh/known_hosts.before_uml
+ cecho "done"
+else
+ cecho-n " * Creating '~/.ssh/known_hosts'"
+ touch ~/.ssh/known_hosts
+ cecho "done"
+fi
+
+for host in $HOSTNAMEIPS
+do
+ HOSTNAME=`echo $host | awk -F : '{ print $1 }'`
+ IP=`echo $host | awk -F : '{ print $2 }'`
+ if [ `grep "$IP " ~/.ssh/known_hosts | wc -l` != "0" ]
+ then
+ cecho "!! Warning: An entry exists for the following IP address: $IP"
+ else
+ cecho-n " * Adding uml host $HOSTNAME ($IP) to '~/.ssh/known_hosts'.."
+ echo "$HOSTNAME,$IP `cat $DIR/../hosts/ssh_host_rsa_key.pub`" >> ~/.ssh/known_hosts
+ cecho "done"
+ fi
+done
+
+#####################################
+# preparing ssh for PK authentication
+#
+
+cecho-n " * Checking for ssh rsa key '~/.ssh/id_rsa.pub'.."
+if [ -f ~/.ssh/id_rsa.pub ]
+then
+ cecho "already exists"
+else
+ cecho "not found"
+ cecho-n " * Generating ssh rsa key pair.."
+ echo "" | ssh-keygen -N "" -t rsa -f ~/.ssh/id_rsa >> $LOGFILE 2>&1
+ cecho "done"
+fi
diff --git a/testing/scripts/build-umlhostfs b/testing/scripts/build-umlhostfs
new file mode 100755
index 000000000..e77bfc025
--- /dev/null
+++ b/testing/scripts/build-umlhostfs
@@ -0,0 +1,78 @@
+#!/bin/bash
+# create UML host file systems
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: build-umlhostfs,v 1.3 2006/03/30 21:20:27 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found."
+
+source $DIR/../testing.conf
+
+cd $BUILDDIR/root-fs
+
+[ -f gentoo-fs ] || die "!! Root file system 'gentoo-fs' not found."
+
+if [ ! -d $BUILDDIR ]
+then
+ cecho-n " * Directory '$BUILDDIR' does not exist..creating.."
+ mkdir $BUILDDIR
+ cecho "done"
+fi
+
+LOGFILE=${BUILDDIR}/testing.log
+
+if [ ! -f $LOGFILE ]
+then
+ cecho-n " * Logfile '$LOGFILE' does not exist..creating.."
+ touch $LOGFILE
+ cecho "done"
+fi
+
+LOOPDIR=loop
+
+if [ ! -d $LOOPDIR ]
+then
+ mkdir $LOOPDIR
+fi
+
+cecho-n " * Creating root filesystem for.."
+
+if [ "$#" -eq 0 ]
+then
+ HOSTS=$STRONGSWANHOSTS
+else
+ HOSTS=$*
+fi
+
+for host in $HOSTS
+do
+ cecho-n "$host.."
+ cp gentoo-fs gentoo-fs-$host
+ mount -o loop gentoo-fs-$host $LOOPDIR
+ cp -rfp $BUILDDIR/hosts/${host}/etc $LOOPDIR
+ if [ "$host" = "winnetou" ]
+ then
+ cp -rfp $UMLTESTDIR/testing/images $LOOPDIR/var/www/localhost/htdocs
+ chroot $LOOPDIR /etc/openssl/generate-crl >> $LOGFILE 2>&1
+ fi
+ chroot $LOOPDIR /etc/init.d/depscan.sh --update >> $LOGFILE 2>&1
+ umount $LOOPDIR
+done
+
+cecho "done"
diff --git a/testing/scripts/build-umlkernel b/testing/scripts/build-umlkernel
new file mode 100755
index 000000000..074d7847a
--- /dev/null
+++ b/testing/scripts/build-umlkernel
@@ -0,0 +1,134 @@
+#!/bin/bash
+# build an UML kernel based on a vanilla kernel and UML patch
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: build-umlkernel,v 1.2 2005/01/09 21:54:25 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "configuration file 'testing.conf' not found"
+
+source $DIR/../testing.conf
+
+cecho-n " * Looking for kernel at '$KERNEL'.."
+if [ -f "${KERNEL}" ]
+then
+ cecho "found it"
+ KERNELVERSION=`basename $KERNEL .tar.bz2 | sed -e 's/linux-//'`
+ cecho " * Kernel version is $KERNELVERSION"
+else
+ cecho "none"
+ exit
+fi
+
+if [ ${UMLPATCH} ]
+then
+ cecho-n " * Looking for uml patch at '$UMLPATCH'.."
+ if [ -f "${UMLPATCH}" ]
+ then
+ cecho "found it"
+ else
+ cecho "none"
+ exit
+ fi
+fi
+
+cecho-n " * Looking for kernel config at '$KERNELCONFIG'.."
+if [ -f "${KERNEL}" ]
+then
+ cecho "found it"
+else
+ cecho "none"
+ exit
+fi
+
+#######################################################
+# unpack kernel and create symlink
+#
+
+if [ ! -d $BUILDDIR ]
+then
+ cecho " * Creating directory '$BUILDDIR'"
+ mkdir $BUILDDIR
+fi
+
+cecho " * Changing to directory '$BUILDDIR'"
+cd $BUILDDIR
+
+LOGFILE=${BUILDDIR}/testing.log
+
+if [ ! -f $LOGFILE ]
+then
+ cecho-n " * Logfile '$LOGFILE' does not exist..creating.."
+ touch $LOGFILE
+ cecho "done"
+fi
+
+cecho-n " * Unpacking kernel.."
+tar xjf $KERNEL >> $LOGFILE 2>&1
+cecho "done"
+
+KERNELDIR=${BUILDDIR}/linux-${KERNELVERSION}
+
+if [ -d $KERNELDIR ]
+then
+ cecho " * Kernel directory is '$KERNELDIR'"
+ cecho " * Creating symlink 'linux'"
+ if [ -d linux ]
+ then
+ rm linux
+ fi
+ ln -s linux-${KERNELVERSION} linux
+else
+ cecho "!! Kernel directory '$KERNELDIR' can not be found"
+ exit
+fi
+
+#######################################################
+# patch kernel
+#
+
+cecho " * Changing to directory '$KERNELDIR'"
+cd $KERNELDIR
+
+if [ $UMLPATCH ]
+then
+ cecho-n " * Applying uml patch.."
+ bzcat $UMLPATCH | patch -p1 >> $LOGFILE 2>&1
+ cecho "done"
+fi
+
+#######################################################
+# copy our default .config to linux and build kernel
+#
+
+cp $KERNELCONFIG .config
+
+cecho "!!"
+cecho "!! Making .config for kernel. You might be prompted for new parameters!"
+cecho "!!"
+make oldconfig ARCH=um >> $LOGFILE 2>&1
+
+cecho-n " * Now compiling uml kernel.."
+make linux ARCH=um >> $LOGFILE 2>&1
+cecho "done"
+
+cecho-n " * Copying uml kernel to '${BUILDDIR}/linux-uml-${KERNELVERSION}'.."
+mv linux ${BUILDDIR}/linux-uml-${KERNELVERSION}
+cecho "done"
+
+
diff --git a/testing/scripts/build-umlrootfs b/testing/scripts/build-umlrootfs
new file mode 100755
index 000000000..ba103838f
--- /dev/null
+++ b/testing/scripts/build-umlrootfs
@@ -0,0 +1,174 @@
+#!/bin/bash
+# Create UML root filesystem
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: build-umlrootfs,v 1.11 2006/01/08 22:29:56 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
+
+source $DIR/../testing.conf
+
+STRONGSWANVERSION=`basename $STRONGSWAN .tar.bz2`
+
+cecho-n " * Looking for strongSwan at '$STRONGSWAN'.."
+if [ -f "$STRONGSWAN" ]
+then
+ cecho "found it"
+ cecho " * strongSwan version is '$STRONGSWANVERSION'"
+else
+ cecho "none"
+ exit
+fi
+
+cecho-n " * Looking for gentoo root filesystem at '$ROOTFS'.."
+if [ -f "$ROOTFS" ]
+then
+ cecho "found it"
+else
+ cecho "none"
+ exit
+fi
+
+[ -d $BUILDDIR ] || die "!! Directory '$BUILDDIR' does not exist"
+
+HOSTCONFIGDIR=$BUILDDIR/hosts
+
+[ -d $HOSTCONFIGDIR ] || die "!! Directory '$HOSTCONFIGDIR' does not exist"
+
+LOGFILE=$BUILDDIR/testing.log
+
+if [ ! -f $LOGFILE ]
+then
+ cecho-n " * Logfile '$LOGFILE' does not exist..creating.."
+ touch $LOGFILE
+ cecho "done"
+fi
+
+ROOTFSDIR=$BUILDDIR/root-fs
+
+if [ ! -d $ROOTFSDIR ]
+then
+ cecho-n " * Root file system directory '$ROOTFSDIR' does not exist..creating.."
+ mkdir $ROOTFSDIR
+ cecho "done"
+fi
+
+cd $ROOTFSDIR
+
+LOOPDIR=$ROOTFSDIR/loop
+
+if [ ! -d $LOOPDIR ]
+then
+ mkdir $LOOPDIR
+fi
+
+######################################################
+# creating reiser-based uml root filesystem
+#
+
+cecho-n " * Building basic root filesystem (gentoo).."
+dd if=/dev/zero of=gentoo-fs count=$ROOTFSSIZE bs=1M >> $LOGFILE 2>&1
+mkreiserfs -q -f gentoo-fs >> $LOGFILE 2>&1
+mount -o loop gentoo-fs $LOOPDIR >> $LOGFILE 2>&1
+tar xjpf $ROOTFS -C $LOOPDIR >> $LOGFILE 2>&1
+cecho "done"
+
+
+######################################################
+# copying default /etc/hosts to the root filesystem
+#
+cecho " * Copying '$HOSTCONFIGDIR/default/etc/hosts' to the root filesystem"
+cp -fp $HOSTCONFIGDIR/default/etc/hosts $LOOPDIR/etc/hosts
+
+#
+#####################################################
+# extracting strongSwan into the root filesystem
+#
+
+cecho " * Extracting strongSwan into the root filesystem"
+tar xjf $STRONGSWAN -C $LOOPDIR/root >> $LOGFILE 2>&1
+
+
+######################################################
+# installing strongSwan and setting the local timezone
+#
+
+INSTALLSHELL=${LOOPDIR}/install.sh
+
+cecho " * Preparing strongSwan installation script"
+echo "ln -sf /usr/share/zoneinfo/${TZUML} /etc/localtime" >> $INSTALLSHELL
+
+if [ "$USE_LIBCURL" = "yes" ]
+then
+ echo "export USE_LIBCURL=true" >> $INSTALLSHELL
+fi
+
+if [ "$USE_LDAP" = "yes" ]
+then
+ echo "export USE_LDAP=true" >> $INSTALLSHELL
+fi
+
+echo "export USERCOMPILE=\'-DRANDOM_DEVICE=\\\"/dev/urandom\\\"\'" >> $INSTALLSHELL
+echo "cd /root/${STRONGSWANVERSION}" >> $INSTALLSHELL
+echo "make programs" >> $INSTALLSHELL
+echo "make install" >> $INSTALLSHELL
+
+cecho-n " * Compiling $STRONGSWANVERSION within the root file system as chroot.."
+chroot $LOOPDIR /bin/bash /install.sh >> $LOGFILE 2>&1
+cecho "done"
+
+rm -f $INSTALLSHELL
+
+
+######################################################
+# copying the host's ssh public key
+#
+
+if [ ! -d $LOOPDIR/root/.ssh ]
+then
+ mkdir $LOOPDIR/root/.ssh
+fi
+cp ~/.ssh/id_rsa.pub $LOOPDIR/root/.ssh/authorized_keys
+
+######################################################
+# setup public key based login among all hosts
+#
+cp $LOOPDIR/etc/ssh/ssh_host_rsa_key $LOOPDIR/root/.ssh/id_rsa
+
+for host in $STRONGSWANHOSTS
+do
+ eval ip="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $1 }' | awk '{ print $1 }'`"
+ echo "$host,$ip `cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub`" >> $LOOPDIR/root/.ssh/known_hosts
+ echo "`cat $HOSTCONFIGDIR/ssh_host_rsa_key.pub` root@$host" >> $LOOPDIR/root/.ssh/authorized_keys
+done
+
+######################################################
+# defining an empty modules.dep
+#
+
+if [ $UMLPATCH ]
+then
+ mkdir $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um
+ touch $LOOPDIR/lib/modules/`basename $UMLPATCH .bz2 | sed s/uml-patch-//`um/modules.dep
+else
+ mkdir $LOOPDIR/lib/modules/$KERNELVERSION
+ touch $LOOPDIR/lib/modules/$KERNELVERSION/modules.dep
+fi
+
+umount $LOOPDIR
diff --git a/testing/scripts/function.sh b/testing/scripts/function.sh
new file mode 100755
index 000000000..22a79698d
--- /dev/null
+++ b/testing/scripts/function.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+# provides some general-purpose script functions
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: function.sh,v 1.3 2005/02/16 22:20:52 as Exp $
+
+
+############################################
+# print output in color
+#
+
+function cecho {
+ echo -e "\033\13301;31m$1\033\1330m"
+}
+
+function cecho-n {
+ echo -en "\033\13301;31m$1\033\1330m"
+}
+
+
+#############################################
+# output all args to stderr and exit with
+# return code 1
+#
+
+die() {
+ echo $* 1>&2
+ exit 1
+}
+
+#############################################
+# search and replace strings throughout a
+# whole directory
+#
+
+function searchandreplace {
+
+ SEARCHSTRING="$1"
+ REPLACESTRING="$2"
+ DESTDIR="$3"
+
+ [ -d "$DESTDIR" ] || die "$DESTDIR is not a directory!"
+
+
+ #########################
+ # create a temporary file
+ #
+
+ TMPFILE="/tmp/sr.$$"
+
+
+ ###########################################
+ # search and replace in each found file the
+ # given string
+ #
+
+ for eachfoundfile in `find $DESTDIR -type f`
+ do
+ sed -e "s/$SEARCHSTRING/$REPLACESTRING/g" "$eachfoundfile" > "$TMPFILE"
+ cp -f "$TMPFILE" "$eachfoundfile"
+ done
+
+
+ ###########################
+ # delete the temporary file
+ #
+
+ rm -f "$TMPFILE"
+
+}
diff --git a/testing/scripts/kstart-umls b/testing/scripts/kstart-umls
new file mode 100755
index 000000000..a533fb728
--- /dev/null
+++ b/testing/scripts/kstart-umls
@@ -0,0 +1,113 @@
+#!/bin/bash
+# starts the UML instances in a konsole (requires KDE)
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: kstart-umls,v 1.6 2005/08/30 22:13:12 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found"
+
+source $DIR/../testing.conf
+
+if [ "$#" -eq 0 ]
+then
+ HOSTS=$STRONGSWANHOSTS
+else
+ HOSTS=$*
+fi
+
+BOOTING_HOSTS=""
+count_max=12
+count=0
+
+for host in $HOSTS
+do
+ up=0
+
+ if [ -d ~/.uml/${host} ]
+ then
+ pid=`cat ~/.uml/${host}/pid`
+ up=`ps up $pid | wc -l`
+ fi
+
+ if [ $up -eq 2 ]
+ then
+ cecho " * Great, ${host} is already running!"
+ else
+ rm -rf ~/.uml/${host}
+ BOOTING_HOSTS="$BOOTING_HOSTS ${host}"
+ let "count_max += 12"
+
+ UMLHOSTFS=$BUILDDIR/root-fs/gentoo-fs-${host}
+ [ -f $UMLHOSTFS ] || die "!! uml root file system '$UMLHOSTFS' not found"
+
+ cecho-n " * Starting ${host}.."
+ eval konsole -title ${host} -e "$UMLKERNEL \
+ umid=${host} \
+ ubda=$UMLHOSTFS \
+ \$SWITCH_${host} \
+ mem=${MEM}M con=pty con0=fd:0,fd:1" &
+ cecho "done"
+ fi
+done
+
+if [ -z "$BOOTING_HOSTS" ]
+then
+ exit 0
+fi
+
+cecho " * Waiting for the uml instances to finish booting"
+
+for host in $BOOTING_HOSTS
+do
+ cecho-n " * Checking on $host.."
+
+ while [ $count -lt $count_max ] && [ ! -d ~/.uml/$host ]
+ do
+ cecho-n "."
+ sleep 5
+ let "count+=1"
+ done
+
+ if [ $count -ge $count_max ]
+ then
+ cecho "exit"
+ exit 1
+ fi
+
+ pid=`cat ~/.uml/$host/pid`
+ up=`ps up $pid | grep agetty | wc -l`
+
+ while [ $count -lt $count_max ] && [ $up -eq 0 ]
+ do
+ cecho-n "."
+ sleep 5
+ up=`ps up $pid | grep agetty | wc -l`
+ let "count+=1"
+ done
+
+ if [ $count -ge $count_max ]
+ then
+ cecho "exit"
+ exit 1
+ else
+ cecho "up"
+ fi
+done
+
+cecho " * All uml instances are up now"
diff --git a/testing/scripts/load-testconfig b/testing/scripts/load-testconfig
new file mode 100755
index 000000000..89da17e72
--- /dev/null
+++ b/testing/scripts/load-testconfig
@@ -0,0 +1,64 @@
+#!/bin/bash
+# Load test specific host configurations
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: load-testconfig,v 1.2 2004/12/13 21:02:42 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found"
+
+source $DIR/../testing.conf
+
+##########################################################################
+# load-testconfig requires a testname as an argument
+#
+
+testname=$1
+
+TESTSDIR=$BUILDDIR/tests
+
+[ -d $TESTSDIR ] || die "Directory '$TESTSDIR' not found"
+[ -d $TESTSDIR/$testname ] || die "Test '$testname' not found"
+[ -f $TESTSDIR/$testname/test.conf ] || die "File 'test.conf' is missing"
+
+source $TESTSDIR/$testname/test.conf
+
+##########################################################################
+# copy test specific configurations to uml hosts
+#
+
+if [ -d $TESTSDIR/$testname/hosts ]
+then
+ for host in `ls $TESTSDIR/$testname/hosts`
+ do
+ eval HOSTLOGIN="root@`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $1 }' | awk '{ print $1 }'`"
+ scp -rp $TESTSDIR/$testname/hosts/$host/etc $HOSTLOGIN:/ > /dev/null 2>&1
+ done
+fi
+
+
+##########################################################################
+# clear the auth.log where IKE messages are logged
+#
+
+for host in $IPSECHOSTS
+do
+ eval HOSTLOGIN="root@`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $1 }' | awk '{ print $1 }'`"
+ ssh $HOSTLOGIN 'rm -f /var/log/auth.log; \
+ kill -SIGHUP `cat /var/run/syslogd.pid`' > /dev/null 2>&1
+done
diff --git a/testing/scripts/restore-defaults b/testing/scripts/restore-defaults
new file mode 100755
index 000000000..129e46f56
--- /dev/null
+++ b/testing/scripts/restore-defaults
@@ -0,0 +1,53 @@
+#!/bin/bash
+# Restore the default host configurations
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: restore-defaults,v 1.2 2004/12/20 07:56:33 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found"
+
+source $DIR/../testing.conf
+
+##########################################################################
+# load-testconfig requires a testname as an argument
+#
+
+testname=$1
+
+HOSTCONFIGDIR=$BUILDDIR/hosts
+TESTSDIR=$BUILDDIR/tests
+
+[ -d $TESTSDIR ] || die "Directory '$TESTSDIR' not found"
+[ -d $TESTSDIR/$testname ] || die "Test '$testname' not found"
+[ -f $TESTSDIR/$testname/test.conf ] || die "File 'test.conf' is missing"
+
+source $TESTSDIR/$testname/test.conf
+
+##########################################################################
+# copy default host config back if necessary
+#
+
+if [ -d $TESTSDIR/${testname}/hosts ]
+then
+ for host in `ls $TESTSDIR/${testname}/hosts`
+ do
+ eval HOSTLOGIN="root@`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $1 }' | awk '{ print $1 }'`"
+ scp -rp $HOSTCONFIGDIR/${host}/etc $HOSTLOGIN:/ > /dev/null 2>&1
+ done
+fi
diff --git a/testing/scripts/start-switches b/testing/scripts/start-switches
new file mode 100755
index 000000000..c90c9f86d
--- /dev/null
+++ b/testing/scripts/start-switches
@@ -0,0 +1,39 @@
+#!/bin/bash
+# starts the UML switches
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: start-switches,v 1.2 2004/12/19 19:17:25 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found"
+
+source $DIR/../testing.conf
+
+for n in 0 1 2
+do
+ if [ `ps aux | grep uml_switch | grep umlswitch$n | wc -l` -eq 1 ]
+ then
+ cecho " * Great, umlswitch$n is already running!"
+ else
+ cecho-n " * Starting umlswitch$n.."
+ uml_switch -tap tap$n -unix /tmp/umlswitch$n >/dev/null </dev/null &
+ sleep 2
+ eval ifconfig "tap$n \$IFCONFIG_$n up"
+ cecho "done"
+ fi
+done
diff --git a/testing/scripts/start-umls b/testing/scripts/start-umls
new file mode 100755
index 000000000..f51791dfa
--- /dev/null
+++ b/testing/scripts/start-umls
@@ -0,0 +1,113 @@
+#!/bin/bash
+# starts the UML instances with a hidden screen
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: start-umls,v 1.5 2005/08/30 22:13:12 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found"
+
+source $DIR/../testing.conf
+
+if [ "$#" -eq 0 ]
+then
+ HOSTS=$STRONGSWANHOSTS
+else
+ HOSTS=$*
+fi
+
+BOOTING_HOSTS=""
+count_max=12
+count=0
+
+for host in $HOSTS
+do
+ up=0
+
+ if [ -d ~/.uml/${host} ]
+ then
+ pid=`cat ~/.uml/${host}/pid`
+ up=`ps up $pid | wc -l`
+ fi
+
+ if [ $up -eq 2 ]
+ then
+ cecho " * Great, ${host} is already running!"
+ else
+ rm -rf ~/.uml/${host}
+ BOOTING_HOSTS="$BOOTING_HOSTS ${host}"
+ let "count_max += 12"
+
+ UMLHOSTFS=$BUILDDIR/root-fs/gentoo-fs-${host}
+ [ -f $UMLHOSTFS ] || die "!! uml root file system '$UMLHOSTFS' not found"
+
+ cecho-n " * Starting ${host}.."
+ eval screen -dmS ${host} "$UMLKERNEL \
+ umid=${host} \
+ ubda=$UMLHOSTFS \
+ \$SWITCH_${host} \
+ mem=${MEM}M con=pty con0=fd:0,fd:1"
+ cecho "done"
+ fi
+done
+
+if [ -z "$BOOTING_HOSTS" ]
+then
+ exit 0
+fi
+
+cecho " * Waiting for the uml instances to finish booting"
+
+for host in $BOOTING_HOSTS
+do
+ cecho-n " * Checking on $host.."
+
+ while [ $count -lt $count_max ] && [ ! -d ~/.uml/$host ]
+ do
+ cecho-n "."
+ sleep 5
+ let "count+=1"
+ done
+
+ if [ $count -ge $count_max ]
+ then
+ cecho "exit"
+ exit 1
+ fi
+
+ pid=`cat ~/.uml/$host/pid`
+ up=`ps up $pid | grep agetty | wc -l`
+
+ while [ $count -lt $count_max ] && [ $up -eq 0 ]
+ do
+ cecho-n "."
+ sleep 5
+ up=`ps up $pid | grep agetty | wc -l`
+ let "count+=1"
+ done
+
+ if [ $count -ge $count_max ]
+ then
+ cecho "exit"
+ exit 1
+ else
+ cecho "up"
+ fi
+done
+
+cecho " * All uml instances are up now"
diff --git a/testing/scripts/xstart-umls b/testing/scripts/xstart-umls
new file mode 100755
index 000000000..13c5d10a1
--- /dev/null
+++ b/testing/scripts/xstart-umls
@@ -0,0 +1,113 @@
+#!/bin/bash
+# starts the UML instances in an xterm (requires X11R6)
+#
+# Copyright (C) 2004 Eric Marchionni, Patrik Rayo
+# Zuercher Hochschule Winterthur
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: xstart-umls,v 1.6 2005/08/30 22:13:12 as Exp $
+
+DIR=`dirname $0`
+
+source $DIR/function.sh
+
+[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found"
+
+source $DIR/../testing.conf
+
+if [ "$#" -eq 0 ]
+then
+ HOSTS=$STRONGSWANHOSTS
+else
+ HOSTS=$*
+fi
+
+BOOTING_HOSTS=""
+count_max=12
+count=0
+
+for host in $HOSTS
+do
+ up=0
+
+ if [ -d ~/.uml/${host} ]
+ then
+ pid=`cat ~/.uml/${host}/pid`
+ up=`ps up $pid | wc -l`
+ fi
+
+ if [ $up -eq 2 ]
+ then
+ cecho " * Great, ${host} is already running!"
+ else
+ rm -rf ~/.uml/${host}
+ BOOTING_HOSTS="$BOOTING_HOSTS ${host}"
+ let "count_max += 12"
+
+ UMLHOSTFS=$BUILDDIR/root-fs/gentoo-fs-${host}
+ [ -f $UMLHOSTFS ] || die "!! uml root file system '$UMLHOSTFS' not found"
+
+ cecho-n " * Starting ${host}.."
+ eval xterm -title ${host} -rightbar -sb -sl 500 -e "$UMLKERNEL \
+ umid=${host} \
+ ubda=$UMLHOSTFS \
+ \$SWITCH_${host} \
+ mem=${MEM}M con=pty con0=fd:0,fd:1" &
+ cecho "done"
+ fi
+done
+
+if [ -z "$BOOTING_HOSTS" ]
+then
+ exit 0
+fi
+
+cecho " * Waiting for the uml instances to finish booting"
+
+for host in $BOOTING_HOSTS
+do
+ cecho-n " * Checking on $host.."
+
+ while [ $count -lt $count_max ] && [ ! -d ~/.uml/$host ]
+ do
+ cecho-n "."
+ sleep 5
+ let "count+=1"
+ done
+
+ if [ $count -ge $count_max ]
+ then
+ cecho "exit"
+ exit 1
+ fi
+
+ pid=`cat ~/.uml/$host/pid`
+ up=`ps up $pid | grep agetty | wc -l`
+
+ while [ $count -lt $count_max ] && [ $up -eq 0 ]
+ do
+ cecho-n "."
+ sleep 5
+ up=`ps up $pid | grep agetty | wc -l`
+ let "count+=1"
+ done
+
+ if [ $count -ge $count_max ]
+ then
+ cecho "exit"
+ exit 1
+ else
+ cecho "up"
+ fi
+done
+
+cecho " * All uml instances are up now"