|
|
@ -30,8 +30,7 @@ |
|
|
|
## |
|
|
|
## The `pleskxml_uri`, `pleskxml_user` and `pleskxml_pass` will be saved in `~/.acme.sh/account.conf` and reused when needed. |
|
|
|
|
|
|
|
|
|
|
|
#################### INTERNAL VARIABLES + NEWLINE ################################## |
|
|
|
#################### INTERNAL VARIABLES + NEWLINE + API TEMPLATES ################################## |
|
|
|
|
|
|
|
pleskxml_init_checks_done=0 |
|
|
|
|
|
|
@ -40,9 +39,6 @@ pleskxml_init_checks_done=0 |
|
|
|
NEWLINE='\ |
|
|
|
' |
|
|
|
|
|
|
|
|
|
|
|
#################### API Templates ################################## |
|
|
|
|
|
|
|
pleskxml_tplt_get_domains="<packet><customer><get-domain-list><filter/></get-domain-list></customer></packet>" |
|
|
|
# Get a list of domains that PLESK can manage, so we can check root domain + host for acme.sh |
|
|
|
# Also used to test credentials and URI. |
|
|
@ -60,7 +56,6 @@ pleskxml_tplt_rmv_dns_record="<packet><dns><del_rec><filter><id>%s</id></filter> |
|
|
|
# Add a TXT record to a domain. |
|
|
|
# ARG = the Plesk internal ID for the dns record to be deleted |
|
|
|
|
|
|
|
|
|
|
|
#################### Public functions ################################## |
|
|
|
|
|
|
|
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" |
|
|
@ -141,7 +136,7 @@ dns_pleskxml_rm() { |
|
|
|
reclist="$(_api_response_split "$pleskxml_prettyprint_result" 'result' '<status>ok</status>' \ |
|
|
|
| grep "<site-id>${root_domain_id}</site-id>" \ |
|
|
|
| grep -E '<id>[0-9]+</id>' \ |
|
|
|
| grep '<type>TXT</type>' \ |
|
|
|
| grep '<type>TXT</type>' |
|
|
|
)" |
|
|
|
|
|
|
|
if [ -z "$reclist" ]; then |
|
|
@ -154,7 +149,7 @@ dns_pleskxml_rm() { |
|
|
|
recid="$(_value "$reclist" \ |
|
|
|
| grep "<host>$1.</host>" \ |
|
|
|
| grep "<value>$txtvalue</value>" \ |
|
|
|
| sed -E 's/(^.*<id>|<\/id>.*$)//g' \ |
|
|
|
| sed -E 's/(^.*<id>|<\/id>.*$)//g' |
|
|
|
)" |
|
|
|
|
|
|
|
_debug "List of DNS TXT records for host:"'\n'"$(_value "$reclist" | grep "<host>$1.</host>")" |
|
|
@ -193,8 +188,6 @@ dns_pleskxml_rm() { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#################### Private functions below ################################## |
|
|
|
|
|
|
|
# Outputs value of a variable |
|
|
@ -202,7 +195,6 @@ _value() { |
|
|
|
printf '%s' "$1" |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Outputs value of a variable (FQDN) and cuts it at 2 delimiters |
|
|
|
# $1, $2 = where to cut |
|
|
|
# $3 = FQDN |
|
|
@ -210,7 +202,6 @@ _valuecut() { |
|
|
|
printf '%s' "$3" | cut -d . -f "${1}-${2}" |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Cleans up an API response, splits it "per item" and greps for a string to validate useful lines |
|
|
|
# $1 - result string from API |
|
|
|
# $2 - tag to resplit on (usually "result" or "domain") |
|
|
@ -223,7 +214,6 @@ _api_response_split() { |
|
|
|
| grep -E "$3" |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Calls Plesk XML API, and checks results for obvious issues |
|
|
|
_call_api() { |
|
|
|
request="$1" |
|
|
@ -249,10 +239,10 @@ _call_api() { |
|
|
|
if _value "$statuslines" | grep -qv '<status>ok</status>'; then |
|
|
|
|
|
|
|
# We have some status lines that aren't "ok". Get the details |
|
|
|
errtext="$( _value "$pleskxml_prettyprint_result" \ |
|
|
|
errtext="$(_value "$pleskxml_prettyprint_result" \ |
|
|
|
| grep -iE "(<status>|<errcode>|<errtext>)" \ |
|
|
|
| sed -E 's/(^[[:space:]]+|<\/[a-z]+$)//g' \ |
|
|
|
| sed -E 's/^<([a-z]+)>/\1: /' \ |
|
|
|
| sed -E 's/^<([a-z]+)>/\1: /' |
|
|
|
)" |
|
|
|
|
|
|
|
elif ! _value "$statuslines" | grep -q '<status>ok</status>'; then |
|
|
@ -278,10 +268,8 @@ _call_api() { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Startup checks (credentials, URI) |
|
|
|
_credential_check() { |
|
|
|
# Startup checks (credentials, URI) |
|
|
|
|
|
|
|
_debug "Checking Plesk XML API login credentials and URI..." |
|
|
|
|
|
|
|
if [ "$pleskxml_init_checks_done" -eq 1 ]; then |
|
|
@ -289,7 +277,6 @@ _credential_check() { |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
pleskxml_user="${pleskxml_user:-$(_readaccountconf_mutable pleskxml_user)}" |
|
|
|
pleskxml_pass="${pleskxml_pass:-$(_readaccountconf_mutable pleskxml_pass)}" |
|
|
|
pleskxml_uri="${pleskxml_uri:-$(_readaccountconf_mutable pleskxml_uri)}" |
|
|
@ -325,7 +312,6 @@ _credential_check() { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# For a FQDN, identify the root domain managed by Plesk, its domain ID in Plesk, and the host if any. |
|
|
|
|
|
|
|
# IMPORTANT NOTE: a result with host = empty string is OK for this API, see |
|
|
|