mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-11-10 00:11:45 +00:00
Travis fixes
This commit is contained in:
parent
a6614abd24
commit
9299a83b17
@ -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,8 +149,8 @@ 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,20 +202,18 @@ _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")
|
||||
# $3 - regex to recognise useful return lines
|
||||
_api_response_split() {
|
||||
printf '%s' "$1" \
|
||||
| sed -E 's/(^[[:space:]]+|[[:space:]]+$)//g' \
|
||||
| tr -d '\n\r' \
|
||||
| sed -E "s/<\/?$2>/${NEWLINE}/g" \
|
||||
| grep -E "$3"
|
||||
| sed -E 's/(^[[:space:]]+|[[:space:]]+$)//g' \
|
||||
| tr -d '\n\r' \
|
||||
| sed -E "s/<\/?$2>/${NEWLINE}/g" \
|
||||
| grep -E "$3"
|
||||
}
|
||||
|
||||
|
||||
# Calls Plesk XML API, and checks results for obvious issues
|
||||
_call_api() {
|
||||
request="$1"
|
||||
@ -249,11 +239,11 @@ _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
|
||||
@ -369,7 +355,7 @@ _pleskxml_get_root_domain() {
|
||||
|
||||
_debug "Checking if '$root_domain_name' is managed by the Plesk server..."
|
||||
|
||||
root_domain_id="$(_value "$output" | grep "<name>$root_domain_name</name>" | _head_n 1 | sed -E 's/^.*<id>([0-9]+)<\/id>.*$/\1/')"
|
||||
root_domain_id="$(_value "$output" | grep "<name>$root_domain_name</name>" | _head_n 1 | sed -E 's/^.*<id>([0-9]+)<\/id>.*$/\1/')"
|
||||
|
||||
if [ -n "$root_domain_id" ]; then
|
||||
# Found a match
|
||||
|
Loading…
Reference in New Issue
Block a user