Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
6d5e7826
Commit
6d5e7826
authored
Jan 09, 2018
by
neilpang
Browse files
support dns_ovh_rm()
parent
c99d4948
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_ovh.sh
View file @
6d5e7826
...
...
@@ -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
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"
#_ovh_rest GET "domain/zone/$_domain/record?fieldType=TXT&subDomain=$_sub_domain"
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment