From a440c2d1cb29a37f2a261a9ae6f428fe5dab70a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 2 May 2018 18:16:42 +0200 Subject: [PATCH] Unify traps in bootstrap scripts to avoid confusion --- hack/bootstrap_tfw_dev.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hack/bootstrap_tfw_dev.sh b/hack/bootstrap_tfw_dev.sh index 5542227..472efea 100755 --- a/hack/bootstrap_tfw_dev.sh +++ b/hack/bootstrap_tfw_dev.sh @@ -18,8 +18,7 @@ LOGFILE=/tmp/bootstrap_tfw.log run() { - trap 'err_cleanup; showlog' ERR - trap cleanlog EXIT + trap handle_exit EXIT : > $LOGFILE check_dependencies @@ -37,6 +36,15 @@ run() echo "You can build & start TFW by executing the command: ${TEST}/hack/tfw.sh start" } +handle_exit() +{ + if [[ $? -ne 0 ]]; then + err_cleanup + showlog + fi + cleanlog +} + showlog() { echo && echo "Error! Showing logs:" && cat $LOGFILE; } cleanlog() { rm $LOGFILE; } err_cleanup() { cd "$BASEDIR" && rm -rf "$BASEIMAGE" "$FRONTEND" "$TEST"; }