Needs yq (
pip install yq) anddigto be installed
curl -s https://gist.githubusercontent.com/jroehl/25dcd6a35d5cf7809d3274439a1e6783/raw/update-ddns.sh | bash -s "host" "domain" "password"
| #!/usr/bin/env bash | |
| HOST="$1" | |
| DOMAIN="$2" | |
| PASSWORD="$3" | |
| if [ "$HOST" == "@" ]; then | |
| SET_IP=$(dig +short ${DOMAIN}) | |
| else | |
| SET_IP=$(dig +short ${HOST}.${DOMAIN}) | |
| fi | |
| CURRENT_IP=$(dig +short myip.opendns.com @resolver1.opendns.com) | |
| echo "IP of a-record \"${HOST}.${DOMAIN}\" = \"${SET_IP}\" / current ip \"${CURRENT_IP}\"" | |
| if [ "$CURRENT_IP" != "$SET_IP" ]; then | |
| RES=`curl -s -X GET "https://dynamicdns.park-your-domain.com/update?host=${HOST}&domain=${DOMAIN}&password=${PASSWORD}&ip=${CURRENT_IP}"` | |
| if command -v xq >/dev/null 2>&1; then | |
| echo $RES | xq '.' | |
| else | |
| echo $RES | |
| fi | |
| else | |
| echo "DDNS entry already up to date (${CURRENT_IP})" | |
| fi |