diff --git a/bash/livedns/mywanip.sh b/bash/livedns/mywanip.sh index 548991b..a308f5b 100644 --- a/bash/livedns/mywanip.sh +++ b/bash/livedns/mywanip.sh @@ -3,15 +3,15 @@ # Updates a zone record using Gandi's LiveDNS. # Ideally this script is placed into a crontab or when the WAN interface comes up. # Replace APIKEY with your Gandi API Key and DOMAIN with your domain name at Gandi. -# Set RECORD to which zone label you wish to update. -# You will be able to query mywanip.example.net if everything went successful. +# Set RECORDS to which zone labels you wish to update. +# You will be able to query example.net, mywanip.example.net and mywanip2.example.net if everything went successful. # # Live dns is available on www.gandi.net # Obtaining your API Key: http://doc.livedns.gandi.net/#step-1-get-your-api-key # DOMAIN="example.net" -RECORD="mywanip" +RECORDS=( "@" "mywanip" "mywanip2" ) APIKEY="my-api-key" @@ -27,19 +27,22 @@ if [[ -z "$IP4" && -z "$IP6" ]]; then fi -if [[ ! -z "$IP4" ]]; then - DATA='{"rrset_values": ["'$IP4'"]}' - curl -s -XPUT -d "$DATA" \ - -H"X-Api-Key: $APIKEY" \ - -H"Content-Type: application/json" \ - "$API/domains/$DOMAIN/records/$RECORD/A" -fi - -if [[ ! -z "$IP6" ]]; then - DATA='{"rrset_values": ["'$IP6'"]}' - curl -s -XPUT -d "$DATA" \ - -H"X-Api-Key: $APIKEY" \ - -H"Content-Type: application/json" \ - "$API/domains/$DOMAIN/records/$RECORD/AAAA" -fi +for RECORD in "${RECORDS[@]}" +do + if [[ ! -z "$IP4" ]]; then + DATA='{"rrset_values": ["'$IP4'"]}' + curl -s -XPUT -d "$DATA" \ + -H"X-Api-Key: $APIKEY" \ + -H"Content-Type: application/json" \ + "$API/domains/$DOMAIN/records/$RECORD/A" + fi + + if [[ ! -z "$IP6" ]]; then + DATA='{"rrset_values": ["'$IP6'"]}' + curl -s -XPUT -d "$DATA" \ + -H"X-Api-Key: $APIKEY" \ + -H"Content-Type: application/json" \ + "$API/domains/$DOMAIN/records/$RECORD/AAAA" + fi +done