mirror of
https://github.com/mr0xb/scripts.git
synced 2026-08-27 19:34:57 -04:00
.
This commit is contained in:
parent
62156a1d85
commit
e698f046c8
5 changed files with 183 additions and 0 deletions
25
util/gandi_dyndns
Normal file
25
util/gandi_dyndns
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Gandi LiveDNS API KEY
|
||||
API_KEY=$GANDI_DDNS_API_KEY
|
||||
|
||||
# Domain hosted with Gandi
|
||||
DOMAIN=$GANDI_DDNS_DOMAIN
|
||||
|
||||
# Subdomain to update DNS
|
||||
SUBDOMAIN=$GANDI_DDNS_SUBDOMAIN
|
||||
|
||||
# Get external IP address
|
||||
EXT_IP=$(curl -s ifconfig.me)
|
||||
|
||||
#Get the current Zone for the provided domain
|
||||
CURRENT_ZONE_HREF=$(curl -s -H "X-Api-Key: $API_KEY" https://dns.api.gandi.net/api/v5/domains/$DOMAIN | jq -r '.zone_records_href')
|
||||
|
||||
# Update the A Record of the subdomain using PUT
|
||||
curl -D- -X PUT -H "Content-Type: application/json" \
|
||||
-H "X-Api-Key: $API_KEY" \
|
||||
-d "{\"rrset_name\": \"$SUBDOMAIN\",
|
||||
\"rrset_type\": \"A\",
|
||||
\"rrset_ttl\": 1200,
|
||||
\"rrset_values\": [\"$EXT_IP\"]}" \
|
||||
$CURRENT_ZONE_HREF/$SUBDOMAIN/A
|
||||
Loading…
Reference in a new issue