This commit is contained in:
Michael Grote 2023-07-21 19:19:59 +02:00
parent 14df44fb68
commit ee668eaa5f

8
x
View file

@ -46,7 +46,7 @@ if [ -d "$GIT_REPO_PATH" ] ; then
if [ -d ".git" ] ; then if [ -d ".git" ] ; then
git pull "$GIT_REPO_REMOTE_NAME" "$GIT_REPO_BRANCH" git pull "$GIT_REPO_REMOTE_NAME" "$GIT_REPO_BRANCH"
else else
echo "Error: The directory exists but is not a Git repository." echo "Error: The directory exists but is not a Git repository"
exit 1 exit 1
fi fi
else else
@ -64,12 +64,14 @@ while read -r FQDN SSH_KEY_PATH; do
FQDN=$(echo "$FQDN" | tr -d "[:space:]") FQDN=$(echo "$FQDN" | tr -d "[:space:]")
# prüfe ob Key existiert # prüfe ob Key existiert
if [ ! -e "$SSH_KEY_PATH" ] ; then if [ ! -e "$SSH_KEY_PATH" ] ; then
echo "File $SSH_KEY_PATH does not exist." echo "Error: File $SSH_KEY_PATH does not exist"
echo "cant not export $FQDN config." echo "Error: can not export $FQDN config"
exit 2 exit 2
fi fi
echo "export $FQDN config." echo "export $FQDN config."
ssh -n -i "$SSH_KEY_PATH" "$FQDN" "/export show-sensitive" > "config_${FQDN}.rsc" ssh -n -i "$SSH_KEY_PATH" "$FQDN" "/export show-sensitive" > "config_${FQDN}.rsc"
# entferne Datumszeile
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'
git add "config_${FQDN}.rsc" git add "config_${FQDN}.rsc"
git commit -m "update config_${FQDN}" git commit -m "update config_${FQDN}"
done <<< "$DEVICES" done <<< "$DEVICES"