]> git.proxmox.com Git - mirror_acme.sh.git/blame - dnsapi/dns_nanelo.sh
Merge pull request #4542 from alexleigh/master
[mirror_acme.sh.git] / dnsapi / dns_nanelo.sh
CommitLineData
c0639c66
AAR
1#!/usr/bin/env sh
2
3# Official DNS API for Nanelo.com
4
5# Provide the required API Key like this:
6# NANELO_TOKEN="FmD408PdqT1E269gUK57"
7
8NANELO_API="https://api.nanelo.com/v1/"
9
10######## Public functions #####################
11
d3fefd22 12# Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
c0639c66
AAR
13dns_nanelo_add() {
14 fulldomain=$1
15 txtvalue=$2
16
17 NANELO_TOKEN="${NANELO_TOKEN:-$(_readaccountconf_mutable NANELO_TOKEN)}"
18 if [ -z "$NANELO_TOKEN" ]; then
19 NANELO_TOKEN=""
20 _err "You didn't configure a Nanelo API Key yet."
21 _err "Please set NANELO_TOKEN and try again."
22 _err "Login to Nanelo.com and go to Settings > API Keys to get a Key"
23 return 1
24 fi
25 _saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
26
27 _info "Adding TXT record to ${fulldomain}"
06e12a30 28 response="$(_get "$NANELO_API$NANELO_TOKEN/dns/addrecord?type=TXT&ttl=60&name=${fulldomain}&value=${txtvalue}")"
c0639c66
AAR
29 if _contains "${response}" 'success'; then
30 return 0
31 fi
d3fefd22 32 _err "Could not create resource record, please check the logs"
c0639c66
AAR
33 _err "${response}"
34 return 1
35}
36
37dns_nanelo_rm() {
38 fulldomain=$1
39 txtvalue=$2
40
41 NANELO_TOKEN="${NANELO_TOKEN:-$(_readaccountconf_mutable NANELO_TOKEN)}"
42 if [ -z "$NANELO_TOKEN" ]; then
43 NANELO_TOKEN=""
44 _err "You didn't configure a Nanelo API Key yet."
45 _err "Please set NANELO_TOKEN and try again."
46 _err "Login to Nanelo.com and go to Settings > API Keys to get a Key"
47 return 1
48 fi
49 _saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
50
51 _info "Deleting resource record $fulldomain"
06e12a30 52 response="$(_get "$NANELO_API$NANELO_TOKEN/dns/deleterecord?type=TXT&ttl=60&name=${fulldomain}&value=${txtvalue}")"
c0639c66
AAR
53 if _contains "${response}" 'success'; then
54 return 0
55 fi
d3fefd22 56 _err "Could not delete resource record, please check the logs"
c0639c66
AAR
57 _err "${response}"
58 return 1
59}