Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
check public ip is returned
Browse files Browse the repository at this point in the history
  • Loading branch information
oznu committed May 30, 2018
1 parent bb166a2 commit 5fc2d36
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -63,11 +63,12 @@ If you prefer to use [Docker Compose](https://docs.docker.com/compose/):
version: '2'
services:
cloudflare-ddns:
image: oznu/cloudflare-ddns
image: oznu/cloudflare-ddns:latest # change 'latest' to 'armhf' or 'aarch64' if running on an arm device
restart: always
environment:
- EMAIL=hello@example.com
- API_KEY=xxxxxxx
- ZONE=example.com
- SUBDOMAIN=subdomain
- PROXIED=false
```
2 changes: 2 additions & 0 deletions root/etc/cont-finish.d/50-remove-record
@@ -1,5 +1,7 @@
#!/usr/bin/with-contenv sh

[ -f /config/cloudflare.conf ] || exit 0

. /app/cloudflare.sh
. /config/cloudflare.conf

Expand Down
21 changes: 20 additions & 1 deletion root/etc/cont-init.d/30-cloudflare-setup
Expand Up @@ -34,14 +34,33 @@ fi

echo "DNS Zone: $ZONE ($CFZoneId)"

# Check we can get the current public ip address
PublicIpAddress=$(getPublicIpAddress)

if [ "$PublicIpAddress" == "" ]; then
echo "----------------------------------------------------------------"
if [ "$RRTYPE" == "AAAA" ]; then
echo "ERROR: Failed To Get Public IPv6 Address"
echo "----------------------------------------------------------------"
echo "You must be running Docker with IPv6 support enabled or this"
echo "container with host networking enabled."
echo
echo "Add '--net=host' to your docker run command or if using"
echo "docker-compose add 'network_mode: host' to this service."
else
echo "ERROR: Failed To Get Public IPv4 Address"
fi
echo "----------------------------------------------------------------"
exit 1
fi

# Get the ID of the dns record from the CloudFlare API
CFDnsRecordName=$(getDnsRecordName)
CFDnsRecordId=$(getDnsRecordId $CFZoneId $CFDnsRecordName)

# If the dns record does not exist, create it now.
if [ "$CFDnsRecordId" == "null" ]; then
echo "DNS record for '$CFDnsRecordName' was not found in $ZONE zone. Creating now..."
PublicIpAddress=$(getPublicIpAddress)
CFDnsRecordId=$(createDnsRecord $CFZoneId $CFDnsRecordName $PublicIpAddress)

if [ "$CFDnsRecordId" == "null" ]; then
Expand Down

0 comments on commit 5fc2d36

Please sign in to comment.