Refactor DDNS updater: switch to Alpine, support multiple domains

- Replace golang base image with alpine for smaller footprint
- Add bash/curl dependencies explicitly
- Refactor script to support multiple domains via arrays
- Improve logging with timestamps and status messages
- Simplify docker-compose configuration
- Remove obsolete build scripts and env files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
primal
2026-01-26 15:40:55 -05:00
parent 484426a1cd
commit 97fd399b4d
7 changed files with 49 additions and 35 deletions
+29 -13
View File
@@ -1,16 +1,32 @@
#!/bin/bash
DOMN=primal.host
PASS=35f5fa4e1fc04d539260a4afaeb42371 \
IP0=''
# Namecheap Dynamic DNS Updater
# https://www.namecheap.com/support/knowledgebase/article.aspx/29/11/how-to-dynamically-update-the-hosts-ip-with-an-https-request/
declare -a domains
domains=( "primal.host" )
declare -a ipAddrs
ipAddrs=( "0.0.0.0" )
declare -a passwords
passwords=( "4e6b91f434284c6d9261d5779b1d560f" )
while true ; do
IP1=$(curl --no-progress-meter 'https://api.ipify.org?format=text')
if [[ "${IP1}" != "${IP0}" && "${IP1}" != '' ]] ; then
OP0=$(curl --no-progress-meter -X GET -d 'host=@' -d "domain=${DOMN}" -d "password=${PASS}" -d "ip=${IP1}" -G 'https://dynamicdns.park-your-domain.com/update')
OP1=$(curl --no-progress-meter -X GET -d 'host=*' -d "domain=${DOMN}" -d "password=${PASS}" -d "ip=${IP1}" -G 'https://dynamicdns.park-your-domain.com/update')
echo $(date) ${IP0} ${IP1}
IP0=${IP1}
else
echo $(date) ${IP0} ${IP1} .
fi
sleep 3661
ipPublic=$(curl --no-progress-meter 'https://api.ipify.org?format=text')
echo "$(date '+%Y-%m-%d %H:%M:%S') Public IP: ${ipPublic}"
for i in ${!domains[@]} ; do
domain=${domains[$i]}
ipAddr=${ipAddrs[$i]}
password=${passwords[$i]}
if [[ "$ipPublic" != "$ipAddr" ]] ; then
for host in '@' '*' ; do
response="$(curl --no-progress-meter -G -d "host=$host" -d "domain=$domain" -d "password=$password" -d "ip=$ipPublic" https://dynamicdns.park-your-domain.com/update)"
if [[ $(echo $response | grep -c "<ErrCount>0</ErrCount>" -) -ne 1 ]] ; then
echo " ERROR updating ${host}.${domain}: $response"
else
ipAddrs[${i}]="$ipPublic"
echo " Updated ${host}.${domain} -> ${ipPublic}"
fi
done
fi
done
sleep 3600
done