mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-22 13:11:41 +00:00
support dns_ovh_rm()
This commit is contained in:
parent
ea25492c28
commit
be186bd39b
@ -78,13 +78,8 @@ _ovh_get_api() {
|
||||
esac
|
||||
}
|
||||
|
||||
######## Public functions #####################
|
||||
|
||||
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
||||
dns_ovh_add() {
|
||||
fulldomain=$1
|
||||
txtvalue=$2
|
||||
|
||||
_initAuth() {
|
||||
if [ -z "$OVH_AK" ] || [ -z "$OVH_AS" ]; then
|
||||
OVH_AK=""
|
||||
OVH_AS=""
|
||||
@ -127,6 +122,19 @@ dns_ovh_add() {
|
||||
return 1
|
||||
fi
|
||||
_info "Consumer key is ok."
|
||||
return 0
|
||||
}
|
||||
|
||||
######## Public functions #####################
|
||||
|
||||
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
||||
dns_ovh_add() {
|
||||
fulldomain=$1
|
||||
txtvalue=$2
|
||||
|
||||
if ! _initAuth; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _get_root "$fulldomain"; then
|
||||
@ -156,9 +164,39 @@ dns_ovh_add() {
|
||||
dns_ovh_rm() {
|
||||
fulldomain=$1
|
||||
txtvalue=$2
|
||||
_debug "Getting txt records"
|
||||
#_ovh_rest GET "domain/zone/$_domain/record?fieldType=TXT&subDomain=$_sub_domain"
|
||||
|
||||
if ! _initAuth; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _get_root "$fulldomain"; then
|
||||
_err "invalid domain"
|
||||
return 1
|
||||
fi
|
||||
|
||||
_debug _sub_domain "$_sub_domain"
|
||||
_debug _domain "$_domain"
|
||||
_debug "Getting txt records"
|
||||
if ! _ovh_rest GET "domain/zone/$_domain/record?fieldType=TXT&subDomain=$_sub_domain"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
for rid in $(echo "$response" | tr '[,]' ' '); do
|
||||
_debug rid "$rid"
|
||||
if ! _ovh_rest GET "domain/zone/$_domain/record/$rid"; then
|
||||
return 1
|
||||
fi
|
||||
if _contains "$response" "\"target\":\"$txtvalue\""; then
|
||||
_debug "Found txt id:$rid"
|
||||
if ! _ovh_rest DELETE "domain/zone/$_domain/record/$rid"; then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#################### Private functions below ##################################
|
||||
@ -170,7 +208,7 @@ _ovh_authentication() {
|
||||
_H3=""
|
||||
_H4=""
|
||||
|
||||
_ovhdata='{"accessRules": [{"method": "GET","path": "/auth/time"},{"method": "GET","path": "/domain"},{"method": "GET","path": "/domain/zone/*"},{"method": "GET","path": "/domain/zone/*/record"},{"method": "POST","path": "/domain/zone/*/record"},{"method": "POST","path": "/domain/zone/*/refresh"},{"method": "PUT","path": "/domain/zone/*/record/*"}],"redirection":"'$ovh_success'"}'
|
||||
_ovhdata='{"accessRules": [{"method": "GET","path": "/auth/time"},{"method": "GET","path": "/domain"},{"method": "GET","path": "/domain/zone/*"},{"method": "GET","path": "/domain/zone/*/record"},{"method": "POST","path": "/domain/zone/*/record"},{"method": "POST","path": "/domain/zone/*/refresh"},{"method": "PUT","path": "/domain/zone/*/record/*"},{"method": "DELETE","path": "/domain/zone/*/record/*"}],"redirection":"'$ovh_success'"}'
|
||||
|
||||
response="$(_post "$_ovhdata" "$OVH_API/auth/credential")"
|
||||
_debug3 response "$response"
|
||||
@ -258,7 +296,7 @@ _ovh_rest() {
|
||||
export _H3="X-Ovh-Timestamp: $_ovh_t"
|
||||
export _H4="X-Ovh-Consumer: $OVH_CK"
|
||||
export _H5="Content-Type: application/json;charset=utf-8"
|
||||
if [ "$data" ] || [ "$m" = "POST" ] || [ "$m" = "PUT" ]; then
|
||||
if [ "$data" ] || [ "$m" = "POST" ] || [ "$m" = "PUT" ] || [ "$m" = "DELETE" ]; then
|
||||
_debug data "$data"
|
||||
response="$(_post "$data" "$_ovh_url" "" "$m")"
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user