add check if target is reachable
This commit is contained in:
parent
92598bf26c
commit
1a00de8c13
1 changed files with 12 additions and 7 deletions
19
app.sh
19
app.sh
|
@ -62,13 +62,18 @@ while true ; do
|
|||
echo "Error: can not export $FQDN config"
|
||||
exit 2
|
||||
fi
|
||||
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
|
||||
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 add "config_${FQDN}.rsc"
|
||||
echo "commit config for ${FQDN} ..."
|
||||
git commit -m "update config_${FQDN}" --quiet > /dev/null
|
||||
# check if target is reachable
|
||||
if ping -c1 -W1 "${FQDN}" > /dev/null; then
|
||||
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
|
||||
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 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"
|
||||
|
||||
echo "push config(s)..."
|
||||
|
|
Loading…
Reference in a new issue