move checks to the top

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

28
app.sh
View file

@ -7,13 +7,15 @@
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
cd "$GIT_REPO_PATH" || exit
while true ; do
echo "[INFO] pull repository..."
git pull --quiet &> /dev/null
echo "[INFO] check variables..." 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 if [ -z "$INTERVAL" ] ; then
echo "[ERROR] \$INTERVAL is not set." echo "[ERROR] \$INTERVAL is not set."
exit 3 exit 3
@ -38,14 +40,12 @@ while true ; do
echo "[ERROR] \$DEVICES is not set." echo "[ERROR] \$DEVICES is not set."
exit 3 exit 3
fi fi
if [ -z "$GIT_REPO_DEPLOY_KEY" ] ; then
echo "[ERROR] \$GIT_REPO_DEPLOY_KEY is not set." cd "$GIT_REPO_PATH" || exit
exit 3
fi while true ; do
if [ -z "$GIT_REPO_URL" ] ; then echo "[INFO] pull repository..."
echo "[ERROR] \$GIT_REPO_URL is not set." git pull --quiet &> /dev/null
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