erster Versuch

This commit is contained in:
Czechman 2023-01-09 23:39:47 +01:00
parent a48afbe845
commit 8e88eecaeb
2 changed files with 57 additions and 0 deletions

1
config.env Normal file
View File

@ -0,0 +1 @@
apitoken=1234567890-token-aendern

56
ipv64-dns-challenge.sh Normal file
View File

@ -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 "Lets 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