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.

58 lines
1.8 KiB

1 month ago
4 weeks ago
1 month ago
1 month 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. fulldomain=$1
  14. txtvalue=$2
  15. _Technitium_account
  16. _info "Using Technitium"
  17. _debug fulldomain "$fulldomain"
  18. _debug txtvalue "$txtvalue"
  19. response="$(_get "$Technitium_Server/api/zones/records/add?token=$Technitium_Token&domain=$fulldomain&type=TXT&text=${txtvalue}")"
  20. if _contains "$response" '"status":"ok"'; then
  21. return 0
  22. fi
  23. _err "Could not add txt record."
  24. return 1
  25. }
  26. dns_technitium_rm() {
  27. fulldomain=$1
  28. txtvalue=$2
  29. _Technitium_account
  30. _info "Using Technitium"
  31. response="$(_get "$Technitium_Server/api/zones/records/delete?token=$Technitium_Token&domain=$fulldomain&type=TXT&text=${txtvalue}")"
  32. if _contains "$response" '"status":"ok"'; then
  33. return 0
  34. fi
  35. _err "Could not remove txt record"
  36. return 1
  37. }
  38. #################### Private functions below ##################################
  39. _Technitium_account() {
  40. Technitium_Server="${Technitium_Server:-$(_readaccountconf_mutable Technitium_Server)}"
  41. Technitium_Token="${Technitium_Token:-$(_readaccountconf_mutable Technitium_Token)}"
  42. if [ -z "$Technitium_Server" ] || [ -z "$Technitium_Token" ]; then
  43. Technitium_Server=""
  44. Technitium_Token=""
  45. _err "You don't specify Technitium Server and Token yet."
  46. _err "Please create your Token and add server address and try again."
  47. return 1
  48. fi
  49. #save the credentials to the account conf file.
  50. _saveaccountconf_mutable Technitium_Server "$Technitium_Server"
  51. _saveaccountconf_mutable Technitium_Token "$Technitium_Token"
  52. }