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