You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.8 KiB

  1. #!/usr/bin/env sh
  2. # dns api wrapper of lexicon for acme.sh
  3. lexicon_url="https://github.com/AnalogJ/lexicon"
  4. lexicon_cmd="lexicon"
  5. wiki="https://github.com/Neilpang/acme.sh/wiki/How-to-use-lexicon-dns-api"
  6. ######## Public functions #####################
  7. #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
  8. dns_lexicon_add() {
  9. fulldomain=$1
  10. txtvalue=$2
  11. domain=$(printf "$fulldomain" | cut -d . -f 2-999)
  12. if ! _exists $lexicon_cmd ; then
  13. _err "Please install $lexicon_cmd first: $wiki"
  14. return 1
  15. fi
  16. if [ -z "$PROVIDER" ] ; then
  17. _err "Please define env PROVIDER first: $wiki"
  18. return 1
  19. fi
  20. _savedomainconf PROVIDER "$PROVIDER"
  21. export PROVIDER
  22. Lx_name=$(echo LEXICON_${PROVIDER}_USERNAME | tr [a-z] [A-Z])
  23. eval Lx_name_v="\$$Lx_name"
  24. _debug "$Lx_name" "$Lx_name_v"
  25. if [ "$Lx_name_v" ] ; then
  26. _saveaccountconf $Lx_name "$Lx_name_v"
  27. export "$Lx_name"
  28. fi
  29. Lx_token=$(echo LEXICON_${PROVIDER}_TOKEN | tr [a-z] [A-Z])
  30. eval Lx_token_v="\$$Lx_token"
  31. _debug "$Lx_token" "$Lx_token_v"
  32. if [ "$Lx_token_v" ] ; then
  33. _saveaccountconf $Lx_token "$Lx_token_v"
  34. export "$Lx_token"
  35. fi
  36. Lx_password=$(echo LEXICON_${PROVIDER}_PASSWORD | tr [a-z] [A-Z])
  37. eval Lx_password_v="\$$Lx_password"
  38. _debug "$Lx_password" "$Lx_password_v"
  39. if [ "$Lx_password_v" ] ; then
  40. _saveaccountconf $Lx_password "$Lx_password_v"
  41. export "$Lx_password"
  42. fi
  43. Lx_domaintoken=$(echo LEXICON_${PROVIDER}_DOMAINTOKEN | tr [a-z] [A-Z])
  44. eval Lx_domaintoken_v="\$$Lx_domaintoken"
  45. _debug "$Lx_domaintoken" "$Lx_domaintoken_v"
  46. if [ "$Lx_domaintoken_v" ] ; then
  47. export "$Lx_domaintoken"
  48. _saveaccountconf $Lx_domaintoken "$Lx_domaintoken_v"
  49. fi
  50. $lexicon_cmd "$PROVIDER" create ${domain} TXT --name="_acme-challenge.${domain}." --content="${txtvalue}"
  51. }