diff --git a/ipv64-dns-challenge.sh b/ipv64-dns-challenge.sh index c729e79..47902de 100755 --- a/ipv64-dns-challenge.sh +++ b/ipv64-dns-challenge.sh @@ -34,22 +34,27 @@ set -e case "$1" in "present") echo "Present" + full_domain=$2 + domain=$(echo $full_domain | rev | cut -d . -f -3 | rev) + praefix=${full_domain%"$domain"} + praefix=${praefix%"."} auth_h="Authorization: Bearer $apitoken" - domain_pl="add_record=$2" - praefix_pl="praefix=" + domain_pl="add_record=$domain" + praefix_pl="praefix=$praefix" type_pl="type=TXT" content_pl="content=$3" -#curl -X POST https://ipv64.net/api.php -H "$authorization" -d "add_record=czechman.ipv64.de" -d "type=TXT" -d "content=test" -#-d "del_record=czechman.ipv64.de" -d "praefix=_acme" -d "type=TXT" -d "content=drei" -H "Authorization: Bearer yS3de7wD2EJHtUAxivRW8lkufcg6Y0pq" echo 'curl -s -X POST -d "'"$domain_pl"'" -d "'"$praefix_pl"'" -d "'"$type_pl"'" -d "'"$content_pl"'" -H "'"\$auth_h"'" https://ipv64.net/api' ;; "cleanup") + full_domain=$2 + domain=$(echo $full_domain | rev | cut -d . -f -3 | rev) + praefix=${full_domain%"$domain"} + praefix=${praefix%"."} auth_h="Authorization: Bearer $apitoken" - domain_pl="del_record=$2" - praefix_pl="praefix=" + domain_pl="del_record=$domain" + praefix_pl="praefix=$praefix" type_pl="type=TXT" content_pl="content=$3" -#curl -X POST https://ipv64.net/api.php -H "$authorization" -d "add_record=czechman.ipv64.de" -d "type=TXT" -d "content=test" echo 'curl -s -X DELETE -d "'"$domain_pl"'" -d "'"$praefix_pl"'" -d "'"$type_pl"'" -d "'"$content_pl"'" -H "'"\$auth_h"'" https://ipv64.net/api' ;; *)