#!/bin/sh # Settings ############################################################################### if [ -z "$GDDNS_API_KEY" ]; then printf "error: GDDNS_API_KEY environment variable is required!\n" exit 1 fi if [ -z "$GDDNS_DOMAIN" ]; then printf "error: GDDNS_DOMAIN environment variable is required!\n" exit 1 fi if [ -z "$GDDNS_RECORD_NAME" ]; then printf "error: GDDNS_RECORD_NAME environment variable is required!\n" exit 1 fi GDDNS_TTL="${GDDNS_TTL:-3600}" GDDNS_EXTERNAL_IP="${GDDNS_EXTERNAL_IP:-"https://ipv4.icanhazip.com"}" # Implementation ############################################################################### # Discover external IP (via icanhazip.com by default) if ! ip="$(curl --fail --silent "$GDDNS_EXTERNAL_IP")"; then printf "error: failed to get external IP address\n" exit 1 fi # Do nothing if the IP has not changed since last time otherwise... previous_ip=$(cat /tmp/DynGanDiNS.ip) if [ "$ip" = "$previous_ip" ]; then exit 0 fi printf "info: new external IP %s\n" "$ip" # ...update Gandi via the API... request_data=$(cat < /tmp/DynGanDiNS.ip