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.

65 lines
2.3 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 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. echo 'RM-ONE '"$1"
  36. echo 'RM-TWO '"$2"
  37. REGRU_API_Username="${REGRU_API_Username:-$(_readaccountconf_mutable REGRU_API_Username)}"
  38. REGRU_API_Password="${REGRU_API_Password:-$(_readaccountconf_mutable REGRU_API_Password)}"
  39. if [ -z "$REGRU_API_Username" ] || [ -z "$REGRU_API_Password" ]; then
  40. REGRU_API_Username=""
  41. REGRU_API_Password=""
  42. _err "You don't specify regru password or username."
  43. return 1
  44. fi
  45. _info "Deleting resource record $fulldomain"
  46. 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")"
  47. if _contains "${response}" 'success'; then
  48. return 0
  49. fi
  50. _err "Could not delete resource record, check logs"
  51. _err "${response}"
  52. return 1
  53. }