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.

74 lines
1.9 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. dns_lexicon_del(){
  8. _err "Not implemented!"
  9. return 1
  10. }
  11. #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
  12. dns_lexicon_add() {
  13. fulldomain=$1
  14. txtvalue=$2
  15. domain=$(printf "$fulldomain" | cut -d . -f 2-999)
  16. if ! _exists $lexicon_cmd ; then
  17. _err "Please install $lexicon_cmd first: $wiki"
  18. return 1
  19. fi
  20. if [ -z "$PROVIDER" ] ; then
  21. _err "Please define env PROVIDER first: $wiki"
  22. return 1
  23. fi
  24. _savedomainconf PROVIDER "$PROVIDER"
  25. export PROVIDER
  26. Lx_name=$(echo LEXICON_${PROVIDER}_USERNAME | tr [a-z] [A-Z])
  27. eval Lx_name_v="\$$Lx_name"
  28. _debug "$Lx_name" "$Lx_name_v"
  29. if [ "$Lx_name_v" ] ; then
  30. _saveaccountconf $Lx_name "$Lx_name_v"
  31. export "$Lx_name"
  32. fi
  33. Lx_token=$(echo LEXICON_${PROVIDER}_TOKEN | tr [a-z] [A-Z])
  34. eval Lx_token_v="\$$Lx_token"
  35. _debug "$Lx_token" "$Lx_token_v"
  36. if [ "$Lx_token_v" ] ; then
  37. _saveaccountconf $Lx_token "$Lx_token_v"
  38. export "$Lx_token"
  39. fi
  40. Lx_password=$(echo LEXICON_${PROVIDER}_PASSWORD | tr [a-z] [A-Z])
  41. eval Lx_password_v="\$$Lx_password"
  42. _debug "$Lx_password" "$Lx_password_v"
  43. if [ "$Lx_password_v" ] ; then
  44. _saveaccountconf $Lx_password "$Lx_password_v"
  45. export "$Lx_password"
  46. fi
  47. Lx_domaintoken=$(echo LEXICON_${PROVIDER}_DOMAINTOKEN | tr [a-z] [A-Z])
  48. eval Lx_domaintoken_v="\$$Lx_domaintoken"
  49. _debug "$Lx_domaintoken" "$Lx_domaintoken_v"
  50. if [ "$Lx_domaintoken_v" ] ; then
  51. export "$Lx_domaintoken"
  52. _saveaccountconf $Lx_domaintoken "$Lx_domaintoken_v"
  53. fi
  54. $lexicon_cmd "$PROVIDER" create ${domain} TXT --name="_acme-challenge.${domain}." --content="${txtvalue}"
  55. }