From 6679a3b1ef84272819e6b2f294bc22878d254972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sat, 28 Apr 2018 11:17:55 +0200 Subject: [PATCH] Implement bootstrap script dependency checking --- hack/bootstrap_tfw_dev.sh | 57 ++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/hack/bootstrap_tfw_dev.sh b/hack/bootstrap_tfw_dev.sh index 0cffd39..5118f02 100755 --- a/hack/bootstrap_tfw_dev.sh +++ b/hack/bootstrap_tfw_dev.sh @@ -14,26 +14,7 @@ BASEDIR="$(pwd)" BASEIMAGE=baseimage-${TFW_POSTFIX} TEST=test-${TFW_POSTFIX} FRONTEND=frontend-${TFW_POSTFIX} - LOGFILE=/tmp/bootstrap_tfw.log -logged() { "$@" >> $LOGFILE 2>&1; } - -spinned() -{ - "$@" & - pid=$! - spin=("-" "\\" "|" "/") - - echo -n "${spin[0]}" - while kill -0 $pid &> /dev/null; do - for i in "${spin[@]}"; do - echo -ne "\b$i" - sleep 0.1 - done - done - echo -ne "\b" -} - run() { @@ -41,6 +22,7 @@ run() trap cleanlog EXIT : > $LOGFILE + check_dependencies clone_repos install_frontend_deps if [ "$TFWDEV" == "0" ]; then @@ -55,6 +37,22 @@ run() echo "You can build & start TFW by executing the command: ${TEST}/hack/tfw.sh start" } +check_dependencies() +{ + dependencies=("git" "docker" "yarn" "ng") + missing="0" + for dep in ${dependencies[@]}; do + if ! type "$dep" > /dev/null 2>&1; then + echo "Dependency '${dep}' not found!" + missing="1" + fi + done + if [ "$missing" == "1" ]; then + echo "Please install the missing packages and retry!" + exit 1 + fi +} + showlog() { echo && echo "Error! Showing logs:" && cat $LOGFILE; } cleanlog() { rm $LOGFILE; } err_cleanup() { cd "$BASEDIR" && rm -rf "$BASEIMAGE" "$FRONTEND" "$TEST"; } @@ -120,4 +118,25 @@ merge_repos() echo "Done!" } +logged() +{ + "$@" >> $LOGFILE 2>&1 +} + +spinned() +{ + "$@" & + pid=$! + spin=("-" "\\" "|" "/") + + echo -n "${spin[0]}" + while kill -0 $pid &> /dev/null; do + for i in "${spin[@]}"; do + echo -ne "\b$i" + sleep 0.1 + done + done + echo -ne "\b" +} + run