]>
Commit | Line | Data |
---|---|---|
218dc339 | 1 | #!/usr/bin/env sh |
2 | ||
3 | # dns api wrapper of lexicon for acme.sh | |
4 | ||
5 | lexicon_url="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 | |
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 | ||
e9f9f515 | 33 | Lx_name=$(echo LEXICON_"${PROVIDER}"_USERNAME | tr '[a-z]' '[A-Z]') |
3de85700 | 34 | Lx_name_v=$(eval "echo "\$"$Lx_name""") |
218dc339 | 35 | _debug "$Lx_name" "$Lx_name_v" |
4c2a3841 | 36 | if [ "$Lx_name_v" ]; then |
c7b16249 | 37 | _saveaccountconf "$Lx_name" "$Lx_name_v" |
3de85700 | 38 | eval export "$Lx_name" |
218dc339 | 39 | fi |
4c2a3841 | 40 | |
e9f9f515 | 41 | Lx_token=$(echo LEXICON_"${PROVIDER}"_TOKEN | tr '[a-z]' '[A-Z]') |
3de85700 | 42 | Lx_token_v=$(eval "echo "\$"$Lx_token""") |
218dc339 | 43 | _debug "$Lx_token" "$Lx_token_v" |
4c2a3841 | 44 | if [ "$Lx_token_v" ]; then |
c7b16249 | 45 | _saveaccountconf "$Lx_token" "$Lx_token_v" |
3de85700 | 46 | eval export "$Lx_token" |
218dc339 | 47 | fi |
4c2a3841 | 48 | |
e9f9f515 | 49 | Lx_password=$(echo LEXICON_"${PROVIDER}"_PASSWORD | tr '[a-z]' '[A-Z]') |
3de85700 | 50 | Lx_password_v=$(eval "echo "\$"$Lx_password""") |
218dc339 | 51 | _debug "$Lx_password" "$Lx_password_v" |
4c2a3841 | 52 | if [ "$Lx_password_v" ]; then |
c7b16249 | 53 | _saveaccountconf "$Lx_password" "$Lx_password_v" |
3de85700 | 54 | eval export "$Lx_password" |
218dc339 | 55 | fi |
4c2a3841 | 56 | |
e9f9f515 | 57 | Lx_domaintoken=$(echo LEXICON_"${PROVIDER}"_DOMAINTOKEN | tr '[a-z]' '[A-Z]') |
3de85700 | 58 | Lx_domaintoken_v=$(eval "echo "\$"$Lx_domaintoken""") |
218dc339 | 59 | _debug "$Lx_domaintoken" "$Lx_domaintoken_v" |
4c2a3841 | 60 | if [ "$Lx_domaintoken_v" ]; then |
3de85700 | 61 | eval export "$Lx_domaintoken" |
c7b16249 | 62 | _saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v" |
218dc339 | 63 | fi |
64 | ||
e9f9f515 | 65 | $lexicon_cmd "$PROVIDER" create "${domain}" TXT --name="_acme-challenge.${domain}." --content="${txtvalue}" |
218dc339 | 66 | |
67 | } | |
68 | ||
5d6fd809 | 69 | #fulldomain |
70 | dns_lexicon_rm() { | |
71 | fulldomain=$1 | |
72 | ||
73 | } |