3 # dns api wrapper of lexicon for acme.sh
5 # https://github.com/AnalogJ/lexicon
8 wiki
="https://github.com/acmesh-official/acme.sh/wiki/How-to-use-lexicon-dns-api"
11 if ! _exists
"$lexicon_cmd"; then
12 _err
"Please install $lexicon_cmd first: $wiki"
16 PROVIDER
="${PROVIDER:-$(_readdomainconf PROVIDER)}"
17 if [ -z "$PROVIDER" ]; then
19 _err
"Please define env PROVIDER first: $wiki"
23 _savedomainconf PROVIDER
"$PROVIDER"
26 # e.g. busybox-ash does not know [:upper:]
27 # shellcheck disable=SC2018,SC2019
28 Lx_name
=$
(echo LEXICON_
"${PROVIDER}"_USERNAME |
tr 'a-z' 'A-Z')
29 eval "$Lx_name=\${$Lx_name:-$(_readaccountconf_mutable "$Lx_name")}"
30 Lx_name_v
=$
(eval echo \$
"$Lx_name")
31 _secure_debug
"$Lx_name" "$Lx_name_v"
32 if [ "$Lx_name_v" ]; then
33 _saveaccountconf_mutable
"$Lx_name" "$Lx_name_v"
34 eval export "$Lx_name"
37 # shellcheck disable=SC2018,SC2019
38 Lx_token
=$
(echo LEXICON_
"${PROVIDER}"_TOKEN |
tr 'a-z' 'A-Z')
39 eval "$Lx_token=\${$Lx_token:-$(_readaccountconf_mutable "$Lx_token")}"
40 Lx_token_v
=$
(eval echo \$
"$Lx_token")
41 _secure_debug
"$Lx_token" "$Lx_token_v"
42 if [ "$Lx_token_v" ]; then
43 _saveaccountconf_mutable
"$Lx_token" "$Lx_token_v"
44 eval export "$Lx_token"
47 # shellcheck disable=SC2018,SC2019
48 Lx_password
=$
(echo LEXICON_
"${PROVIDER}"_PASSWORD |
tr 'a-z' 'A-Z')
49 eval "$Lx_password=\${$Lx_password:-$(_readaccountconf_mutable "$Lx_password")}"
50 Lx_password_v
=$
(eval echo \$
"$Lx_password")
51 _secure_debug
"$Lx_password" "$Lx_password_v"
52 if [ "$Lx_password_v" ]; then
53 _saveaccountconf_mutable
"$Lx_password" "$Lx_password_v"
54 eval export "$Lx_password"
57 # shellcheck disable=SC2018,SC2019
58 Lx_domaintoken
=$
(echo LEXICON_
"${PROVIDER}"_DOMAINTOKEN |
tr 'a-z' 'A-Z')
59 eval "$Lx_domaintoken=\${$Lx_domaintoken:-$(_readaccountconf_mutable "$Lx_domaintoken")}"
60 Lx_domaintoken_v
=$
(eval echo \$
"$Lx_domaintoken")
61 _secure_debug
"$Lx_domaintoken" "$Lx_domaintoken_v"
62 if [ "$Lx_domaintoken_v" ]; then
63 _saveaccountconf_mutable
"$Lx_domaintoken" "$Lx_domaintoken_v"
64 eval export "$Lx_domaintoken"
67 # shellcheck disable=SC2018,SC2019
68 Lx_api_key
=$
(echo LEXICON_
"${PROVIDER}"_API_KEY |
tr 'a-z' 'A-Z')
69 eval "$Lx_api_key=\${$Lx_api_key:-$(_readaccountconf_mutable "$Lx_api_key")}"
70 Lx_api_key_v
=$
(eval echo \$
"$Lx_api_key")
71 _secure_debug
"$Lx_api_key" "$Lx_api_key_v"
72 if [ "$Lx_api_key_v" ]; then
73 _saveaccountconf_mutable
"$Lx_api_key" "$Lx_api_key_v"
74 eval export "$Lx_api_key"
78 ######## Public functions #####################
80 #Usage: dns_lexicon_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
85 if ! _lexicon_init
; then
89 domain
=$
(printf "%s" "$fulldomain" | cut
-d .
-f 2-999)
91 _secure_debug LEXICON_OPTS
"$LEXICON_OPTS"
92 _savedomainconf LEXICON_OPTS
"$LEXICON_OPTS"
94 # shellcheck disable=SC2086
95 $lexicon_cmd "$PROVIDER" $LEXICON_OPTS create
"${domain}" TXT --name="_acme-challenge.${domain}." --content="${txtvalue}"
99 #Usage: dns_lexicon_rm _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
104 if ! _lexicon_init
; then
108 domain
=$
(printf "%s" "$fulldomain" | cut
-d .
-f 2-999)
110 # shellcheck disable=SC2086
111 $lexicon_cmd "$PROVIDER" $LEXICON_OPTS delete
"${domain}" TXT --name="_acme-challenge.${domain}." --content="${txtvalue}"