- 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>
33 lines
1.2 KiB
Bash
Executable File
33 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# 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
|
|
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
|