Commit 42b9cf0c authored by Jørgen Lien Sellæg's avatar Jørgen Lien Sellæg
Browse files

initial implementation vsddnsc

parent 3de74c63
#!/bin/bash
readonly DOMAIN="$1"
readonly PASSWORD="$2"
readonly URL="https://dyn.dns.he.net/nic/update"
function usage {
cat <<- EOF
Usage: $0 domain [password]
domain:
A-record you wish to update.
password:
Authentication token.
EOF
exit $1
}
function check_args {
if [ "${DOMAIN}" == "" ]; then
usage 1
fi
if [ "${PASSWORD}" == "" ] && [ "${VSDDNSC_PASSWORD}" == "" ]; then
usage 2
fi
}
check_args
function update_needed {
local registered_ip=$(dig +short ${DOMAIN})
local current_ip="$1"
[ "$current_ip" == "$registered_ip" ]
}
function update_dns {
local current_ip=$(curl -s https://api.ipify.org)
local password="${PASSWORD}";
if [ "${password}" == "" ]; then
password="${VSDDNSC_PASSWORD}"
fi
if update_needed "${current_ip}"; then
curl ${URL} -d "hostname=${DOMAIN}" -d "password=${password}" -d "myip=${current_ip}" &> /dev/null
fi
return 0
}
update_dns
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment