From b86866579ab3054a21120bca00b4bdfe8c8e575d Mon Sep 17 00:00:00 2001 From: Reto Buerki Date: Thu, 6 Dec 2012 16:58:37 +0100 Subject: Move execute wrappers to function.sh file --- testing/scripts/function.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'testing/scripts/function.sh') diff --git a/testing/scripts/function.sh b/testing/scripts/function.sh index daf56486b..4ee9b24b8 100755 --- a/testing/scripts/function.sh +++ b/testing/scripts/function.sh @@ -14,10 +14,31 @@ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. +# execute command +# $1 - command to execute +# $2 - whether or not to log command exit status +# (0 -> disable exit status logging) +execute() +{ + cmd=${1} + echo $cmd >>$LOGFILE 2>&1 + $cmd >>$LOGFILE 2>&1 + status=$? + [ "$2" != 0 ] && log_status $status + if [ $status != 0 ]; then + echo + echo "! Command $cmd failed, exiting (status $status)" + echo "! Check why here $LOGFILE" + exit 1 + fi +} -############################################ -# output functions -# +# execute command in chroot +# $1 - command to execute +execute_chroot() +{ + execute "chroot $LOOPDIR $@" +} export TERM=xterm -- cgit v1.2.3