add check if target is reachable

This commit is contained in:
Michael Grote 2023-08-04 10:16:54 +02:00
parent 92598bf26c
commit 1a00de8c13

19
app.sh
View file

@ -62,13 +62,18 @@ while true ; do
echo "Error: can not export $FQDN config" echo "Error: can not export $FQDN config"
exit 2 exit 2
fi fi
echo "export $FQDN config..." # check if target is reachable
ssh -n -o StrictHostKeyChecking=no -i "$SSH_KEY_PATH" "${USERNAME}@${FQDN}" "/export show-sensitive" > "config_${FQDN}.rsc" 2> /dev/null if ping -c1 -W1 "${FQDN}" > /dev/null; then
# entferne Datumszeile echo "export $FQDN config..."
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" ssh -n -o StrictHostKeyChecking=no -i "$SSH_KEY_PATH" "${USERNAME}@${FQDN}" "/export show-sensitive" > "config_${FQDN}.rsc" 2> /dev/null
git add "config_${FQDN}.rsc" # entferne Datumszeile
echo "commit config for ${FQDN} ..." 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"
git commit -m "update config_${FQDN}" --quiet > /dev/null git add "config_${FQDN}.rsc"
echo "commit config for ${FQDN} ..."
git commit -m "update config_${FQDN}" --quiet > /dev/null
else
echo "${FQDN} not reachable!"
fi
done <<< "$DEVICES" done <<< "$DEVICES"
echo "push config(s)..." echo "push config(s)..."