From 1b062ab929f4e3b62d72a61dbe77b17c0252d405 Mon Sep 17 00:00:00 2001
From: mod242 <40213799+mod242@users.noreply.github.com>
Date: Sun, 28 Apr 2019 15:58:08 +0200
Subject: [PATCH 1/6] Correct sed parsing error
---
dnsapi/dns_ddnss.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dnsapi/dns_ddnss.sh b/dnsapi/dns_ddnss.sh
index dfe6dcb..903b961 100644
--- a/dnsapi/dns_ddnss.sh
+++ b/dnsapi/dns_ddnss.sh
@@ -119,7 +119,7 @@ _ddnss_rest() {
# DDNSS uses GET to update domain info
if [ "$method" = "GET" ]; then
- response="$(_get "$url" | sed 's/<[^>]*>//g;/]*>//g' | _tail_n 1)"
else
_err "Unsupported method"
return 1
From 5b1b5cc8f2c76c31859cf2047c230730707689d3 Mon Sep 17 00:00:00 2001
From: mod242 <40213799+mod242@users.noreply.github.com>
Date: Mon, 29 Apr 2019 10:43:16 +0200
Subject: [PATCH 2/6] Create dns_schlundtech.sh
---
dnsapi/dns_schlundtech.sh | 261 ++++++++++++++++++++++++++++++++++++++
1 file changed, 261 insertions(+)
create mode 100644 dnsapi/dns_schlundtech.sh
diff --git a/dnsapi/dns_schlundtech.sh b/dnsapi/dns_schlundtech.sh
new file mode 100644
index 0000000..202b346
--- /dev/null
+++ b/dnsapi/dns_schlundtech.sh
@@ -0,0 +1,261 @@
+#!/usr/bin/env sh
+# -*- mode: sh; tab-width: 2; indent-tabs-mode: s; coding: utf-8 -*-
+
+# Schlundtech DNS API
+# Author: mod242
+# Created: 2019-40-29
+# Completly based on the autoDNS xml api wrapper by auerswald@gmail.com
+#
+# export SCHLUNDTECH_USER="username"
+# export SCHLUNDTECH_PASSWORD="password"
+#
+# Usage:
+# acme.sh --issue --dns dns_autodns -d example.com
+
+AUTODNS_API="https://gateway.schlundtech.de"
+
+# Arguments:
+# txtdomain
+# txt
+dns_schlundtech_add() {
+ fulldomain="$1"
+ txtvalue="$2"
+
+ SCHLUNDTECH_USER="${SCHLUNDTECH_USER:-$(_readaccountconf_mutable AUTODNS_USER)}"
+ SCHLUNDTECH_PASSWORD="${SCHLUNDTECH_PASSWORD:-$(_readaccountconf_mutable AUTODNS_PASSWORD)}"
+
+ if [ -z "$SCHLUNDTECH_USER" ] || [ -z "$SCHLUNDTECH_PASSWORD" ]; then
+ _err "You didn't specify schlundtech user and password."
+ return 1
+ fi
+
+ _saveaccountconf_mutable SCHLUNDTECH_USER "$SCHLUNDTECH_USER"
+ _saveaccountconf_mutable SCHLUNDTECH_PASSWORD "$SCHLUNDTECH_PASSWORD"
+
+ _debug "First detect the root zone"
+
+ if ! _get_autodns_zone "$fulldomain"; then
+ _err "invalid domain"
+ return 1
+ fi
+
+ _debug _sub_domain "$_sub_domain"
+ _debug _zone "$_zone"
+ _debug _system_ns "$_system_ns"
+
+ _info "Adding TXT record"
+
+ autodns_response="$(_autodns_zone_update "$_zone" "$_sub_domain" "$txtvalue" "$_system_ns")"
+
+ if [ "$?" -eq "0" ]; then
+ _info "Added, OK"
+ return 0
+ fi
+
+ return 1
+}
+
+# Arguments:
+# txtdomain
+# txt
+dns_schlundtech_rm() {
+ fulldomain="$1"
+ txtvalue="$2"
+
+ SCHLUNDTECH_USER="${SCHLUNDTECH_USER:-$(_readaccountconf_mutable AUTODNS_USER)}"
+ SCHLUNDTECH_PASSWORD="${SCHLUNDTECH_PASSWORD:-$(_readaccountconf_mutable AUTODNS_PASSWORD)}"
+
+ if [ -z "$SCHLUNDTECH_USER" ] || [ -z "$SCHLUNDTECH_PASSWORD" ]; then
+ _err "You didn't specify schlundtech user and password."
+ return 1
+ fi
+
+ _debug "First detect the root zone"
+
+ if ! _get_autodns_zone "$fulldomain"; then
+ _err "zone not found"
+ return 1
+ fi
+
+ _debug _sub_domain "$_sub_domain"
+ _debug _zone "$_zone"
+ _debug _system_ns "$_system_ns"
+
+ _info "Delete TXT record"
+
+ autodns_response="$(_autodns_zone_cleanup "$_zone" "$_sub_domain" "$txtvalue" "$_system_ns")"
+
+ if [ "$?" -eq "0" ]; then
+ _info "Deleted, OK"
+ return 0
+ fi
+
+ return 1
+}
+
+#################### Private functions below ##################################
+
+# Arguments:
+# fulldomain
+# Returns:
+# _sub_domain=_acme-challenge.www
+# _zone=domain.com
+# _system_ns
+_get_autodns_zone() {
+ domain="$1"
+
+ i=2
+ p=1
+
+ while true; do
+ h=$(printf "%s" "$domain" | cut -d . -f $i-100)
+ _debug h "$h"
+
+ if [ -z "$h" ]; then
+ # not valid
+ return 1
+ fi
+
+ autodns_response="$(_autodns_zone_inquire "$h")"
+
+ if [ "$?" -ne "0" ]; then
+ _err "invalid domain"
+ return 1
+ fi
+
+ if _contains "$autodns_response" "1" >/dev/null; then
+ _zone="$(echo "$autodns_response" | _egrep_o '[^<]*' | cut -d '>' -f 2 | cut -d '<' -f 1)"
+ _system_ns="$(echo "$autodns_response" | _egrep_o '[^<]*' | cut -d '>' -f 2 | cut -d '<' -f 1)"
+ _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
+ return 0
+ fi
+
+ p=$i
+ i=$(_math "$i" + 1)
+ done
+
+ return 1
+}
+
+_build_request_auth_xml() {
+ printf "
+ %s
+ %s
+ 10
+ " "$SCHLUNDTECH_USER" "$SCHLUNDTECH_PASSWORD"
+}
+
+# Arguments:
+# zone
+_build_zone_inquire_xml() {
+ printf "
+
+ %s
+
+ 0205
+
+ 1
+ 1
+
+
+ name
+ eq
+ %s
+
+
+ " "$(_build_request_auth_xml)" "$1"
+}
+
+# Arguments:
+# zone
+# subdomain
+# txtvalue
+# system_ns
+_build_zone_update_xml() {
+ printf "
+
+ %s
+
+ 0202001
+
+
+ %s
+ 600
+ TXT
+ %s
+
+
+
+ %s
+ %s
+
+
+ " "$(_build_request_auth_xml)" "$2" "$3" "$1" "$4"
+}
+
+# Arguments:
+# zone
+_autodns_zone_inquire() {
+ request_data="$(_build_zone_inquire_xml "$1")"
+ autodns_response="$(_autodns_api_call "$request_data")"
+ ret="$?"
+
+ printf "%s" "$autodns_response"
+ return "$ret"
+}
+
+# Arguments:
+# zone
+# subdomain
+# txtvalue
+# system_ns
+_autodns_zone_update() {
+ request_data="$(_build_zone_update_xml "$1" "$2" "$3" "$4")"
+ autodns_response="$(_autodns_api_call "$request_data")"
+ ret="$?"
+
+ printf "%s" "$autodns_response"
+ return "$ret"
+}
+
+# Arguments:
+# zone
+# subdomain
+# txtvalue
+# system_ns
+_autodns_zone_cleanup() {
+ request_data="$(_build_zone_update_xml "$1" "$2" "$3" "$4")"
+ # replace 'rr_add>' with 'rr_rem>' in request_data
+ request_data="$(printf -- "%s" "$request_data" | sed 's/rr_add>/rr_rem>/g')"
+ autodns_response="$(_autodns_api_call "$request_data")"
+ ret="$?"
+
+ printf "%s" "$autodns_response"
+ return "$ret"
+}
+
+# Arguments:
+# request_data
+_autodns_api_call() {
+ request_data="$1"
+
+ _debug request_data "$request_data"
+
+ autodns_response="$(_post "$request_data" "$AUTODNS_API")"
+ ret="$?"
+
+ _debug autodns_response "$autodns_response"
+
+ if [ "$ret" -ne "0" ]; then
+ _err "error"
+ return 1
+ fi
+
+ if _contains "$autodns_response" "success" >/dev/null; then
+ _info "success"
+ printf "%s" "$autodns_response"
+ return 0
+ fi
+
+ return 1
+}
From 345d6c5687e48dae07494565d735a367f6faa7af Mon Sep 17 00:00:00 2001
From: mod242 <40213799+mod242@users.noreply.github.com>
Date: Mon, 29 Apr 2019 10:44:23 +0200
Subject: [PATCH 3/6] Update dns_schlundtech.sh
---
dnsapi/dns_schlundtech.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dnsapi/dns_schlundtech.sh b/dnsapi/dns_schlundtech.sh
index 202b346..c5e7d63 100644
--- a/dnsapi/dns_schlundtech.sh
+++ b/dnsapi/dns_schlundtech.sh
@@ -21,8 +21,8 @@ dns_schlundtech_add() {
fulldomain="$1"
txtvalue="$2"
- SCHLUNDTECH_USER="${SCHLUNDTECH_USER:-$(_readaccountconf_mutable AUTODNS_USER)}"
- SCHLUNDTECH_PASSWORD="${SCHLUNDTECH_PASSWORD:-$(_readaccountconf_mutable AUTODNS_PASSWORD)}"
+ SCHLUNDTECH_USER="${SCHLUNDTECH_USER:-$(_readaccountconf_mutable SCHLUNDTECH_USER)}"
+ SCHLUNDTECH_PASSWORD="${SCHLUNDTECH_PASSWORD:-$(_readaccountconf_mutable SCHLUNDTECH_PASSWORD)}"
if [ -z "$SCHLUNDTECH_USER" ] || [ -z "$SCHLUNDTECH_PASSWORD" ]; then
_err "You didn't specify schlundtech user and password."
From 9b68a3ef4acb7112119d01182965394cd653c761 Mon Sep 17 00:00:00 2001
From: mod242 <40213799+mod242@users.noreply.github.com>
Date: Mon, 29 Apr 2019 12:13:40 +0200
Subject: [PATCH 4/6] Update dns_schlundtech.sh
---
dnsapi/dns_schlundtech.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dnsapi/dns_schlundtech.sh b/dnsapi/dns_schlundtech.sh
index c5e7d63..efb021a 100644
--- a/dnsapi/dns_schlundtech.sh
+++ b/dnsapi/dns_schlundtech.sh
@@ -62,8 +62,8 @@ dns_schlundtech_rm() {
fulldomain="$1"
txtvalue="$2"
- SCHLUNDTECH_USER="${SCHLUNDTECH_USER:-$(_readaccountconf_mutable AUTODNS_USER)}"
- SCHLUNDTECH_PASSWORD="${SCHLUNDTECH_PASSWORD:-$(_readaccountconf_mutable AUTODNS_PASSWORD)}"
+ SCHLUNDTECH_USER="${SCHLUNDTECH_USER:-$(_readaccountconf_mutable SCHLUNDTECH_USER)}"
+ SCHLUNDTECH_PASSWORD="${SCHLUNDTECH_PASSWORD:-$(_readaccountconf_mutable SCHLUNDTECH_PASSWORD)}"
if [ -z "$SCHLUNDTECH_USER" ] || [ -z "$SCHLUNDTECH_PASSWORD" ]; then
_err "You didn't specify schlundtech user and password."
From 175b56b43c05ed0ed2ec432e3e1ead2f12f78414 Mon Sep 17 00:00:00 2001
From: mod242 <40213799+mod242@users.noreply.github.com>
Date: Mon, 29 Apr 2019 12:18:05 +0200
Subject: [PATCH 5/6] Update dns_schlundtech.sh
---
dnsapi/dns_schlundtech.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dnsapi/dns_schlundtech.sh b/dnsapi/dns_schlundtech.sh
index efb021a..1240863 100644
--- a/dnsapi/dns_schlundtech.sh
+++ b/dnsapi/dns_schlundtech.sh
@@ -10,9 +10,9 @@
# export SCHLUNDTECH_PASSWORD="password"
#
# Usage:
-# acme.sh --issue --dns dns_autodns -d example.com
+# acme.sh --issue --dns dns_schlundtech -d example.com
-AUTODNS_API="https://gateway.schlundtech.de"
+SCHLUNDTECH_API="https://gateway.schlundtech.de"
# Arguments:
# txtdomain
@@ -241,7 +241,7 @@ _autodns_api_call() {
_debug request_data "$request_data"
- autodns_response="$(_post "$request_data" "$AUTODNS_API")"
+ autodns_response="$(_post "$request_data" "$SCHLUNDTECH_API")"
ret="$?"
_debug autodns_response "$autodns_response"
From d7be2c5b8a4eb49da47faea5ded8da66d30f98b6 Mon Sep 17 00:00:00 2001
From: mod242 <40213799+mod242@users.noreply.github.com>
Date: Mon, 29 Apr 2019 16:17:24 +0200
Subject: [PATCH 6/6] Remove from Master Branch
---
dnsapi/dns_schlundtech.sh | 261 --------------------------------------
1 file changed, 261 deletions(-)
delete mode 100644 dnsapi/dns_schlundtech.sh
diff --git a/dnsapi/dns_schlundtech.sh b/dnsapi/dns_schlundtech.sh
deleted file mode 100644
index 1240863..0000000
--- a/dnsapi/dns_schlundtech.sh
+++ /dev/null
@@ -1,261 +0,0 @@
-#!/usr/bin/env sh
-# -*- mode: sh; tab-width: 2; indent-tabs-mode: s; coding: utf-8 -*-
-
-# Schlundtech DNS API
-# Author: mod242
-# Created: 2019-40-29
-# Completly based on the autoDNS xml api wrapper by auerswald@gmail.com
-#
-# export SCHLUNDTECH_USER="username"
-# export SCHLUNDTECH_PASSWORD="password"
-#
-# Usage:
-# acme.sh --issue --dns dns_schlundtech -d example.com
-
-SCHLUNDTECH_API="https://gateway.schlundtech.de"
-
-# Arguments:
-# txtdomain
-# txt
-dns_schlundtech_add() {
- fulldomain="$1"
- txtvalue="$2"
-
- SCHLUNDTECH_USER="${SCHLUNDTECH_USER:-$(_readaccountconf_mutable SCHLUNDTECH_USER)}"
- SCHLUNDTECH_PASSWORD="${SCHLUNDTECH_PASSWORD:-$(_readaccountconf_mutable SCHLUNDTECH_PASSWORD)}"
-
- if [ -z "$SCHLUNDTECH_USER" ] || [ -z "$SCHLUNDTECH_PASSWORD" ]; then
- _err "You didn't specify schlundtech user and password."
- return 1
- fi
-
- _saveaccountconf_mutable SCHLUNDTECH_USER "$SCHLUNDTECH_USER"
- _saveaccountconf_mutable SCHLUNDTECH_PASSWORD "$SCHLUNDTECH_PASSWORD"
-
- _debug "First detect the root zone"
-
- if ! _get_autodns_zone "$fulldomain"; then
- _err "invalid domain"
- return 1
- fi
-
- _debug _sub_domain "$_sub_domain"
- _debug _zone "$_zone"
- _debug _system_ns "$_system_ns"
-
- _info "Adding TXT record"
-
- autodns_response="$(_autodns_zone_update "$_zone" "$_sub_domain" "$txtvalue" "$_system_ns")"
-
- if [ "$?" -eq "0" ]; then
- _info "Added, OK"
- return 0
- fi
-
- return 1
-}
-
-# Arguments:
-# txtdomain
-# txt
-dns_schlundtech_rm() {
- fulldomain="$1"
- txtvalue="$2"
-
- SCHLUNDTECH_USER="${SCHLUNDTECH_USER:-$(_readaccountconf_mutable SCHLUNDTECH_USER)}"
- SCHLUNDTECH_PASSWORD="${SCHLUNDTECH_PASSWORD:-$(_readaccountconf_mutable SCHLUNDTECH_PASSWORD)}"
-
- if [ -z "$SCHLUNDTECH_USER" ] || [ -z "$SCHLUNDTECH_PASSWORD" ]; then
- _err "You didn't specify schlundtech user and password."
- return 1
- fi
-
- _debug "First detect the root zone"
-
- if ! _get_autodns_zone "$fulldomain"; then
- _err "zone not found"
- return 1
- fi
-
- _debug _sub_domain "$_sub_domain"
- _debug _zone "$_zone"
- _debug _system_ns "$_system_ns"
-
- _info "Delete TXT record"
-
- autodns_response="$(_autodns_zone_cleanup "$_zone" "$_sub_domain" "$txtvalue" "$_system_ns")"
-
- if [ "$?" -eq "0" ]; then
- _info "Deleted, OK"
- return 0
- fi
-
- return 1
-}
-
-#################### Private functions below ##################################
-
-# Arguments:
-# fulldomain
-# Returns:
-# _sub_domain=_acme-challenge.www
-# _zone=domain.com
-# _system_ns
-_get_autodns_zone() {
- domain="$1"
-
- i=2
- p=1
-
- while true; do
- h=$(printf "%s" "$domain" | cut -d . -f $i-100)
- _debug h "$h"
-
- if [ -z "$h" ]; then
- # not valid
- return 1
- fi
-
- autodns_response="$(_autodns_zone_inquire "$h")"
-
- if [ "$?" -ne "0" ]; then
- _err "invalid domain"
- return 1
- fi
-
- if _contains "$autodns_response" "1" >/dev/null; then
- _zone="$(echo "$autodns_response" | _egrep_o '[^<]*' | cut -d '>' -f 2 | cut -d '<' -f 1)"
- _system_ns="$(echo "$autodns_response" | _egrep_o '[^<]*' | cut -d '>' -f 2 | cut -d '<' -f 1)"
- _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
- return 0
- fi
-
- p=$i
- i=$(_math "$i" + 1)
- done
-
- return 1
-}
-
-_build_request_auth_xml() {
- printf "
- %s
- %s
- 10
- " "$SCHLUNDTECH_USER" "$SCHLUNDTECH_PASSWORD"
-}
-
-# Arguments:
-# zone
-_build_zone_inquire_xml() {
- printf "
-
- %s
-
- 0205
-
- 1
- 1
-
-
- name
- eq
- %s
-
-
- " "$(_build_request_auth_xml)" "$1"
-}
-
-# Arguments:
-# zone
-# subdomain
-# txtvalue
-# system_ns
-_build_zone_update_xml() {
- printf "
-
- %s
-
- 0202001
-
-
- %s
- 600
- TXT
- %s
-
-
-
- %s
- %s
-
-
- " "$(_build_request_auth_xml)" "$2" "$3" "$1" "$4"
-}
-
-# Arguments:
-# zone
-_autodns_zone_inquire() {
- request_data="$(_build_zone_inquire_xml "$1")"
- autodns_response="$(_autodns_api_call "$request_data")"
- ret="$?"
-
- printf "%s" "$autodns_response"
- return "$ret"
-}
-
-# Arguments:
-# zone
-# subdomain
-# txtvalue
-# system_ns
-_autodns_zone_update() {
- request_data="$(_build_zone_update_xml "$1" "$2" "$3" "$4")"
- autodns_response="$(_autodns_api_call "$request_data")"
- ret="$?"
-
- printf "%s" "$autodns_response"
- return "$ret"
-}
-
-# Arguments:
-# zone
-# subdomain
-# txtvalue
-# system_ns
-_autodns_zone_cleanup() {
- request_data="$(_build_zone_update_xml "$1" "$2" "$3" "$4")"
- # replace 'rr_add>' with 'rr_rem>' in request_data
- request_data="$(printf -- "%s" "$request_data" | sed 's/rr_add>/rr_rem>/g')"
- autodns_response="$(_autodns_api_call "$request_data")"
- ret="$?"
-
- printf "%s" "$autodns_response"
- return "$ret"
-}
-
-# Arguments:
-# request_data
-_autodns_api_call() {
- request_data="$1"
-
- _debug request_data "$request_data"
-
- autodns_response="$(_post "$request_data" "$SCHLUNDTECH_API")"
- ret="$?"
-
- _debug autodns_response "$autodns_response"
-
- if [ "$ret" -ne "0" ]; then
- _err "error"
- return 1
- fi
-
- if _contains "$autodns_response" "success" >/dev/null; then
- _info "success"
- printf "%s" "$autodns_response"
- return 0
- fi
-
- return 1
-}