move checks to the top

This commit is contained in:
Michael Grote 2023-08-15 10:14:23 +02:00
parent 22f7f214fe
commit 2094cd7567

68
app.sh
View file

@ -7,46 +7,46 @@
echo "[INFO] clone repository..." 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 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 cd "$GIT_REPO_PATH" || exit
while true ; do while true ; do
echo "[INFO] pull repository..." echo "[INFO] pull repository..."
git pull --quiet &> /dev/null 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 # Save the current value of IFS to restore later
OLD_IFS=$IFS OLD_IFS=$IFS