From 2094cd7567849a5e9dc771659285710e561e66e4 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Tue, 15 Aug 2023 10:14:23 +0200 Subject: [PATCH] move checks to the top --- app.sh | 68 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/app.sh b/app.sh index 37a3130..ea18bf9 100644 --- a/app.sh +++ b/app.sh @@ -7,46 +7,46 @@ echo "[INFO] clone repository..." GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -i $GIT_REPO_DEPLOY_KEY" git clone "$GIT_REPO_URL" "$GIT_REPO_PATH" --quiet > /dev/null +echo "[INFO] check variables..." +if [ -z "$GIT_REPO_DEPLOY_KEY" ] ; then + echo "[ERROR] \$GIT_REPO_DEPLOY_KEY is not set." + exit 3 +fi +if [ -z "$GIT_REPO_URL" ] ; then + echo "[ERROR] \$GIT_REPO_URL is not set." + exit 3 +fi +if [ -z "$INTERVAL" ] ; then + echo "[ERROR] \$INTERVAL is not set." + exit 3 +fi +if [ -z "$GIT_REPO_BRANCH" ] ; then + echo "[ERROR] \$GIT_REPO_BRANCH is not set." + exit 3 +fi +if [ -z "$GIT_USERNAME" ] ; then + echo "[ERROR] \$GIT_USERNAME is not set." + exit 3 +fi +if [ -z "$GIT_USER_MAIL" ] ; then + echo "[ERROR] \$GIT_USER_MAIL is not set." + exit 3 +fi +if [ -z "$GIT_REPO_REMOTE_NAME" ] ; then + echo "[ERROR] \$GIT_REPO_REMOTE_NAME is not set." + exit 3 +fi +if [ -z "$DEVICES" ] ; then + echo "[ERROR] \$DEVICES is not set." + exit 3 +fi + cd "$GIT_REPO_PATH" || exit while true ; do echo "[INFO] pull repository..." git pull --quiet &> /dev/null - echo "[INFO] check variables..." - if [ -z "$INTERVAL" ] ; then - echo "[ERROR] \$INTERVAL is not set." - exit 3 - fi - if [ -z "$GIT_REPO_BRANCH" ] ; then - echo "[ERROR] \$GIT_REPO_BRANCH is not set." - exit 3 - fi - if [ -z "$GIT_USERNAME" ] ; then - echo "[ERROR] \$GIT_USERNAME is not set." - exit 3 - fi - if [ -z "$GIT_USER_MAIL" ] ; then - echo "[ERROR] \$GIT_USER_MAIL is not set." - exit 3 - fi - if [ -z "$GIT_REPO_REMOTE_NAME" ] ; then - echo "[ERROR] \$GIT_REPO_REMOTE_NAME is not set." - exit 3 - fi - if [ -z "$DEVICES" ] ; then - echo "[ERROR] \$DEVICES is not set." - exit 3 - fi - if [ -z "$GIT_REPO_DEPLOY_KEY" ] ; then - echo "[ERROR] \$GIT_REPO_DEPLOY_KEY is not set." - exit 3 - fi - if [ -z "$GIT_REPO_URL" ] ; then - echo "[ERROR] \$GIT_REPO_URL is not set." - exit 3 - fi - # Save the current value of IFS to restore later OLD_IFS=$IFS