From 63d8206794a3b775da1ca42769b9bc8a24b03424 Mon Sep 17 00:00:00 2001 From: Thomas Mieslinger Date: Wed, 10 Nov 2021 15:36:10 +0100 Subject: [PATCH] add scripts to use IONOS DNS API --- dns_scripts/DNS_IONOS.md | 9 +++++++ dns_scripts/dns_add_ionos | 54 +++++++++++++++++++++++++++++++++++++++ dns_scripts/dns_del_ionos | 23 +++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 dns_scripts/DNS_IONOS.md create mode 100755 dns_scripts/dns_add_ionos create mode 100755 dns_scripts/dns_del_ionos diff --git a/dns_scripts/DNS_IONOS.md b/dns_scripts/DNS_IONOS.md new file mode 100644 index 0000000..d3a685e --- /dev/null +++ b/dns_scripts/DNS_IONOS.md @@ -0,0 +1,9 @@ +# Do DNS-01 verification using IONOS DNS API + +The getting started guide explains how to obtain API Keys https://developer.hosting.ionos.de/docs/getstarted + +All API Documentation can be found here https://developer.hosting.ionos.de/docs/dns + +JSON processing in bash is ... hard. So I choose `jq` to do the heavylifting. Other authors choose python so if +you think I did a bad decision feel free to implement this whith python/perl/ruby... + diff --git a/dns_scripts/dns_add_ionos b/dns_scripts/dns_add_ionos new file mode 100755 index 0000000..e4354bf --- /dev/null +++ b/dns_scripts/dns_add_ionos @@ -0,0 +1,54 @@ +#!/usr/bin/bash +# +# Called as +# +# eval "${DNS_ADD_COMMAND}" "${lower_d}" "${auth_key}" +# + +# See https://developer.hosting.ionos.de/docs/getstarted how to generate +# an API Key consisting of prefix and key +# +# see DNS API Doc here https://developer.hosting.ionos.de/docs/dns +# + +API_KEY="X-API-Key: ." +API_URL="https://api.hosting.ionos.com/dns/v1" + +# TODO: check $1,$2 not empty + +DNS_RR=$1 +DNS_SECRET=$2 + + +# get zone id: +curl -s -X GET "$API_URL/zones" -H "accept: application/json" -H "Content-Type: application/json" -H "$API_KEY" \ + | jq -r 'map([.name, .id] | join (";")) | .[]' >/tmp/$$.zones + +ZONE=$DNS_RR + +do=true +while $do; do + ZONE_ID=$(awk -F\; '/^'"$ZONE"';/{print $2}'