Last active
November 17, 2020 04:01
-
-
Save the0demiurge/6b42e5f46ef7a402f580474b419fe871 to your computer and use it in GitHub Desktop.
Simple Namecheap Dynamic DNS client
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/sh | |
set -eu | |
FETCH="curl -sL" | |
# or for curl: | |
# FETCH="fetch -qo -" | |
# $1: Your domain | |
# $2: Subdomain A record to update. Use @ for TLD. | |
# $3: The password given to you by Namecheap's web interface | |
# | |
# Rerun this script every 5 minutes. Crontab entry: | |
# */5 * * * * namecheap-ddns bla.com @ asdjfasfasdfasdf | |
# | |
# Consider enabling your crond's time jitter if you update | |
# multiple domains to not make too many requests at once to | |
# Namecheap's service. | |
domain=pythonic.life | |
host=laptop | |
password="do not tell others" | |
ip=$(${FETCH} "https://dynamicdns.park-your-domain.com/getip") | |
out=$(${FETCH} "https://dynamicdns.park-your-domain.com/update?host=${host}&domain=${domain}&password=${password}&ip=${ip}") | |
grep -q "<ErrCount>0</ErrCount>" <<EOF && exit 0 | |
${out} | |
EOF | |
cat <<EOF | |
${out} | |
EOF | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment