From: Reto Buerki Date: Thu, 6 Dec 2012 18:03:45 +0000 (+0100) Subject: Import testing.conf file in function.sh X-Git-Tag: 5.0.2rc1~1^2~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c2ef58e86c10e0cf9846dc9211cc68c7e908f7f;p=thirdparty%2Fstrongswan.git Import testing.conf file in function.sh This is needed to have access to $LOGFILE and possibly other config settings. --- diff --git a/testing/scripts/build-baseimage b/testing/scripts/build-baseimage index 08da30f083..4b81c5cdbc 100755 --- a/testing/scripts/build-baseimage +++ b/testing/scripts/build-baseimage @@ -2,15 +2,10 @@ echo "Building base image" -DIR=`dirname $0` - -. $DIR/function.sh +. $PWD/scripts/function.sh [ `id -u` -eq 0 ] || die "You must be root to run $0" -[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found" -. $DIR/../testing.conf - # additional packages EXTRAS=build-essential,gperf,libgmp-dev,libldap2-dev,libcurl4-openssl-dev,libxml2-dev,libtspi-dev,libsqlite3-dev,openssh-server,tcpdump,psmisc,openssl,vim,sqlite3,conntrack,gdb,cmake,libxerces-c2-dev,libltdl-dev,liblog4cxx10-dev,libboost-thread-dev,libboost-system-dev,git-core SERVICES="isc-dhcp-server apache2 slapd" diff --git a/testing/scripts/build-umlhostfs b/testing/scripts/build-umlhostfs index ada9696c76..e5355988cd 100755 --- a/testing/scripts/build-umlhostfs +++ b/testing/scripts/build-umlhostfs @@ -16,18 +16,13 @@ echo "Creating guest images" -DIR=`dirname $0` - -. $DIR/function.sh +. $PWD/scripts/function.sh [ `id -u` -eq 0 ] || die "You must be root to run $0" -[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found" -. $DIR/../testing.conf - BASE=$BUILDDIR/base.img ROOTFSDIR=$BUILDDIR/root-fs -HOSTSDIR=$DIR/../hosts +HOSTSDIR=$PWD/hosts [ -f $BASE ] || die "Base image $BASE not found" [ -f $HOSTDIR ] || die "Hosts directory $HOSTSDIR not found" diff --git a/testing/scripts/build-umlkernel b/testing/scripts/build-umlkernel index 3947e4ab1a..6e17af430d 100755 --- a/testing/scripts/build-umlkernel +++ b/testing/scripts/build-umlkernel @@ -14,12 +14,7 @@ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. -DIR=`dirname $0` -. $DIR/function.sh - -[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found" - -. $DIR/../testing.conf +. $PWD/scripts/function.sh echo "Building guest kernel version $KERNELVERSION" diff --git a/testing/scripts/build-umlrootfs b/testing/scripts/build-umlrootfs index a0444de385..6c67a25342 100755 --- a/testing/scripts/build-umlrootfs +++ b/testing/scripts/build-umlrootfs @@ -16,15 +16,10 @@ echo "Building root image" -DIR=`dirname $0` - -. $DIR/function.sh +. $PWD/scripts/function.sh [ `id -u` -eq 0 ] || die "You must be root to run $0" -[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found" -. $DIR/../testing.conf - [ -f "$ROOTFS" ] || die "Root image $ROOTFS not found" ROOTFSDIR=$BUILDDIR/root-fs diff --git a/testing/scripts/function.sh b/testing/scripts/function.sh index a04490aecc..3e0560a46c 100755 --- a/testing/scripts/function.sh +++ b/testing/scripts/function.sh @@ -14,6 +14,21 @@ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. +export TERM=xterm +RED=$(tput setaf 1) +GREEN=$(tput setaf 2) +NORMAL=$(tput op) + +# exit with given error message +# $1 - error message +die() { + echo -e "${RED}$1${NORMAL}" + exit 1 +} + +[ -f testing.conf ] || die "Configuration file 'testing.conf' not found" +. testing.conf + # execute command # $1 - command to execute # $2 - whether or not to log command exit status @@ -40,11 +55,6 @@ execute_chroot() execute "chroot $LOOPDIR $@" } -export TERM=xterm -RED=$(tput setaf 1) -GREEN=$(tput setaf 2) -NORMAL=$(tput op) - function cecho { echo -e "\033[1;31m$1\033[0m" } @@ -76,13 +86,6 @@ log_status() echo } -# exit with given error message -# $1 - error message -die() { - echo -e "${RED}$1${NORMAL}" - exit 1 -} - ############################################# # search and replace strings throughout a # whole directory diff --git a/testing/scripts/install-shared b/testing/scripts/install-shared index 4cfac9e77e..0f961aef94 100755 --- a/testing/scripts/install-shared +++ b/testing/scripts/install-shared @@ -17,13 +17,7 @@ # for more details. # -DIR=`dirname $0` - -source $DIR/function.sh - -[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found" - -source $DIR/../testing.conf +. $PWD/scripts/function.sh cecho "installing strongSwan from shared tree" cecho-n " on: " diff --git a/testing/scripts/load-testconfig b/testing/scripts/load-testconfig index d73b312753..1abe5985c4 100755 --- a/testing/scripts/load-testconfig +++ b/testing/scripts/load-testconfig @@ -14,13 +14,7 @@ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. -DIR=`dirname $0` - -source $DIR/function.sh - -[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found" - -source $DIR/../testing.conf +. $PWD/scripts/function.sh ########################################################################## # load-testconfig requires a testname as an argument diff --git a/testing/scripts/restore-defaults b/testing/scripts/restore-defaults index 6bad3c5f0b..16714db263 100755 --- a/testing/scripts/restore-defaults +++ b/testing/scripts/restore-defaults @@ -14,12 +14,7 @@ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. -DIR=`dirname $0` - -. $DIR/function.sh - -[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found" -. $DIR/../testing.conf +. $PWD/scripts/function.sh ########################################################################## # load-testconfig requires a testname as an argument @@ -27,7 +22,7 @@ DIR=`dirname $0` testname=$1 -HOSTCONFIGDIR=$DIR/../hosts +HOSTCONFIGDIR=$PWD/hosts TESTSDIR=$BUILDDIR/tests [ -d $TESTSDIR ] || die "Directory '$TESTSDIR' not found" diff --git a/testing/scripts/shutdown-umls b/testing/scripts/shutdown-umls index e71e466025..9d37ab1d83 100755 --- a/testing/scripts/shutdown-umls +++ b/testing/scripts/shutdown-umls @@ -17,13 +17,7 @@ # for more details. # -DIR=`dirname $0` - -source $DIR/function.sh - -[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found" - -source $DIR/../testing.conf +. $PWD/scripts/function.sh cecho "shutting down" cecho-n " " diff --git a/testing/scripts/start-umls b/testing/scripts/start-umls index 470bdc61b5..f9578d751f 100755 --- a/testing/scripts/start-umls +++ b/testing/scripts/start-umls @@ -14,13 +14,7 @@ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. -DIR=`dirname $0` - -source $DIR/function.sh - -[ -f $DIR/../testing.conf ] || die "Configuration file 'testing.conf' not found" - -source $DIR/../testing.conf +. $PWD/scripts/function.sh if [ "$#" -eq 0 ] then