]> git.proxmox.com Git - mirror_acme.sh.git/blob - dnsapi/dns_lexicon.sh
secure debug message
[mirror_acme.sh.git] / dnsapi / dns_lexicon.sh
1 #!/usr/bin/env sh
2
3 # dns api wrapper of lexicon for acme.sh
4
5 # https://github.com/AnalogJ/lexicon
6 lexicon_cmd="lexicon"
7
8 wiki="https://github.com/Neilpang/acme.sh/wiki/How-to-use-lexicon-dns-api"
9
10 ######## Public functions #####################
11
12 #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
13 dns_lexicon_add() {
14 fulldomain=$1
15 txtvalue=$2
16
17 domain=$(printf "%s" "$fulldomain" | cut -d . -f 2-999)
18
19 if ! _exists "$lexicon_cmd"; then
20 _err "Please install $lexicon_cmd first: $wiki"
21 return 1
22 fi
23
24 if [ -z "$PROVIDER" ]; then
25 PROVIDER=""
26 _err "Please define env PROVIDER first: $wiki"
27 return 1
28 fi
29
30 _savedomainconf PROVIDER "$PROVIDER"
31 export PROVIDER
32
33 # e.g. busybox-ash does not know [:upper:]
34 # shellcheck disable=SC2018,SC2019
35 Lx_name=$(echo LEXICON_"${PROVIDER}"_USERNAME | tr 'a-z' 'A-Z')
36 Lx_name_v=$(eval echo \$"$Lx_name")
37 _secure_debug "$Lx_name" "$Lx_name_v"
38 if [ "$Lx_name_v" ]; then
39 _saveaccountconf "$Lx_name" "$Lx_name_v"
40 eval export "$Lx_name"
41 fi
42
43 # shellcheck disable=SC2018,SC2019
44 Lx_token=$(echo LEXICON_"${PROVIDER}"_TOKEN | tr 'a-z' 'A-Z')
45 Lx_token_v=$(eval echo \$"$Lx_token")
46 _secure_debug "$Lx_token" "$Lx_token_v"
47 if [ "$Lx_token_v" ]; then
48 _saveaccountconf "$Lx_token" "$Lx_token_v"
49 eval export "$Lx_token"
50 fi
51
52 # shellcheck disable=SC2018,SC2019
53 Lx_password=$(echo LEXICON_"${PROVIDER}"_PASSWORD | tr 'a-z' 'A-Z')
54 Lx_password_v=$(eval echo \$"$Lx_password")
55 _secure_debug "$Lx_password" "$Lx_password_v"
56 if [ "$Lx_password_v" ]; then
57 _saveaccountconf "$Lx_password" "$Lx_password_v"
58 eval export "$Lx_password"
59 fi
60
61 # shellcheck disable=SC2018,SC2019
62 Lx_domaintoken=$(echo LEXICON_"${PROVIDER}"_DOMAINTOKEN | tr 'a-z' 'A-Z')
63 Lx_domaintoken_v=$(eval echo \$"$Lx_domaintoken")
64 _secure_debug "$Lx_domaintoken" "$Lx_domaintoken_v"
65 if [ "$Lx_domaintoken_v" ]; then
66 eval export "$Lx_domaintoken"
67 _saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v"
68 fi
69
70 $lexicon_cmd "$PROVIDER" create "${domain}" TXT --name="_acme-challenge.${domain}." --content="${txtvalue}"
71
72 }
73
74 #fulldomain
75 dns_lexicon_rm() {
76 fulldomain=$1
77
78 }