Skip to content

Instantly share code, notes, and snippets.

@davidpelaez
Created September 17, 2014 03:44
Show Gist options
  • Save davidpelaez/c89cd592a223299b99da to your computer and use it in GitHub Desktop.
Save davidpelaez/c89cd592a223299b99da to your computer and use it in GitHub Desktop.
Self restarting IPSEC check
#!/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