forked from oznu/docker-cloudflare-ddns
/
ddns
25 lines (20 loc) · 861 Bytes
/
ddns
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
. ./cloudflare.conf
DnsIpAddress=$(getDnsRecordIp $CF_ZONE_ID $CF_RECORD_ID)
if [ ! -z ${CUSTOM_LOOKUP_CMD+x} ]; then
CurrentIpAddress=$(getCustomIpAddress)
elif [ ! -z ${INTERFACE+x} ]; then
CurrentIpAddress=$(getLocalIpAddress)
else
CurrentIpAddress=$(getPublicIpAddress)
fi
#if [ "$CurrentIpAddress" != "$DnsIpAddress" ]; then
echo "Updating CloudFlare DNS record $CF_RECORD_NAME from $DnsIpAddress to $CurrentIpAddress..."
update=$(updateDnsRecord $CF_ZONE_ID $CF_RECORD_ID $CF_RECORD_NAME $CurrentIpAddress)
if [ "$update" == "null" ]; then
echo "ERROR: Failed to update CloudFlare DNS record $CF_RECORD_NAME from $DnsIpAddress to $CurrentIpAddress"
else
echo "CloudFlare DNS record $CF_RECORD_NAME ($CurrentIpAddress) updated successfully."
fi
#else
# echo "No DNS update required for $CF_RECORD_NAME ($DnsIpAddress)."
#fi