Created
September 17, 2014 03:44
-
-
Save davidpelaez/c89cd592a223299b99da to your computer and use it in GitHub Desktop.
Self restarting IPSEC check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eo pipefail | |
date | |
url="https://le-service.something" | |
if curl -s --write-out "%{http_code}" "$url" --output /dev/null --max-time 10 | grep -G 200 &> /dev/null; then | |
echo "Succesfully reached leService endpoint" | |
exit 0 | |
else | |
echo "leService didn't respond with 200 OK or couldn't be reached." | |
echo "[ALERT] Forcing leService's VPN connection restart" | |
ipsec auto --down leService | |
sleep 1 | |
ipsec auto --up leService | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment