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.

73 lines
2.0 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 "%s" "$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. PROVIDER=""
  18. _err "Please define env PROVIDER first: $wiki"
  19. return 1
  20. fi
  21. _savedomainconf PROVIDER "$PROVIDER"
  22. export PROVIDER
  23. Lx_name=$(echo LEXICON_"${PROVIDER}"_USERNAME | tr '[a-z]' '[A-Z]')
  24. Lx_name_v=$(eval "echo "\$"$Lx_name""")
  25. _debug "$Lx_name" "$Lx_name_v"
  26. if [ "$Lx_name_v" ]; then
  27. _saveaccountconf "$Lx_name" "$Lx_name_v"
  28. eval export "$Lx_name"
  29. fi
  30. Lx_token=$(echo LEXICON_"${PROVIDER}"_TOKEN | tr '[a-z]' '[A-Z]')
  31. Lx_token_v=$(eval "echo "\$"$Lx_token""")
  32. _debug "$Lx_token" "$Lx_token_v"
  33. if [ "$Lx_token_v" ]; then
  34. _saveaccountconf "$Lx_token" "$Lx_token_v"
  35. eval export "$Lx_token"
  36. fi
  37. Lx_password=$(echo LEXICON_"${PROVIDER}"_PASSWORD | tr '[a-z]' '[A-Z]')
  38. Lx_password_v=$(eval "echo "\$"$Lx_password""")
  39. _debug "$Lx_password" "$Lx_password_v"
  40. if [ "$Lx_password_v" ]; then
  41. _saveaccountconf "$Lx_password" "$Lx_password_v"
  42. eval export "$Lx_password"
  43. fi
  44. Lx_domaintoken=$(echo LEXICON_"${PROVIDER}"_DOMAINTOKEN | tr '[a-z]' '[A-Z]')
  45. Lx_domaintoken_v=$(eval "echo "\$"$Lx_domaintoken""")
  46. _debug "$Lx_domaintoken" "$Lx_domaintoken_v"
  47. if [ "$Lx_domaintoken_v" ]; then
  48. eval export "$Lx_domaintoken"
  49. _saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v"
  50. fi
  51. $lexicon_cmd "$PROVIDER" create "${domain}" TXT --name="_acme-challenge.${domain}." --content="${txtvalue}"
  52. }
  53. #fulldomain
  54. dns_lexicon_rm() {
  55. fulldomain=$1
  56. }