]> git.proxmox.com Git - mirror_acme.sh.git/blame - dnsapi/dns_lexicon.sh
dnsapi/dns_dp.sh: shellcheck: fix 1 occurence of SC2126
[mirror_acme.sh.git] / dnsapi / dns_lexicon.sh
CommitLineData
218dc339 1#!/usr/bin/env sh
2
3# dns api wrapper of lexicon for acme.sh
4
5lexicon_url="https://github.com/AnalogJ/lexicon"
6lexicon_cmd="lexicon"
7
8wiki="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"
13dns_lexicon_add() {
14 fulldomain=$1
15 txtvalue=$2
4c2a3841 16
c7b16249 17 domain=$(printf "%s" "$fulldomain" | cut -d . -f 2-999)
4c2a3841 18
c7b16249 19 if ! _exists "$lexicon_cmd"; then
218dc339 20 _err "Please install $lexicon_cmd first: $wiki"
21 return 1
22 fi
4c2a3841 23
24 if [ -z "$PROVIDER" ]; then
422e5026 25 PROVIDER=""
218dc339 26 _err "Please define env PROVIDER first: $wiki"
27 return 1
28 fi
29
30 _savedomainconf PROVIDER "$PROVIDER"
31 export PROVIDER
32
800f02ba
BB
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')
a8c61111 36 Lx_name_v=$(eval echo \$"$Lx_name")
218dc339 37 _debug "$Lx_name" "$Lx_name_v"
4c2a3841 38 if [ "$Lx_name_v" ]; then
c7b16249 39 _saveaccountconf "$Lx_name" "$Lx_name_v"
3de85700 40 eval export "$Lx_name"
218dc339 41 fi
4c2a3841 42
800f02ba
BB
43 # shellcheck disable=SC2018,SC2019
44 Lx_token=$(echo LEXICON_"${PROVIDER}"_TOKEN | tr 'a-z' 'A-Z')
a8c61111 45 Lx_token_v=$(eval echo \$"$Lx_token")
218dc339 46 _debug "$Lx_token" "$Lx_token_v"
4c2a3841 47 if [ "$Lx_token_v" ]; then
c7b16249 48 _saveaccountconf "$Lx_token" "$Lx_token_v"
3de85700 49 eval export "$Lx_token"
218dc339 50 fi
4c2a3841 51
800f02ba
BB
52 # shellcheck disable=SC2018,SC2019
53 Lx_password=$(echo LEXICON_"${PROVIDER}"_PASSWORD | tr 'a-z' 'A-Z')
a8c61111 54 Lx_password_v=$(eval echo \$"$Lx_password")
218dc339 55 _debug "$Lx_password" "$Lx_password_v"
4c2a3841 56 if [ "$Lx_password_v" ]; then
c7b16249 57 _saveaccountconf "$Lx_password" "$Lx_password_v"
3de85700 58 eval export "$Lx_password"
218dc339 59 fi
4c2a3841 60
800f02ba
BB
61 # shellcheck disable=SC2018,SC2019
62 Lx_domaintoken=$(echo LEXICON_"${PROVIDER}"_DOMAINTOKEN | tr 'a-z' 'A-Z')
a8c61111 63 Lx_domaintoken_v=$(eval echo \$"$Lx_domaintoken")
218dc339 64 _debug "$Lx_domaintoken" "$Lx_domaintoken_v"
4c2a3841 65 if [ "$Lx_domaintoken_v" ]; then
3de85700 66 eval export "$Lx_domaintoken"
c7b16249 67 _saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v"
218dc339 68 fi
69
e9f9f515 70 $lexicon_cmd "$PROVIDER" create "${domain}" TXT --name="_acme-challenge.${domain}." --content="${txtvalue}"
218dc339 71
72}
73
5d6fd809 74#fulldomain
75dns_lexicon_rm() {
76 fulldomain=$1
77
78}