]> git.proxmox.com Git - mirror_acme.sh.git/blame - dnsapi/dns_dnshome.sh
Merge pull request #4542 from alexleigh/master
[mirror_acme.sh.git] / dnsapi / dns_dnshome.sh
CommitLineData
4346139d
B
1#!/usr/bin/env sh
2
3# dnsHome.de API for acme.sh
4#
5# This Script adds the necessary TXT record to a Subdomain
6#
7# Author dnsHome.de (https://github.com/dnsHome-de)
8#
9# Report Bugs to https://github.com/acmesh-official/acme.sh/issues/3819
10#
11# export DNSHOME_Subdomain=""
12# export DNSHOME_SubdomainPassword=""
13
14# Usage: add subdomain.ddnsdomain.tld "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
15# Used to add txt record
16dns_dnshome_add() {
17 txtvalue=$2
18
19 DNSHOME_Subdomain="${DNSHOME_Subdomain:-$(_readdomainconf DNSHOME_Subdomain)}"
20 DNSHOME_SubdomainPassword="${DNSHOME_SubdomainPassword:-$(_readdomainconf DNSHOME_SubdomainPassword)}"
21
22 if [ -z "$DNSHOME_Subdomain" ] || [ -z "$DNSHOME_SubdomainPassword" ]; then
23 DNSHOME_Subdomain=""
24 DNSHOME_SubdomainPassword=""
25 _err "Please specify/export your dnsHome.de Subdomain and Password"
26 return 1
27 fi
28
29 #save the credentials to the account conf file.
30 _savedomainconf DNSHOME_Subdomain "$DNSHOME_Subdomain"
31 _savedomainconf DNSHOME_SubdomainPassword "$DNSHOME_SubdomainPassword"
32
33 DNSHOME_Api="https://$DNSHOME_Subdomain:$DNSHOME_SubdomainPassword@www.dnshome.de/dyndns.php"
34
35 _DNSHOME_rest POST "acme=add&txt=$txtvalue"
36 if ! echo "$response" | grep 'successfully' >/dev/null; then
37 _err "Error"
38 _err "$response"
39 return 1
40 fi
41
42 return 0
43}
44
45# Usage: txtvalue
46# Used to remove the txt record after validation
47dns_dnshome_rm() {
48 txtvalue=$2
49
50 DNSHOME_Subdomain="${DNSHOME_Subdomain:-$(_readdomainconf DNSHOME_Subdomain)}"
51 DNSHOME_SubdomainPassword="${DNSHOME_SubdomainPassword:-$(_readdomainconf DNSHOME_SubdomainPassword)}"
52
53 DNSHOME_Api="https://$DNSHOME_Subdomain:$DNSHOME_SubdomainPassword@www.dnshome.de/dyndns.php"
54
55 if [ -z "$DNSHOME_Subdomain" ] || [ -z "$DNSHOME_SubdomainPassword" ]; then
56 DNSHOME_Subdomain=""
57 DNSHOME_SubdomainPassword=""
58 _err "Please specify/export your dnsHome.de Subdomain and Password"
59 return 1
60 fi
61
62 _DNSHOME_rest POST "acme=rm&txt=$txtvalue"
63 if ! echo "$response" | grep 'successfully' >/dev/null; then
64 _err "Error"
65 _err "$response"
66 return 1
67 fi
68
69 return 0
70}
71
72#################### Private functions below ##################################
73_DNSHOME_rest() {
74 method=$1
75 data="$2"
76 _debug "$data"
77
78 _debug data "$data"
79 response="$(_post "$data" "$DNSHOME_Api" "" "$method")"
80
81 if [ "$?" != "0" ]; then
82 _err "error $data"
83 return 1
84 fi
85 _debug2 response "$response"
86 return 0
87}