Created
March 6, 2021 00:28
-
-
Save pweinzettel/4cdbf938faf2a84a7af3aa6b92ad4de2 to your computer and use it in GitHub Desktop.
namecheap dynamic dns update
This file contains hidden or 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 | |
### CONFIG INI | |
HOST='subdom' | |
DOMAIN='example.com' | |
PASSWD='<SECRET>' | |
URL='https://dynamicdns.park-your-domain.com/update' | |
### CONFIG END | |
IP=$(curl -s ifconfig.me) | |
EC=$? | |
if [ "${EC}" -eq 0 ]; then | |
LAST="$(cat /tmp/${HOST}.${DOMAIN} 2>/dev/null)" | |
if [ "${LAST}" != "${IP}" ]; then | |
curl -s "${URL}?host=${HOST}&domain=${DOMAIN}&ip=${IP}&password=${PASSWD}" | logger -t "DNS Update" | |
EC=${PIPESTATUS[0]} | |
if [ "${EC}" -eq 0 ]; then | |
echo ${IP} > /tmp/${HOST}.${DOMAIN} | |
fi | |
else | |
echo "No change ( ${IP} == ${LAST} )" | logger -t "DNS Update" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment