Browse Source

Travis fixes

shebang
stilez 5 years ago
committed by GitHub
parent
commit
9299a83b17
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      dnsapi/dns_pleskxml

26
dnsapi/dns_pleskxml

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

Loading…
Cancel
Save