Mise à jour DSN Gandi

Gravitys

Chevalier Jedi
27 Août 2015
351
1
18
Hello,

Je suis entrain de passer de Free ADSL au FTTLA de Red et j'aimerai utiliser l'API XML de Gandi afin de faire mes mises à jour DNS (Red ne propose pas d'IP Fixe...)

j'ai donc ma clef API, mon script bash, maintenant je voudrais l'automatiser un minimum directement sur le nas (crontab ?)

Quelle est la solution la plus élégante ?

Merci
le script en question :
Code:
#!/bin/bash
# 
# 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.
# 
# Live dns is available on beta.gandi.net
# Obtaining your API Key: http://doc.livedns.gandi.net/#requirements
#

DOMAIN="example.net"
RECORD="mywanip"
APIKEY="my-api-key"


API="https://dns.beta.gandi.net/api/v5/"
IP_SERVICE="http://me.gandi.net"

IP4=$(curl -s4 $IP_SERVICE)
IP6=$(curl -s6 $IP_SERVICE)

if [[ -z "$IP4" && -z "$IP6" ]]; then
    echo "Something went wrong. Can not get your IP from $IP_SERVICE "
    exit 1
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
 
si ca peut en aider d'autres, XMLRPCLIB pas dispo sur qnap, donc passage obligé par une vm ou container...

j'ai du monter une vm, mais j'aimerai passer par container dans le futur.