From 4d32b7e6ae9a206381d470d25cb5bfaf84299288 Mon Sep 17 00:00:00 2001 From: Vitaly Kireev Date: Wed, 27 May 2020 11:48:54 +0300 Subject: [PATCH] To work in cronjob ${_domain} was empty in cronjob. Replace it by fulldomain without _acme-challenge. at begin string. Now CronJob works perfectly excellent for me. Thanks all. --- dnsapi/dns_regru.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dnsapi/dns_regru.sh b/dnsapi/dns_regru.sh index 369f62ad..100bfcf9 100644 --- a/dnsapi/dns_regru.sh +++ b/dnsapi/dns_regru.sh @@ -14,6 +14,8 @@ REGRU_API_URL="https://api.reg.ru/api/regru2" dns_regru_add() { fulldomain=$1 txtvalue=$2 + mydomain=${fulldomain#*_acme-challenge.} + _info "Name of domain ${mydomain}" REGRU_API_Username="${REGRU_API_Username:-$(_readaccountconf_mutable REGRU_API_Username)}" REGRU_API_Password="${REGRU_API_Password:-$(_readaccountconf_mutable REGRU_API_Password)}" @@ -28,7 +30,7 @@ dns_regru_add() { _saveaccountconf_mutable REGRU_API_Password "$REGRU_API_Password" _info "Adding TXT record to ${fulldomain}" - 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")" + 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${mydomain}%22}],%22subdomain%22:%22_acme-challenge%22,%22text%22:%22${txtvalue}%22,%22output_content_type%22:%22plain%22}&input_format=json")" if _contains "${response}" 'success'; then return 0 @@ -41,6 +43,8 @@ dns_regru_add() { dns_regru_rm() { fulldomain=$1 txtvalue=$2 + mydomain=${fulldomain#*_acme-challenge.} + _info "Name of domain ${mydomain}" REGRU_API_Username="${REGRU_API_Username:-$(_readaccountconf_mutable REGRU_API_Username)}" REGRU_API_Password="${REGRU_API_Password:-$(_readaccountconf_mutable REGRU_API_Password)}" @@ -52,7 +56,7 @@ dns_regru_rm() { fi _info "Deleting resource record $fulldomain" - 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")" + 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${mydomain}%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")" if _contains "${response}" 'success'; then return 0