From acfc4540a2a7828c97df22526f9f77d5fbbda9ba Mon Sep 17 00:00:00 2001 From: David Beniamine <david.beniamine@tetras-libre.fr> Date: Mon, 18 Feb 2019 12:00:46 +0100 Subject: [PATCH] Abort on errors --- do_preinstall.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/do_preinstall.sh b/do_preinstall.sh index 366ec9d..1c34fcf 100755 --- a/do_preinstall.sh +++ b/do_preinstall.sh @@ -28,20 +28,31 @@ then exit 1 fi +safe_run(){ + $@ + code=$? + if [ $code -ne 0 ] + then + echo "Error while running $1" + exit $code + fi +} + + logfile="/var/log/`basename $0`_`date +%Y%m%d-%H%M`" exec &> >(tee -a "$logfile") echo "Updating eole" -Maj-Auto +safe_run Maj-Auto echo "Generating containers" -gen_conteneurs +safe_run gen_conteneurs -echo "Generation de la configuration initiale" -gen_config +echo "Generating initial config" +safe_run gen_config echo "Instanciating server" -instance +safe_run instance echo "Running diagnostic" -diagnose -L +safe_run diagnose -L -- GitLab