add dyndns scripts

This commit is contained in:
Christian Ulrich 2024-05-02 01:35:19 +02:00
parent 47d2132170
commit 2b5dbf6831
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#!/bin/sh
ttl=300
ip=${1}
second_level_domain="$domain"
subdomain="{@}"
depth=$(echo "$domain" | grep -o "[.]" | wc -l)
if [ "$depth" -ge 2 ]; then
second_level_domain=$(echo "$domain" | cut -s -d '.' -f ${depth}-)
subdomain=$(echo "$domain" | cut -s -d '.' -f -$((depth - 1)))
fi
echo "second_level_domain = ${second_level_domain}"
echo "subdomain = ${subdomain}"
curl -fs -o /dev/null -X PUT -H "Content-Type: application/json" \
-H "X-Api-Key: ${password}" \
-d "{\"rrset_ttl\": ${ttl}, \"rrset_values\": [\"${ip}\"]}" \
"https://dns.api.gandi.net/api/v5/domains/${second_level_domain}/records/${subdomain}/A"

View File

@ -0,0 +1,11 @@
#!/bin/sh
ttl=300
ip=${1}
contents="[{\"content\":\"${ip}\"}]"
curl -fs \
-X POST -H "Content-Type: application/json" \
-d "{\"authToken\":\"${password}\",\"hostname\":\"${domain}\",\"recordType\":\"A\",\"rrSetContents\":${contents},\"removeAllRecords\":\"true\"}" \
"https://secure.hosting.de/api/dns/v1/json/resourceRecordSetUpdate"