This commit is contained in:
Michael Grote 2023-07-21 21:33:53 +02:00
parent b8f880e7a5
commit c121b24da5

15
app.sh
View file

@ -1,7 +1,7 @@
#!/bin/bash
while true ; do
# Checks
echo "check variables..."
if [ -z "$INTERVAL" ] ; then
echo "INTERVAL is not set."
exit 3
@ -40,8 +40,7 @@ while true ; do
git config --global user.email "$GIT_USER_MAIL"
git config --global user.name "$GIT_USERNAME"
echo clone
pwd
echo "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"
@ -60,20 +59,16 @@ while true ; do
echo "Error: can not export $FQDN config"
exit 2
fi
echo "export $FQDN config"
echo "export $FQDN config..."
ssh -n -o StrictHostKeyChecking=no -i "$SSH_KEY_PATH" "${USERNAME}@${FQDN}" "/export show-sensitive" > "config_${FQDN}.rsc" 2> /dev/null
# entferne Datumszeile
echo sed
pwd
sed -i -r '/^# [0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}\:[0-9]{2}\:[0-9]{2}\sby\sRouterOS\s[0-9\s\.]+/d' "config_${FQDN}.rsc"
echo add
pwd
git add "config_${FQDN}.rsc"
echo commit
pwd
echo "commit config for ${FQDN} ..."
git commit -m "update config_${FQDN}" --quiet
done <<< "$DEVICES"
echo "push config(s)..."
GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -i $GIT_REPO_DEPLOY_KEY" git push &> /dev/null
# Restore the original IFS value