mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-05-05 23:24:54 +00:00
complete overhaul (after github actions mess)
This commit is contained in:
parent
233d821471
commit
26edfc2928
@ -15,17 +15,16 @@
|
|||||||
# Previous update by Marc-Oliver Lange <git@die-lang.es>
|
# Previous update by Marc-Oliver Lange <git@die-lang.es>
|
||||||
# KASAPI SOAP guideline by https://github.com/o1oo11oo/kasapi.sh
|
# KASAPI SOAP guideline by https://github.com/o1oo11oo/kasapi.sh
|
||||||
########################################################################
|
########################################################################
|
||||||
# KAS_Api_GET="$(_get "https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl")"
|
KAS_Api_GET="$(_get "https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl")"
|
||||||
# KAS_Api="$(echo "$KAS_Api_GET" | tr -d ' ' | grep -i "<soap:addresslocation=" | sed "s/='/\n/g" | grep -i "http" | sed "s/'\/>//g")"
|
KAS_Api="$(echo "$KAS_Api_GET" | tr -d ' ' | grep -i "<soap:addresslocation=" | sed "s/='/\n/g" | grep -i "http" | sed "s/'\/>//g")"
|
||||||
KAS_Api='https://kasapi.kasserver.com/soap/KasApi.php'
|
|
||||||
_info "##KAS## Using $KAS_Api"
|
_info "##KAS## Using $KAS_Api"
|
||||||
KAS_default_ratelimit=5
|
KAS_default_ratelimit=5 # TODO - Every response delivers a ratelimit (seconds) where KASAPI is blocking a request.
|
||||||
######## Public functions #####################
|
######## Public functions #####################
|
||||||
dns_kas_add() {
|
dns_kas_add() {
|
||||||
_fulldomain=$1
|
_fulldomain=$1
|
||||||
_txtvalue=$2
|
_txtvalue=$2
|
||||||
_info "##KAS## ##KAS## Using DNS-01 All-inkl/Kasserver hook"
|
_info "##KAS## Using DNS-01 All-inkl/Kasserver hook"
|
||||||
_info "##KAS## ##KAS## Adding $_fulldomain DNS TXT entry on All-inkl/Kasserver"
|
_info "##KAS## Adding $_fulldomain DNS TXT entry on All-inkl/Kasserver"
|
||||||
_info "##KAS## Check and Save Props"
|
_info "##KAS## Check and Save Props"
|
||||||
_check_and_save
|
_check_and_save
|
||||||
_info "##KAS## Checking Zone and Record_Name"
|
_info "##KAS## Checking Zone and Record_Name"
|
||||||
@ -35,41 +34,28 @@ dns_kas_add() {
|
|||||||
|
|
||||||
_info "##KAS## Creating TXT DNS record"
|
_info "##KAS## Creating TXT DNS record"
|
||||||
|
|
||||||
export _H1="SOAPAction: \"urn:xmethodsKasApi#KasApi\""
|
|
||||||
|
|
||||||
params_auth="\"kas_login\":\"$KAS_Login\""
|
|
||||||
params_auth="$params_auth,\"kas_auth_type\":\"$KAS_Authtype\""
|
|
||||||
params_auth="$params_auth,\"kas_auth_data\":\"$KAS_Authdata\""
|
|
||||||
|
|
||||||
params_request="\"record_name\":\"$_record_name\""
|
params_request="\"record_name\":\"$_record_name\""
|
||||||
params_request="$params_request,\"record_type\":\"TXT\""
|
params_request="$params_request,\"record_type\":\"TXT\""
|
||||||
params_request="$params_request,\"record_data\":\"$_txtvalue\""
|
params_request="$params_request,\"record_data\":\"$_txtvalue\""
|
||||||
params_request="$params_request,\"record_aux\":\"0\""
|
params_request="$params_request,\"record_aux\":\"0\""
|
||||||
params_request="$params_request,\"zone_host\":\"$_zone\""
|
params_request="$params_request,\"zone_host\":\"$_zone\""
|
||||||
|
|
||||||
params='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethodsKasApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:KasApi><Params xsi:type="xsd:string">{'
|
response="$(_post_soap "add_dns_settings" "$params_request")"
|
||||||
params="$params$params_auth,\"kas_action\":\"add_dns_settings\""
|
|
||||||
params="$params,\"KasRequestParams\":{$params_request}"
|
|
||||||
params="$params}</Params></ns1:KasApi></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
|
||||||
|
|
||||||
_debug2 "##KAS## ##KAS## Wait for $KAS_default_ratelimit seconds by default before calling KAS API."
|
|
||||||
_sleep $KAS_default_ratelimit
|
|
||||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
|
||||||
_debug2 "##KAS## response" "$response"
|
|
||||||
if [ -z "$response" ]; then
|
if [ -z "$response" ]; then
|
||||||
_info "##KAS## Response was empty, 2nd attempt"
|
_info "##KAS## Response was empty, please check manually."
|
||||||
_sleep $KAS_default_ratelimit
|
return 1
|
||||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
elif _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||||
_debug2 "##KAS## retry response" "$response"
|
faultstring="$(echo "$response" | tr -d '\n\r' | sed "s/<faultstring>/\n=> /g" | sed "s/<\/faultstring>/\n/g" | grep "=>" | sed "s/=> //g")"
|
||||||
fi
|
case "$faultstring" in
|
||||||
|
"record_already_exists")
|
||||||
if _contains "$response" "<SOAP-ENV:Fault>"; then
|
_info "##KAS## The record already exists, which must not be a problem. Please check manually."
|
||||||
if _contains "$response" "record_already_exists"; then
|
;;
|
||||||
_info "##KAS## The record already exists, which must not be a problem. Please check manually."
|
*)
|
||||||
else
|
_err "##KAS## An error =>$faultstring<= occurred, please check manually."
|
||||||
_err "##KAS## An error occurred, please check manually."
|
return 1
|
||||||
return 1
|
;;
|
||||||
fi
|
esac
|
||||||
elif ! _contains "$response" "<item><key xsi:type=\"xsd:string\">ReturnString</key><value xsi:type=\"xsd:string\">TRUE</value></item>"; then
|
elif ! _contains "$response" "<item><key xsi:type=\"xsd:string\">ReturnString</key><value xsi:type=\"xsd:string\">TRUE</value></item>"; then
|
||||||
_err "##KAS## An unknown error occurred, please check manually."
|
_err "##KAS## An unknown error occurred, please check manually."
|
||||||
return 1
|
return 1
|
||||||
@ -83,7 +69,6 @@ dns_kas_rm() {
|
|||||||
_info "##KAS## Using DNS-01 All-inkl/Kasserver hook"
|
_info "##KAS## Using DNS-01 All-inkl/Kasserver hook"
|
||||||
_info "##KAS## Cleaning up after All-inkl/Kasserver hook"
|
_info "##KAS## Cleaning up after All-inkl/Kasserver hook"
|
||||||
_info "##KAS## Removing $_fulldomain DNS TXT entry on All-inkl/Kasserver"
|
_info "##KAS## Removing $_fulldomain DNS TXT entry on All-inkl/Kasserver"
|
||||||
|
|
||||||
_info "##KAS## Check and Save Props"
|
_info "##KAS## Check and Save Props"
|
||||||
_check_and_save
|
_check_and_save
|
||||||
_info "##KAS## Checking Zone and Record_Name"
|
_info "##KAS## Checking Zone and Record_Name"
|
||||||
@ -91,44 +76,34 @@ dns_kas_rm() {
|
|||||||
_info "##KAS## Getting Record ID"
|
_info "##KAS## Getting Record ID"
|
||||||
_get_record_id
|
_get_record_id
|
||||||
|
|
||||||
# If there is a record_id, delete the entry
|
|
||||||
if [ -n "$_record_id" ]; then
|
if [ -n "$_record_id" ]; then
|
||||||
export _H1="SOAPAction: \"urn:xmethodsKasApi#KasApi\""
|
|
||||||
|
|
||||||
params_auth="\"kas_login\":\"$KAS_Login\""
|
|
||||||
params_auth="$params_auth,\"kas_auth_type\":\"$KAS_Authtype\""
|
|
||||||
params_auth="$params_auth,\"kas_auth_data\":\"$KAS_Authdata\""
|
|
||||||
|
|
||||||
params_request="\"record_id\":\"RECORDID\""
|
|
||||||
|
|
||||||
params='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethodsKasApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:KasApi><Params xsi:type="xsd:string">{'
|
|
||||||
params="$params$params_auth,\"kas_action\":\"delete_dns_settings\""
|
|
||||||
params="$params,\"KasRequestParams\":{$params_request}"
|
|
||||||
params="$params}</Params></ns1:KasApi></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
|
||||||
|
|
||||||
for i in $_record_id; do
|
for i in $_record_id; do
|
||||||
params2="$(echo $params | sed "s/RECORDID/$i/g")"
|
_info "##KAS## Removing $_record_id"
|
||||||
_debug2 "##KAS## Wait for $KAS_default_ratelimit seconds by default before calling KAS API."
|
params_request="\"record_id\":\"$_record_id\""
|
||||||
_sleep $KAS_default_ratelimit
|
|
||||||
response="$(_post "$params2" "$KAS_Api" "" "POST" "text/xml")"
|
response="$(_post_soap "delete_dns_settings" "$params_request")"
|
||||||
_debug2 "##KAS## response" "$response"
|
|
||||||
if [ -z "$response" ]; then
|
if [ -z "$response" ]; then
|
||||||
_info "##KAS## Response was empty, 2nd attempt"
|
_info "##KAS## Response was empty, please check manually."
|
||||||
_sleep $KAS_default_ratelimit
|
|
||||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
|
||||||
_debug2 "##KAS## retry response" "$response"
|
|
||||||
fi
|
|
||||||
if _contains "$response" "<SOAP-ENV:Fault>"; then
|
|
||||||
_err "##KAS## Either the txt record was not found or another error occurred, please check manually."
|
|
||||||
return 1
|
return 1
|
||||||
|
elif _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||||
|
faultstring="$(echo "$response" | tr -d '\n\r' | sed "s/<faultstring>/\n=> /g" | sed "s/<\/faultstring>/\n/g" | grep "=>" | sed "s/=> //g")"
|
||||||
|
case "$faultstring" in
|
||||||
|
"record_id_not_found")
|
||||||
|
_info "##KAS## The record was not found, which must not be a problem. Please check manually."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_err "##KAS## An error =>$faultstring<= occurred, please check manually."
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
elif ! _contains "$response" "<item><key xsi:type=\"xsd:string\">ReturnString</key><value xsi:type=\"xsd:string\">TRUE</value></item>"; then
|
elif ! _contains "$response" "<item><key xsi:type=\"xsd:string\">ReturnString</key><value xsi:type=\"xsd:string\">TRUE</value></item>"; then
|
||||||
_err "##KAS## Either the txt record was not found or another unknown error occurred, please check manually."
|
_err "##KAS## An unknown error occurred, please check manually."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else # Cannot delete or unkown error
|
else
|
||||||
_info "##KAS## No record_id found that can be automatically deleted. Please check or delete manually."
|
_info "##KAS## No records where found, which must not be a problem. Please check manually."
|
||||||
# return 1
|
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -157,30 +132,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/acmesh-official/acme.sh/wiki/DNS-API-Dev-Guide
|
# See: https://github.com/acmesh-official/acme.sh/wiki/DNS-API-Dev-Guide
|
||||||
_get_zone_and_record_name() {
|
_get_zone_and_record_name() {
|
||||||
export _H1="SOAPAction: \"urn:xmethodsKasApi#KasApi\""
|
_info "##KAS## Get domain info"
|
||||||
|
|
||||||
params_auth="\"kas_login\":\"$KAS_Login\""
|
response="$(_post_soap "get_domains")"
|
||||||
params_auth="$params_auth,\"kas_auth_type\":\"$KAS_Authtype\""
|
|
||||||
params_auth="$params_auth,\"kas_auth_data\":\"$KAS_Authdata\""
|
|
||||||
|
|
||||||
params='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethodsKasApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:KasApi><Params xsi:type="xsd:string">{'
|
|
||||||
params="$params$params_auth,\"kas_action\":\"get_domains\""
|
|
||||||
params="$params}</Params></ns1:KasApi></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
|
||||||
|
|
||||||
_debug2 "##KAS## Wait for $KAS_default_ratelimit seconds by default before calling KAS API."
|
|
||||||
_sleep $KAS_default_ratelimit
|
|
||||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
|
||||||
_debug2 "##KAS## response" "$response"
|
|
||||||
if [ -z "$response" ]; then
|
if [ -z "$response" ]; then
|
||||||
_info "##KAS## Response was empty, 2nd attempt"
|
_info "##KAS## Response was empty, please check manually."
|
||||||
_sleep $KAS_default_ratelimit
|
return 1
|
||||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
elif _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||||
_debug2 "##KAS## retry response" "$response"
|
faultstring="$(echo "$response" | tr -d '\n\r' | sed "s/<faultstring>/\n=> /g" | sed "s/<\/faultstring>/\n/g" | grep "=>" | sed "s/=> //g")"
|
||||||
fi
|
_err "##KAS## Either no domains were found or another error =>$faultstring<= occurred, please check manually."
|
||||||
if _contains "$response" "<SOAP-ENV:Fault>"; then
|
|
||||||
_err "##KAS## Either no domains were found or another error occurred, please check manually."
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_zonen="$(echo "$response" | tr -d '\n\r' | sed "s/<item xsi:type=\"ns2:Map\">/\n/g" | sed "s/<item><key xsi:type=\"xsd:string\">domain_name<\/key><value xsi:type=\"xsd:string\">/=> /g" | sed "s/<\/value><\/item>/\n/g" | grep "=>"| sed "s/=> //g")"
|
_zonen="$(echo "$response" | tr -d '\n\r' | sed "s/<item xsi:type=\"ns2:Map\">/\n/g" | sed "s/<item><key xsi:type=\"xsd:string\">domain_name<\/key><value xsi:type=\"xsd:string\">/=> /g" | sed "s/<\/value><\/item>/\n/g" | grep "=>"| sed "s/=> //g")"
|
||||||
_domain="$1"
|
_domain="$1"
|
||||||
_temp_domain="$(echo "$1" | sed 's/\.$//')"
|
_temp_domain="$(echo "$1" | sed 's/\.$//')"
|
||||||
@ -203,34 +167,48 @@ _get_zone_and_record_name() {
|
|||||||
|
|
||||||
# Retrieve the DNS record ID
|
# Retrieve the DNS record ID
|
||||||
_get_record_id() {
|
_get_record_id() {
|
||||||
|
_info "##KAS## Get domain info"
|
||||||
|
|
||||||
|
params_request="\"zone_host\":\"$_zone\""
|
||||||
|
|
||||||
|
response="$(_post_soap "get_dns_settings" "$params_request")"
|
||||||
|
|
||||||
|
if [ -z "$response" ]; then
|
||||||
|
_info "##KAS## Response was empty, please check manually."
|
||||||
|
return 1
|
||||||
|
elif _contains "$response" "<SOAP-ENV:Fault>"; then
|
||||||
|
faultstring="$(echo "$response" | tr -d '\n\r' | sed "s/<faultstring>/\n=> /g" | sed "s/<\/faultstring>/\n/g" | grep "=>" | sed "s/=> //g")"
|
||||||
|
_err "##KAS## Either no domains were found or another error =>$faultstring<= occurred, please check manually."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_record_id="$(echo "$response" | tr -d '\n\r' | sed "s/<item xsi:type=\"ns2:Map\">/\n/g" | grep -i "$_record_name" | grep -i ">TXT<" | sed "s/<item><key xsi:type=\"xsd:string\">record_id<\/key><value xsi:type=\"xsd:string\">/=>/g" | sed "s/<\/value><\/item>/\n/g" | grep "=>" | sed "s/=>//g")"
|
||||||
|
_debug2 _record_id "$_record_id"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
_post_soap() {
|
||||||
|
KAS_Action=$1
|
||||||
|
KAS_Params=$2
|
||||||
|
|
||||||
export _H1="SOAPAction: \"urn:xmethodsKasApi#KasApi\""
|
export _H1="SOAPAction: \"urn:xmethodsKasApi#KasApi\""
|
||||||
|
|
||||||
params_auth="\"kas_login\":\"$KAS_Login\""
|
params_auth="\"kas_login\":\"$KAS_Login\""
|
||||||
params_auth="$params_auth,\"kas_auth_type\":\"$KAS_Authtype\""
|
params_auth="$params_auth,\"kas_auth_type\":\"$KAS_Authtype\""
|
||||||
params_auth="$params_auth,\"kas_auth_data\":\"$KAS_Authdata\""
|
params_auth="$params_auth,\"kas_auth_data\":\"$KAS_Authdata\""
|
||||||
|
|
||||||
params_request="\"zone_host\":\"$_zone\""
|
data='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethodsKasApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:KasApi><Params xsi:type="xsd:string">{'
|
||||||
|
data="$data$params_auth,\"kas_action\":\"$KAS_Action\""
|
||||||
params='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethodsKasApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:KasApi><Params xsi:type="xsd:string">{'
|
if [ -n "$KAS_Params" ]; then
|
||||||
params="$params$params_auth,\"kas_action\":\"get_dns_settings\""
|
data="$data,\"KasRequestParams\":{$KAS_Params}"
|
||||||
params="$params,\"KasRequestParams\":{$params_request}"
|
fi
|
||||||
params="$params}</Params></ns1:KasApi></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
data="$data}</Params></ns1:KasApi></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
||||||
|
|
||||||
_debug2 "##KAS## Wait for $KAS_default_ratelimit seconds by default before calling KAS API."
|
_debug2 "##KAS## Wait for $KAS_default_ratelimit seconds by default before calling KAS API."
|
||||||
_sleep $KAS_default_ratelimit
|
_sleep $KAS_default_ratelimit
|
||||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
|
||||||
|
response="$(_post "$data" "$KAS_Api" "" "POST" "text/xml")"
|
||||||
_debug2 "##KAS## response" "$response"
|
_debug2 "##KAS## response" "$response"
|
||||||
if [ -z "$response" ]; then
|
|
||||||
_info "##KAS## Response was empty, 2nd attempt"
|
echo "$response"
|
||||||
_sleep $KAS_default_ratelimit
|
|
||||||
response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")"
|
|
||||||
_debug2 "##KAS## retry response" "$response"
|
|
||||||
fi
|
|
||||||
if _contains "$response" "<SOAP-ENV:Fault>"; then
|
|
||||||
_err "##KAS## Either no zones were found or another error occurred, please check manually."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_record_id="$(echo "$response" | tr -d '\n\r' | sed "s/<item xsi:type=\"ns2:Map\">/\n/g" | grep -i "$_record_name" | grep -i ">TXT<" | sed "s/<item><key xsi:type=\"xsd:string\">record_id<\/key><value xsi:type=\"xsd:string\">/=>/g" | sed "s/<\/value><\/item>/\n/g" | grep "=>" | sed "s/=>//g")"
|
|
||||||
_debug2 _record_id "$_record_id"
|
|
||||||
return 0
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user