Skip to content

Commit 7a9ffb5

Browse files
author
serverco
authored
Merge pull request #274 from lolo32/master
Adding support for OVH managed DNS
2 parents 806921c + a9c1ee3 commit 7a9ffb5

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

dns_scripts/dns_add_ovh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
domains=($(echo "$1"|sed -e 's/^\(\([a-zA-Z0-9.-]*\?\)\.\)*\([a-zA-Z0-9-]\+\.[a-zA-Z-]\+\)$/"\1" _acme-challenge.\2 \3/g'))
4+
challenge="$2"
5+
6+
# Please, do not forget to ask for your credentials at https://eu.api.ovh.com/createToken/
7+
# permissions needed are /domain/zone/* in GET,POST,DELETE
8+
applicationKey="YourAK"
9+
applicationSecret="YourAS"
10+
consumerKey="YourCK"
11+
12+
topDomain=${domains[2]}
13+
subDomain=${domains[1]%%.}
14+
15+
function send
16+
{
17+
method=$1
18+
url=$2
19+
body=$3
20+
ts=$(date +%s)
21+
22+
sign=\$1\$$(echo -n "${applicationSecret}+${consumerKey}+${method}+https://eu.api.ovh.com/1.0${url}+${body}+${ts}"|sha1sum|cut -d" " -f1)
23+
curl -X ${method} -H "Content-Type: application/json" -H "X-Ovh-Application: ${applicationKey}" -H "X-Ovh-Timestamp: ${ts}" -H "X-Ovh-Signature: ${sign}" -H "X-Ovh-Consumer: ${consumerKey}" -d "${body}" https://eu.api.ovh.com/1.0${url}
24+
}
25+
26+
# Creation request
27+
send POST /domain/zone/${topDomain}/record "{\"fieldType\":\"TXT\",\"subDomain\":\"$subDomain\",\"ttl\":60,\"target\":\"$challenge\"}"
28+
29+
# Refresh request
30+
send POST /domain/zone/${topDomain}/refresh ""
31+
32+
# Pause for 10 seconds, for DNS propagation
33+
sleep 10

dns_scripts/dns_del_ovh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
domains=($(echo "$1"|sed -e 's/^\(\([a-zA-Z0-9.-]*\?\)\.\)*\([a-zA-Z0-9-]\+\.[a-zA-Z-]\+\)$/"\1" _acme-challenge.\2 \3/g'))
4+
challenge="$2"
5+
6+
# Please, do not forget to ask for your credentials at https://eu.api.ovh.com/createToken/
7+
# permissions needed are /domain/zone/* in GET,POST,DELETE
8+
applicationKey="YourAK"
9+
applicationSecret="YourAS"
10+
consumerKey="YourCK"
11+
12+
topDomain=${domains[2]}
13+
subDomain=${domains[1]%%.}
14+
15+
function send
16+
{
17+
method=$1
18+
url=$2
19+
body=$3
20+
ts=$(date +%s)
21+
22+
sign=\$1\$$(echo -n "${applicationSecret}+${consumerKey}+${method}+https://eu.api.ovh.com/1.0${url}+${body}+${ts}"|sha1sum|cut -d" " -f1)
23+
curl -X ${method} -H "Content-Type: application/json" -H "X-Ovh-Application: ${applicationKey}" -H "X-Ovh-Timestamp: ${ts}" -H "X-Ovh-Signature: ${sign}" -H "X-Ovh-Consumer: ${consumerKey}" -d "${body}" https://eu.api.ovh.com/1.0${url}
24+
}
25+
26+
# Creation request
27+
oldResult=$(send GET "/domain/zone/${topDomain}/record?fieldType=TXT&subDomain=${subDomain}" ""|sed -e 's/\[//' -e 's/\]//')
28+
29+
for num in ${oldResult//,/ }
30+
do
31+
send DELETE "/domain/zone/${topDomain}/record/${num}" ""
32+
done
33+
34+
# Refresh request
35+
send POST /domain/zone/${topDomain}/refresh ""

0 commit comments

Comments
 (0)