#
# ==============================================
#
IPCamTalk DDNS update script
# Works with Debian Trixie and Pi-hole setup
# ==============================================
# Config
API_URL="https://ipcamtalk.com/dyn?api=xxxxxxxxxx"
IP_FILE="/tmp/last_ipctddns"
LOG_FILE="/var/log/ipctddns.log"
# Get current public IP
CURRENT_IP=$(curl -s
)
if [ -z "$CURRENT_IP" ]; then
echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Could not detect public IP" >> "$LOG_FILE"
exit 1
fi
# Get last IP
LAST_IP=$(cat "$IP_FILE" 2>/dev/null)
# Compare
if [ "$CURRENT_IP" != "$LAST_IP" ]; then
# Update DDNS
RESPONSE=$(curl -s -A "Mozilla/5.0" "$API_URL")
STATUS=$?
if [ $STATUS -eq 0 ]; then
echo "$(date '+%Y-%m-%d %H:%M:%S') Updated DDNS to $CURRENT_IP. Response: $RESPONSE" >> "$LOG_FILE"
# Save current IP
echo "$CURRENT_IP" > "$IP_FILE"
else
echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: DDNS update failed (curl exit $STATUS)" >> "$LOG_FILE"
fi
else
echo "$(date '+%Y-%m-%d %H:%M:%S') No IP change detected ($CURRENT_IP), skipping update" >> "$LOG_FILE"
fi