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
2.3 KiB

3 months ago
3 months ago
3 months 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: github.com/acmesh-official/acme.sh
  10. Author: Henning Reich <acmesh@qupfer.de>
  11. '
  12. #This file name is "dns_myapi.sh"
  13. #So, here must be a method dns_myapi_add()
  14. #Which will be called by acme.sh to add the txt record to your api system.
  15. #returns 0 means success, otherwise error.
  16. ######## Public functions #####################
  17. # Please Read this guide first: https://github.com/acmesh-official/acme.sh/wiki/DNS-API-Dev-Guide
  18. #Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
  19. dns_technitium_add() {
  20. fulldomain=$1
  21. txtvalue=$2
  22. _Technitium_account
  23. _info "Using Technitium"
  24. _debug fulldomain "$fulldomain"
  25. _debug txtvalue "$txtvalue"
  26. response="$(_get "$Technitium_Server/api/zones/records/add?token=$Technitium_Token&domain=$fulldomain&type=TXT&text=${txtvalue}")"
  27. if _contains "$response" '"status":"ok"'; then
  28. return 0
  29. fi
  30. _err "Could not add txt record."
  31. return 1
  32. }
  33. #Usage: fulldomain txtvalue
  34. #Remove the txt record after validation.
  35. dns_technitium_rm() {
  36. fulldomain=$1
  37. txtvalue=$2
  38. _info "Using Technitium"
  39. response="$(_get "$Technitium_Server/api/zones/records/delete?token=$Technitium_Token&domain=$fulldomain&type=TXT&text=${txtvalue}")"
  40. if _contains "$response" '"status":"ok"'; then
  41. return 0
  42. fi
  43. _err "Could not remove txt record"
  44. return 1
  45. }
  46. #################### Private functions below ##################################
  47. _Technitium_account() {
  48. Technitium_Server="${Technitium_Server:-$(_readaccountconf_mutable Technitium_Server)}"
  49. Technitium_Token="${Technitium_Token:-$(_readaccountconf_mutable Technitium_Token)}"
  50. if [ -z "$Technitium_Server" ] || [ -z "$Technitium_Token" ]; then
  51. Technitium_Server=""
  52. Technitium_Token=""
  53. _err "You don't specify Technitium Server and Token yet."
  54. _err "Please create your Token and add server address and try again."
  55. return 1
  56. fi
  57. #save the credentials to the account conf file.
  58. _saveaccountconf_mutable Technitium_Server "$Technitium_Server"
  59. _saveaccountconf_mutable Technitium_Token "$Technitium_Token"
  60. }