Merge pull request #13405 from peter-stadler/nginx-util-uci
[feed/packages.git] / net / ddns-scripts / files / usr / lib / ddns / update_gandi_net.sh
1 #!/bin/sh
2 # Thanks goes to Alex Griffin who provided this script.
3
4 local __TTL=600
5 local __RRTYPE
6 local __ENDPOINT="https://dns.api.gandi.net/api/v5"
7
8 [ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing subdomain as 'username'"
9 [ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing API Key as 'password'"
10
11 [ $use_ipv6 -ne 0 ] && __RRTYPE="AAAA" || __RRTYPE="A"
12
13 curl -s -X PUT "$__ENDPOINT/domains/$domain/records/$username/$__RRTYPE" \
14 -H "X-Api-Key: $password" \
15 -H "Content-Type: application/json" \
16 -d "{\"rrset_ttl\": $__TTL, \"rrset_values\": [\"$__IP\"]}" >$DATFILE
17
18 write_log 7 "gandi.net answered: $(cat $DATFILE)"
19
20 return 0