|
@ -13,19 +13,18 @@ |
|
|
# Git repo: https://github.com/phlegx/acme.sh |
|
|
# Git repo: https://github.com/phlegx/acme.sh |
|
|
# TODO: Better Error handling |
|
|
# TODO: Better Error handling |
|
|
######################################################################## |
|
|
######################################################################## |
|
|
|
|
|
|
|
|
KAS_Api="https://kasapi.kasserver.com/dokumentation/formular.php" |
|
|
KAS_Api="https://kasapi.kasserver.com/dokumentation/formular.php" |
|
|
|
|
|
|
|
|
######## Public functions ##################### |
|
|
######## Public functions ##################### |
|
|
|
|
|
|
|
|
dns_kas_add() { |
|
|
|
|
|
|
|
|
dns_kas_add(){ |
|
|
_fulldomain=$1 |
|
|
_fulldomain=$1 |
|
|
_txtvalue=$2 |
|
|
_txtvalue=$2 |
|
|
_info "Using DNS-01 All-inkl/Kasserver hook" |
|
|
_info "Using DNS-01 All-inkl/Kasserver hook" |
|
|
_info "Adding or Updating $_fulldomain DNS TXT entry on All-inkl/Kasserver" |
|
|
_info "Adding or Updating $_fulldomain DNS TXT entry on All-inkl/Kasserver" |
|
|
|
|
|
|
|
|
|
|
|
_info "Check and Save Props" |
|
|
_check_and_save |
|
|
_check_and_save |
|
|
|
|
|
_info "Checking Zone and Record_Name" |
|
|
_get_zone_and_record_name "$_fulldomain" |
|
|
_get_zone_and_record_name "$_fulldomain" |
|
|
|
|
|
_info "Getting Record ID" |
|
|
_get_record_id |
|
|
_get_record_id |
|
|
|
|
|
|
|
|
_info "Creating TXT DNS record" |
|
|
_info "Creating TXT DNS record" |
|
@ -62,8 +61,11 @@ dns_kas_rm() { |
|
|
_info "Cleaning up after All-inkl/Kasserver hook" |
|
|
_info "Cleaning up after All-inkl/Kasserver hook" |
|
|
_info "Removing $_fulldomain DNS TXT entry on All-inkl/Kasserver" |
|
|
_info "Removing $_fulldomain DNS TXT entry on All-inkl/Kasserver" |
|
|
|
|
|
|
|
|
|
|
|
_info "Check and Save Props" |
|
|
_check_and_save |
|
|
_check_and_save |
|
|
|
|
|
_info "Checking Zone and Record_Name" |
|
|
_get_zone_and_record_name "$_fulldomain" |
|
|
_get_zone_and_record_name "$_fulldomain" |
|
|
|
|
|
_info "Getting Record ID" |
|
|
_get_record_id |
|
|
_get_record_id |
|
|
|
|
|
|
|
|
# If there is a record_id, delete the entry |
|
|
# If there is a record_id, delete the entry |
|
@ -116,11 +118,19 @@ _check_and_save() { |
|
|
# Gets back the base domain/zone and record name. |
|
|
# Gets back the base domain/zone and record name. |
|
|
# See: https://github.com/Neilpang/acme.sh/wiki/DNS-API-Dev-Guide |
|
|
# See: https://github.com/Neilpang/acme.sh/wiki/DNS-API-Dev-Guide |
|
|
_get_zone_and_record_name() { |
|
|
_get_zone_and_record_name() { |
|
|
_zonen="$( echo "$response" | tr -d "\n\r" | tr -d " " | tr '[]' '<>' | sed "s/=>Array/\n=> Array/g" | tr ' ' '\n' | grep "domain_name" | tr '<' '\n' | grep "domain_name" | cut -d '>' -f 3)" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
params="?kas_login=$KAS_Login" |
|
|
|
|
|
params="$params&kas_auth_type=$KAS_Authtype" |
|
|
|
|
|
params="$params&kas_auth_data=$KAS_Authdata" |
|
|
|
|
|
params="$params&kas_action=get_domains" |
|
|
|
|
|
|
|
|
|
|
|
_debug2 "Wait for 10 seconds by default before calling KAS API." |
|
|
|
|
|
sleep 10 |
|
|
|
|
|
response="$(_get "$KAS_Api$params")" |
|
|
|
|
|
_debug2 "response" "$response" |
|
|
|
|
|
_zonen="$( echo "$response" | tr -d "\n\r" | tr -d " " | tr '[]' '<>' | sed "s/=>Array/\n=> Array/g" | tr ' ' '\n' | grep "domain_name" | tr '<' '\n' | grep "domain_name" | sed "s/domain_name>=>//g")" |
|
|
_domain="$1" |
|
|
_domain="$1" |
|
|
if _endswith "$_domain" "."; then |
|
|
|
|
|
_domain="$(echo "$_domain" | sed 's/.$//')" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
_temp_domain="$(echo "$1" | sed 's/\.$//')" |
|
|
_rootzone="$_domain" |
|
|
_rootzone="$_domain" |
|
|
for i in $_zonen; do |
|
|
for i in $_zonen; do |
|
|
l1=${#_rootzone} |
|
|
l1=${#_rootzone} |
|
@ -129,12 +139,12 @@ _get_zone_and_record_name() { |
|
|
_rootzone="$i" |
|
|
_rootzone="$i" |
|
|
fi |
|
|
fi |
|
|
done |
|
|
done |
|
|
_zone="$_rootzone" |
|
|
|
|
|
_debug2 "zone:" "$_zone" |
|
|
|
|
|
|
|
|
|
|
|
l3=$((${#_domain}-l1-1)) |
|
|
|
|
|
_record_name="$(echo "$_domain" | cut -c -"$l3")" |
|
|
|
|
|
_debug2 "record_name:" "$_record_name" |
|
|
|
|
|
|
|
|
_zone="${_rootzone}." |
|
|
|
|
|
_temp_record_name="$(echo "$_temp_domain" | sed "s/"$_rootzone"//g")" |
|
|
|
|
|
_record_name="$(echo "$_temp_record_name" | sed 's/\.$//')" |
|
|
|
|
|
_debug2 "Zone:" "$_zone" |
|
|
|
|
|
_debug2 "Domain:" "$_domain" |
|
|
|
|
|
_debug2 "Record_Name:" "$_record_name" |
|
|
return 0 |
|
|
return 0 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -151,7 +161,7 @@ _get_record_id() { |
|
|
sleep 10 |
|
|
sleep 10 |
|
|
response="$(_get "$KAS_Api$params")" |
|
|
response="$(_get "$KAS_Api$params")" |
|
|
_debug2 "response" "$response" |
|
|
_debug2 "response" "$response" |
|
|
_record_id="$(echo "$response" | tr -d "\n\r" | tr -d " " | tr '[]' '<>' | sed "s/=>Array/\n=> Array/g" | tr ' ' '\n' | grep "=>$_record_name<" | grep '>TXT<' | tr '<' '\n' | grep record_id | cut -d '>' -f 3)" |
|
|
|
|
|
|
|
|
_record_id="$(echo "$response" | tr -d "\n\r" | tr -d " " | tr '[]' '<>' | sed "s/=>Array/\n=> Array/g" | tr ' ' '\n' | grep "=>$_record_name<" | grep '>TXT<' | tr '<' '\n' | grep record_id | sed "s/record_id>=>//g")" |
|
|
_debug2 _record_id "$_record_id" |
|
|
_debug2 _record_id "$_record_id" |
|
|
return 0 |
|
|
return 0 |
|
|
} |
|
|
} |