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.

63 lines
2.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #!/usr/bin/env sh
  2. #
  3. # REGRU_API_Username="test"
  4. #
  5. # REGRU_API_Password="test"
  6. #
  7. _domain=$_domain
  8. REGRU_API_URL="https://api.reg.ru/api/regru2"
  9. ######## Public functions #####################
  10. dns_regru_add() {
  11. fulldomain=$1
  12. txtvalue=$2
  13. REGRU_API_Username="${REGRU_API_Username:-$(_readaccountconf_mutable REGRU_API_Username)}"
  14. REGRU_API_Password="${REGRU_API_Password:-$(_readaccountconf_mutable REGRU_API_Password)}"
  15. if [ -z "$REGRU_API_Username" ] || [ -z "$REGRU_API_Password" ]; then
  16. REGRU_API_Username=""
  17. REGRU_API_Password=""
  18. _err "You don't specify regru password or username."
  19. return 1
  20. fi
  21. _saveaccountconf_mutable REGRU_API_Username "$REGRU_API_Username"
  22. _saveaccountconf_mutable REGRU_API_Password "$REGRU_API_Password"
  23. _info "Adding TXT record to ${fulldomain}"
  24. response="$(_get "$REGRU_API_URL/zone/add_txt?input_data={%22username%22:%22${REGRU_API_Username}%22,%22password%22:%22${REGRU_API_Password}%22,%22domains%22:[{%22dname%22:%22${_domain}%22}],%22subdomain%22:%22_acme-challenge%22,%22text%22:%22${txtvalue}%22,%22output_content_type%22:%22plain%22}&input_format=json")"
  25. if _contains "${response}" 'success'; then
  26. return 0
  27. fi
  28. _err "Could not create resource record, check logs"
  29. _err "${response}"
  30. return 1
  31. }
  32. dns_regru_rm() {
  33. fulldomain=$1
  34. txtvalue=$2
  35. REGRU_API_Username="${REGRU_API_Username:-$(_readaccountconf_mutable REGRU_API_Username)}"
  36. REGRU_API_Password="${REGRU_API_Password:-$(_readaccountconf_mutable REGRU_API_Password)}"
  37. if [ -z "$REGRU_API_Username" ] || [ -z "$REGRU_API_Password" ]; then
  38. REGRU_API_Username=""
  39. REGRU_API_Password=""
  40. _err "You don't specify regru password or username."
  41. return 1
  42. fi
  43. _info "Deleting resource record $fulldomain"
  44. response="$(_get "$REGRU_API_URL/zone/remove_record?input_data={%22username%22:%22${REGRU_API_Username}%22,%22password%22:%22${REGRU_API_Password}%22,%22domains%22:[{%22dname%22:%22${_domain}%22}],%22subdomain%22:%22_acme-challenge%22,%22content%22:%22${txtvalue}%22,%22record_type%22:%22TXT%22,%22output_content_type%22:%22plain%22}&input_format=json")"
  45. if _contains "${response}" 'success'; then
  46. return 0
  47. fi
  48. _err "Could not delete resource record, check logs"
  49. _err "${response}"
  50. return 1
  51. }