2016-05-08 12:20:56 +02:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
# dns api wrapper of lexicon for acme.sh
|
|
|
|
|
|
|
|
lexicon_url="https://github.com/AnalogJ/lexicon"
|
|
|
|
lexicon_cmd="lexicon"
|
|
|
|
|
|
|
|
wiki="https://github.com/Neilpang/acme.sh/wiki/How-to-use-lexicon-dns-api"
|
|
|
|
|
|
|
|
######## Public functions #####################
|
|
|
|
|
|
|
|
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
|
|
|
|
dns_lexicon_add() {
|
|
|
|
fulldomain=$1
|
|
|
|
txtvalue=$2
|
2016-11-09 12:30:39 +01:00
|
|
|
|
2016-11-11 16:30:14 +01:00
|
|
|
domain=$(printf "%s" "$fulldomain" | cut -d . -f 2-999)
|
2016-11-09 12:30:39 +01:00
|
|
|
|
2016-11-11 16:30:14 +01:00
|
|
|
if ! _exists "$lexicon_cmd"; then
|
2016-05-08 12:20:56 +02:00
|
|
|
_err "Please install $lexicon_cmd first: $wiki"
|
|
|
|
return 1
|
|
|
|
fi
|
2016-11-09 12:30:39 +01:00
|
|
|
|
|
|
|
if [ -z "$PROVIDER" ]; then
|
2016-11-12 04:13:40 +01:00
|
|
|
PROVIDER=""
|
2016-05-08 12:20:56 +02:00
|
|
|
_err "Please define env PROVIDER first: $wiki"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
_savedomainconf PROVIDER "$PROVIDER"
|
|
|
|
export PROVIDER
|
|
|
|
|
2016-11-11 17:06:34 +01:00
|
|
|
Lx_name=$(echo LEXICON_"${PROVIDER}"_USERNAME | tr '[a-z]' '[A-Z]')
|
2016-11-12 04:40:30 +01:00
|
|
|
Lx_name_v=$(eval "echo "\$"$Lx_name""")
|
2016-05-08 12:20:56 +02:00
|
|
|
_debug "$Lx_name" "$Lx_name_v"
|
2016-11-09 12:30:39 +01:00
|
|
|
if [ "$Lx_name_v" ]; then
|
2016-11-11 16:30:14 +01:00
|
|
|
_saveaccountconf "$Lx_name" "$Lx_name_v"
|
2016-11-12 04:40:30 +01:00
|
|
|
eval export "$Lx_name"
|
2016-05-08 12:20:56 +02:00
|
|
|
fi
|
2016-11-09 12:30:39 +01:00
|
|
|
|
2016-11-11 17:06:34 +01:00
|
|
|
Lx_token=$(echo LEXICON_"${PROVIDER}"_TOKEN | tr '[a-z]' '[A-Z]')
|
2016-11-12 04:40:30 +01:00
|
|
|
Lx_token_v=$(eval "echo "\$"$Lx_token""")
|
2016-05-08 12:20:56 +02:00
|
|
|
_debug "$Lx_token" "$Lx_token_v"
|
2016-11-09 12:30:39 +01:00
|
|
|
if [ "$Lx_token_v" ]; then
|
2016-11-11 16:30:14 +01:00
|
|
|
_saveaccountconf "$Lx_token" "$Lx_token_v"
|
2016-11-12 04:40:30 +01:00
|
|
|
eval export "$Lx_token"
|
2016-05-08 12:20:56 +02:00
|
|
|
fi
|
2016-11-09 12:30:39 +01:00
|
|
|
|
2016-11-11 17:06:34 +01:00
|
|
|
Lx_password=$(echo LEXICON_"${PROVIDER}"_PASSWORD | tr '[a-z]' '[A-Z]')
|
2016-11-12 04:40:30 +01:00
|
|
|
Lx_password_v=$(eval "echo "\$"$Lx_password""")
|
2016-05-08 12:20:56 +02:00
|
|
|
_debug "$Lx_password" "$Lx_password_v"
|
2016-11-09 12:30:39 +01:00
|
|
|
if [ "$Lx_password_v" ]; then
|
2016-11-11 16:30:14 +01:00
|
|
|
_saveaccountconf "$Lx_password" "$Lx_password_v"
|
2016-11-12 04:40:30 +01:00
|
|
|
eval export "$Lx_password"
|
2016-05-08 12:20:56 +02:00
|
|
|
fi
|
2016-11-09 12:30:39 +01:00
|
|
|
|
2016-11-11 17:06:34 +01:00
|
|
|
Lx_domaintoken=$(echo LEXICON_"${PROVIDER}"_DOMAINTOKEN | tr '[a-z]' '[A-Z]')
|
2016-11-12 04:40:30 +01:00
|
|
|
Lx_domaintoken_v=$(eval "echo "\$"$Lx_domaintoken""")
|
2016-05-08 12:20:56 +02:00
|
|
|
_debug "$Lx_domaintoken" "$Lx_domaintoken_v"
|
2016-11-09 12:30:39 +01:00
|
|
|
if [ "$Lx_domaintoken_v" ]; then
|
2016-11-12 04:40:30 +01:00
|
|
|
eval export "$Lx_domaintoken"
|
2016-11-11 16:30:14 +01:00
|
|
|
_saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v"
|
2016-05-08 12:20:56 +02:00
|
|
|
fi
|
|
|
|
|
2016-11-11 17:06:34 +01:00
|
|
|
$lexicon_cmd "$PROVIDER" create "${domain}" TXT --name="_acme-challenge.${domain}." --content="${txtvalue}"
|
2016-05-08 12:20:56 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-10-25 17:08:02 +02:00
|
|
|
#fulldomain
|
|
|
|
dns_lexicon_rm() {
|
|
|
|
fulldomain=$1
|
|
|
|
|
|
|
|
}
|