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.

56 lines
1.8 KiB

1 month ago
4 weeks ago
1 month ago
1 month ago
4 weeks ago
1 month ago
4 weeks ago
1 month ago
  1. #!/usr/bin/env sh
  2. # shellcheck disable=SC2034
  3. dns_Technitium_info='Technitium DNS Server
  4. Site: https://technitium.com/dns/
  5. Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_technitium
  6. Options:
  7. Technitium_Server Server Address
  8. Technitium_Token API Token
  9. Issues:https://github.com/acmesh-official/acme.sh/issues/6116
  10. Author: Henning Reich <acmesh@qupfer.de>
  11. '
  12. dns_technitium_add() {
  13. _info "add txt Record using Technitium"
  14. _Technitium_account
  15. fulldomain=$1
  16. txtvalue=$2
  17. response="$(_get "$Technitium_Server/api/zones/records/add?token=$Technitium_Token&domain=$fulldomain&type=TXT&text=${txtvalue}")"
  18. if _contains "$response" '"status":"ok"'; then
  19. return 0
  20. fi
  21. _err "Could not add txt record."
  22. return 1
  23. }
  24. dns_technitium_rm() {
  25. _info "remove txt record using Technitium"
  26. _Technitium_account
  27. fulldomain=$1
  28. txtvalue=$2
  29. response="$(_get "$Technitium_Server/api/zones/records/delete?token=$Technitium_Token&domain=$fulldomain&type=TXT&text=${txtvalue}")"
  30. if _contains "$response" '"status":"ok"'; then
  31. return 0
  32. fi
  33. _err "Could not remove txt record"
  34. return 1
  35. }
  36. #################### Private functions below ##################################
  37. _Technitium_account() {
  38. Technitium_Server="${Technitium_Server:-$(_readaccountconf_mutable Technitium_Server)}"
  39. Technitium_Token="${Technitium_Token:-$(_readaccountconf_mutable Technitium_Token)}"
  40. if [ -z "$Technitium_Server" ] || [ -z "$Technitium_Token" ]; then
  41. Technitium_Server=""
  42. Technitium_Token=""
  43. _err "You don't specify Technitium Server and Token yet."
  44. _err "Please create your Token and add server address and try again."
  45. return 1
  46. fi
  47. #save the credentials to the account conf file.
  48. _saveaccountconf_mutable Technitium_Server "$Technitium_Server"
  49. _saveaccountconf_mutable Technitium_Token "$Technitium_Token"
  50. }