Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/bash
- DDNS_HOSTNAME=example.com
- SERVER=domains.google.com
- GOOGLE_USER=
- GOOGLE_PASS=
- TEST_HOST=example.com
- CURL_EXE="/usr/bin/curl -4 --user-agent curl -s -get"
- CURRENT_IP=$(${CURL_EXE} https://${SERVER}/checkip)
- DNS_IP=$(/usr/bin/host ${TEST_HOST} | grep "has address" | awk '{print $4}')
- VPN_UP=$(ip link ls wgpia0 2>&1)
- echo -n "Expected IPv4 addr: ${DNS_IP}, Current IPv4 addr: ${CURRENT_IP} - "
- if [ "$DNS_IP" != "$CURRENT_IP" ]; then
- echo "IPv4 Addresses DO NOT match."
- if [ "${VPN_UP}" == "Device \"wgpia0\" does not exist." ]; then
- echo -n "VPN is not up. Attempting to update ${SERVER}... "
- RETVAL=$(${CURL_EXE} https://${GOOGLE_USER}:${GOOGLE_PASS}@${SERVER}/nic/update?hostname=${DDNS_HOSTNAME})
- echo -n "${RETVAL} - "
- xmessage -display :0.0 "Your WAN IP address has changed and is now ${CURRENT_IP}."
- else
- echo -n "VPN is up. Skipping - "
- fi # vpn_up
- else
- echo -n "IPv4 addresses match - "
- fi # dns != current
- echo "Done."
Add Comment
Please, Sign In to add comment