2016-05-08 10:20:56 +00: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 11:30:39 +00:00
|
|
|
|
2016-11-11 15:30:14 +00:00
|
|
|
domain=$(printf "%s" "$fulldomain" | cut -d . -f 2-999)
|
2016-11-09 11:30:39 +00:00
|
|
|
|
2016-11-11 15:30:14 +00:00
|
|
|
if ! _exists "$lexicon_cmd"; then
|
2016-05-08 10:20:56 +00:00
|
|
|
_err "Please install $lexicon_cmd first: $wiki"
|
|
|
|
return 1
|
|
|
|
fi
|
2016-11-09 11:30:39 +00:00
|
|
|
|
|
|
|
if [ -z "$PROVIDER" ]; then
|
2016-11-12 03:13:40 +00:00
|
|
|
PROVIDER=""
|
2016-05-08 10:20:56 +00:00
|
|
|
_err "Please define env PROVIDER first: $wiki"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
_savedomainconf PROVIDER "$PROVIDER"
|
|
|
|
export PROVIDER
|
|
|
|
|
2016-11-11 16:06:34 +00:00
|
|
|
Lx_name=$(echo LEXICON_"${PROVIDER}"_USERNAME | tr '[a-z]' '[A-Z]')
|
2016-05-08 10:20:56 +00:00
|
|
|
eval Lx_name_v="\$$Lx_name"
|
|
|
|
_debug "$Lx_name" "$Lx_name_v"
|
2016-11-09 11:30:39 +00:00
|
|
|
if [ "$Lx_name_v" ]; then
|
2016-11-11 15:30:14 +00:00
|
|
|
_saveaccountconf "$Lx_name" "$Lx_name_v"
|
2016-05-08 10:20:56 +00:00
|
|
|
export "$Lx_name"
|
|
|
|
fi
|
2016-11-09 11:30:39 +00:00
|
|
|
|
2016-11-11 16:06:34 +00:00
|
|
|
Lx_token=$(echo LEXICON_"${PROVIDER}"_TOKEN | tr '[a-z]' '[A-Z]')
|
2016-05-08 10:20:56 +00:00
|
|
|
eval Lx_token_v="\$$Lx_token"
|
|
|
|
_debug "$Lx_token" "$Lx_token_v"
|
2016-11-09 11:30:39 +00:00
|
|
|
if [ "$Lx_token_v" ]; then
|
2016-11-11 15:30:14 +00:00
|
|
|
_saveaccountconf "$Lx_token" "$Lx_token_v"
|
2016-05-08 10:20:56 +00:00
|
|
|
export "$Lx_token"
|
|
|
|
fi
|
2016-11-09 11:30:39 +00:00
|
|
|
|
2016-11-11 16:06:34 +00:00
|
|
|
Lx_password=$(echo LEXICON_"${PROVIDER}"_PASSWORD | tr '[a-z]' '[A-Z]')
|
2016-05-08 10:20:56 +00:00
|
|
|
eval Lx_password_v="\$$Lx_password"
|
|
|
|
_debug "$Lx_password" "$Lx_password_v"
|
2016-11-09 11:30:39 +00:00
|
|
|
if [ "$Lx_password_v" ]; then
|
2016-11-11 15:30:14 +00:00
|
|
|
_saveaccountconf "$Lx_password" "$Lx_password_v"
|
2016-05-08 10:20:56 +00:00
|
|
|
export "$Lx_password"
|
|
|
|
fi
|
2016-11-09 11:30:39 +00:00
|
|
|
|
2016-11-11 16:06:34 +00:00
|
|
|
Lx_domaintoken=$(echo LEXICON_"${PROVIDER}"_DOMAINTOKEN | tr '[a-z]' '[A-Z]')
|
2016-05-08 10:20:56 +00:00
|
|
|
eval Lx_domaintoken_v="\$$Lx_domaintoken"
|
|
|
|
_debug "$Lx_domaintoken" "$Lx_domaintoken_v"
|
2016-11-09 11:30:39 +00:00
|
|
|
if [ "$Lx_domaintoken_v" ]; then
|
2016-05-08 10:20:56 +00:00
|
|
|
export "$Lx_domaintoken"
|
2016-11-11 15:30:14 +00:00
|
|
|
_saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v"
|
2016-05-08 10:20:56 +00:00
|
|
|
fi
|
|
|
|
|
2016-11-11 16:06:34 +00:00
|
|
|
$lexicon_cmd "$PROVIDER" create "${domain}" TXT --name="_acme-challenge.${domain}." --content="${txtvalue}"
|
2016-05-08 10:20:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-10-25 15:08:02 +00:00
|
|
|
#fulldomain
|
|
|
|
dns_lexicon_rm() {
|
|
|
|
fulldomain=$1
|
|
|
|
|
|
|
|
}
|