diff --git a/config.env b/config.env new file mode 100644 index 0000000..e1b29e4 --- /dev/null +++ b/config.env @@ -0,0 +1 @@ +apitoken=1234567890-token-aendern \ No newline at end of file diff --git a/ipv64-dns-challenge.sh b/ipv64-dns-challenge.sh new file mode 100644 index 0000000..efc10eb --- /dev/null +++ b/ipv64-dns-challenge.sh @@ -0,0 +1,56 @@ +#! /bin/sh + +################################################################################################################# +# DNS challenge Script für ipv64.net +# Das Script soll genutzt werden um die DNS-01 Challenge per EXEC Methode über +# den "Let’s Encrypt client and ACME library written in Go" (LEGO) und die API von ipv64.net +# LEGO Dokumentation: https://go-acme.github.io/lego/dns/exec/ +# API Dokumentation: https://ipv64.net/dyndns_updater_api.php +# Mit dem Nginx Proxy Manager ist das Skript nicht kompatibel, da der NPM die EXEC Methode nicht unterstützt. +# Daher wurde das Skript für die Nutzung mit Traefik umgesetzt. +# Traefik Dokumentation: https://doc.traefik.io/traefik/https/acme/#providers +# Getestet wurde es mit Traefik 2.9 aber auch 1.7 sollte es laut Dokumentation unterstützen: +# https://doc.traefik.io/traefik/v1.7/configuration/acme/#provider +################################################################################################################# +# Alle Konfigurationsparameter werden aus der config.env Datei gelesen +############################################# +configfile="config.env" + +if [ ! -r "$configfile" ]; then + echo "$configfile does not exist or isn't readable" + exit 1 +fi + +apitoken=$(grep ^"apitoken = " "$configfile" | sed -e "s/apitoken = //") + +if [ -z "$apitoken" ]; then + echo "apitoken is not defined in $configfile" + exit 1 +fi + + +set -e + +case "$1" in + "present") + echo "Present" + authorization="Authorization: Bearer $apitoken" + payload="{\"add_record\":\"$2\",, \"type\":\"TXT\", \"content\":\"$3\"}" + echo "payload=${payload}" +#curl -X POST https://ipv64.net/api.php -H "$authorization" -d "add_record=czechman.ipv64.de" -d "type=TXT" -d "content=test" + curl -s -X POST -d "${payload}" -H "$authorization" https://ipv64.net/api + ;; + "cleanup") + echo "cleanup" + authorization="Authorization: Bearer $apitoken" + payload="{\"del_record\":\"$2\",, \"type\":\"TXT\", \"content\":\"$3\"}" + echo "payload=${payload}" +#curl -X POST https://ipv64.net/api.php -H "$authorization" -d "add_record=czechman.ipv64.de" -d "type=TXT" -d "content=test" + curl -s -X DELETE -d "${payload}" -H "$authorization" https://ipv64.net/api + ;; + *) + echo "OOPS" + ;; +esac + +