mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-22 05:01:40 +00:00
Update dns_openprovider.sh
#2104 Fix wildcard handling & custom NS config for OpenProvider DNS
This commit is contained in:
parent
65c59c8c30
commit
3ff48b8559
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/bash
|
||||||
|
|
||||||
# This is the OpenProvider API wrapper for acme.sh
|
# This is the OpenProvider API wrapper for acme.sh
|
||||||
#
|
#
|
||||||
@ -59,16 +59,17 @@ dns_openprovider_add() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
items="$(echo "$items" | sed "s|${item}||")"
|
tmpitem="$(echo "$item" | sed 's/\*/\\*/g')"
|
||||||
|
items="$(echo "$items" | sed "s|${tmpitem}||")"
|
||||||
|
|
||||||
results_retrieved="$(_math "$results_retrieved" + 1)"
|
results_retrieved="$(_math "$results_retrieved" + 1)"
|
||||||
new_item="$(echo "$item" | sed -n 's/.*<item>.*\(<name>\(.*\)\.'"$_domain_name"'\.'"$_domain_extension"'<\/name>.*\(<type>.*<\/type>\).*\(<value>.*<\/value>\).*\(<prio>.*<\/prio>\).*\(<ttl>.*<\/ttl>\)\).*<\/item>.*/<item><name>\2<\/name>\3\4\5\6<\/item>/p')"
|
new_item="$(echo "$item" | sed -n 's/.*<item>.*\(<name>\(.*\)\.'"$_domain_name"'\.'"$_domain_extension"'<\/name>.*\(<type>.*<\/type>\).*\(<value>.*<\/value>\).*\(<prio>.*<\/prio>\).*\(<ttl>.*<\/ttl>\)\).*<\/item>.*/<item><name>\2<\/name>\3\4\5\6<\/item>/p')"
|
||||||
if [ -z "$new_item" ]; then
|
if [ -z "$new_item" ]; then
|
||||||
# Base record
|
# Domain apex
|
||||||
new_item="$(echo "$item" | sed -n 's/.*<item>.*\(<name>\(.*\)'"$_domain_name"'\.'"$_domain_extension"'<\/name>.*\(<type>.*<\/type>\).*\(<value>.*<\/value>\).*\(<prio>.*<\/prio>\).*\(<ttl>.*<\/ttl>\)\).*<\/item>.*/<item><name>\2<\/name>\3\4\5\6<\/item>/p')"
|
new_item="$(echo "$item" | sed -n 's/.*<item>.*\(<name>\(.*\)'"$_domain_name"'\.'"$_domain_extension"'<\/name>.*\(<type>.*<\/type>\).*\(<value>.*<\/value>\).*\(<prio>.*<\/prio>\).*\(<ttl>.*<\/ttl>\)\).*<\/item>.*/<item><name>\2<\/name>\3\4\5\6<\/item>/p')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$(echo "$new_item" | _egrep_o ".*<type>(A|AAAA|CNAME|MX|SPF|SRV|TXT|TLSA|SSHFP|CAA)<\/type>.*")" ]; then
|
if [ -z "$(echo "$new_item" | _egrep_o ".*<type>(A|AAAA|CNAME|MX|SPF|SRV|TXT|TLSA|SSHFP|CAA|NS)<\/type>.*")" ]; then
|
||||||
_debug "not an allowed record type, skipping" "$new_item"
|
_debug "not an allowed record type, skipping" "$new_item"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -86,7 +87,7 @@ dns_openprovider_add() {
|
|||||||
|
|
||||||
_debug "Creating acme record"
|
_debug "Creating acme record"
|
||||||
acme_record="$(echo "$fulldomain" | sed -e "s/.$_domain_name.$_domain_extension$//")"
|
acme_record="$(echo "$fulldomain" | sed -e "s/.$_domain_name.$_domain_extension$//")"
|
||||||
_openprovider_request "$(printf '<modifyZoneDnsRequest><domain><name>%s</name><extension>%s</extension></domain><type>master</type><records><array>%s<item><name>%s</name><type>TXT</type><value>%s</value><ttl>86400</ttl></item></array></records></modifyZoneDnsRequest>' "$_domain_name" "$_domain_extension" "$existing_items" "$acme_record" "$txtvalue")"
|
_openprovider_request "$(printf '<modifyZoneDnsRequest><domain><name>%s</name><extension>%s</extension></domain><type>master</type><records><array>%s<item><name>%s</name><type>TXT</type><value>%s</value><ttl>600</ttl></item></array></records></modifyZoneDnsRequest>' "$_domain_name" "$_domain_extension" "$existing_items" "$acme_record" "$txtvalue")"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -136,7 +137,8 @@ dns_openprovider_rm() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
items="$(echo "$items" | sed "s|${item}||")"
|
tmpitem="$(echo "$item" | sed 's/\*/\\*/g')"
|
||||||
|
items="$(echo "$items" | sed "s|${tmpitem}||")"
|
||||||
|
|
||||||
results_retrieved="$(_math "$results_retrieved" + 1)"
|
results_retrieved="$(_math "$results_retrieved" + 1)"
|
||||||
if ! echo "$item" | grep -v "$fulldomain"; then
|
if ! echo "$item" | grep -v "$fulldomain"; then
|
||||||
@ -147,11 +149,11 @@ dns_openprovider_rm() {
|
|||||||
new_item="$(echo "$item" | sed -n 's/.*<item>.*\(<name>\(.*\)\.'"$_domain_name"'\.'"$_domain_extension"'<\/name>.*\(<type>.*<\/type>\).*\(<value>.*<\/value>\).*\(<prio>.*<\/prio>\).*\(<ttl>.*<\/ttl>\)\).*<\/item>.*/<item><name>\2<\/name>\3\4\5\6<\/item>/p')"
|
new_item="$(echo "$item" | sed -n 's/.*<item>.*\(<name>\(.*\)\.'"$_domain_name"'\.'"$_domain_extension"'<\/name>.*\(<type>.*<\/type>\).*\(<value>.*<\/value>\).*\(<prio>.*<\/prio>\).*\(<ttl>.*<\/ttl>\)\).*<\/item>.*/<item><name>\2<\/name>\3\4\5\6<\/item>/p')"
|
||||||
|
|
||||||
if [ -z "$new_item" ]; then
|
if [ -z "$new_item" ]; then
|
||||||
# Base record
|
# domain apex
|
||||||
new_item="$(echo "$item" | sed -n 's/.*<item>.*\(<name>\(.*\)'"$_domain_name"'\.'"$_domain_extension"'<\/name>.*\(<type>.*<\/type>\).*\(<value>.*<\/value>\).*\(<prio>.*<\/prio>\).*\(<ttl>.*<\/ttl>\)\).*<\/item>.*/<item><name>\2<\/name>\3\4\5\6<\/item>/p')"
|
new_item="$(echo "$item" | sed -n 's/.*<item>.*\(<name>\(.*\)'"$_domain_name"'\.'"$_domain_extension"'<\/name>.*\(<type>.*<\/type>\).*\(<value>.*<\/value>\).*\(<prio>.*<\/prio>\).*\(<ttl>.*<\/ttl>\)\).*<\/item>.*/<item><name>\2<\/name>\3\4\5\6<\/item>/p')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$(echo "$new_item" | _egrep_o ".*<type>(A|AAAA|CNAME|MX|SPF|SRV|TXT|TLSA|SSHFP|CAA)<\/type>.*")" ]; then
|
if [ -z "$(echo "$new_item" | _egrep_o ".*<type>(A|AAAA|CNAME|MX|SPF|SRV|TXT|TLSA|SSHFP|CAA|NS)<\/type>.*")" ]; then
|
||||||
_debug "not an allowed record type, skipping" "$new_item"
|
_debug "not an allowed record type, skipping" "$new_item"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -205,7 +207,8 @@ _get_root() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
items="$(echo "$items" | sed "s|${item}||")"
|
tmpitem="$(echo "$item" | sed 's/\*/\\*/g')"
|
||||||
|
items="$(echo "$items" | sed "s|${tmpitem}||")"
|
||||||
|
|
||||||
results_retrieved="$(_math "$results_retrieved" + 1)"
|
results_retrieved="$(_math "$results_retrieved" + 1)"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user