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.

87 lines
2.4 KiB

  1. #!/usr/bin/env sh
  2. # dnsHome.de API for acme.sh
  3. #
  4. # This Script adds the necessary TXT record to a Subdomain
  5. #
  6. # Author dnsHome.de (https://github.com/dnsHome-de)
  7. #
  8. # Report Bugs to https://github.com/acmesh-official/acme.sh/issues/3819
  9. #
  10. # export DNSHOME_Subdomain=""
  11. # export DNSHOME_SubdomainPassword=""
  12. # Usage: add subdomain.ddnsdomain.tld "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
  13. # Used to add txt record
  14. dns_dnshome_add() {
  15. txtvalue=$2
  16. DNSHOME_Subdomain="${DNSHOME_Subdomain:-$(_readdomainconf DNSHOME_Subdomain)}"
  17. DNSHOME_SubdomainPassword="${DNSHOME_SubdomainPassword:-$(_readdomainconf DNSHOME_SubdomainPassword)}"
  18. if [ -z "$DNSHOME_Subdomain" ] || [ -z "$DNSHOME_SubdomainPassword" ]; then
  19. DNSHOME_Subdomain=""
  20. DNSHOME_SubdomainPassword=""
  21. _err "Please specify/export your dnsHome.de Subdomain and Password"
  22. return 1
  23. fi
  24. #save the credentials to the account conf file.
  25. _savedomainconf DNSHOME_Subdomain "$DNSHOME_Subdomain"
  26. _savedomainconf DNSHOME_SubdomainPassword "$DNSHOME_SubdomainPassword"
  27. DNSHOME_Api="https://$DNSHOME_Subdomain:$DNSHOME_SubdomainPassword@www.dnshome.de/dyndns.php"
  28. _DNSHOME_rest POST "acme=add&txt=$txtvalue"
  29. if ! echo "$response" | grep 'successfully' >/dev/null; then
  30. _err "Error"
  31. _err "$response"
  32. return 1
  33. fi
  34. return 0
  35. }
  36. # Usage: txtvalue
  37. # Used to remove the txt record after validation
  38. dns_dnshome_rm() {
  39. txtvalue=$2
  40. DNSHOME_Subdomain="${DNSHOME_Subdomain:-$(_readdomainconf DNSHOME_Subdomain)}"
  41. DNSHOME_SubdomainPassword="${DNSHOME_SubdomainPassword:-$(_readdomainconf DNSHOME_SubdomainPassword)}"
  42. DNSHOME_Api="https://$DNSHOME_Subdomain:$DNSHOME_SubdomainPassword@www.dnshome.de/dyndns.php"
  43. if [ -z "$DNSHOME_Subdomain" ] || [ -z "$DNSHOME_SubdomainPassword" ]; then
  44. DNSHOME_Subdomain=""
  45. DNSHOME_SubdomainPassword=""
  46. _err "Please specify/export your dnsHome.de Subdomain and Password"
  47. return 1
  48. fi
  49. _DNSHOME_rest POST "acme=rm&txt=$txtvalue"
  50. if ! echo "$response" | grep 'successfully' >/dev/null; then
  51. _err "Error"
  52. _err "$response"
  53. return 1
  54. fi
  55. return 0
  56. }
  57. #################### Private functions below ##################################
  58. _DNSHOME_rest() {
  59. method=$1
  60. data="$2"
  61. _debug "$data"
  62. _debug data "$data"
  63. response="$(_post "$data" "$DNSHOME_Api" "" "$method")"
  64. if [ "$?" != "0" ]; then
  65. _err "error $data"
  66. return 1
  67. fi
  68. _debug2 response "$response"
  69. return 0
  70. }