Browse Source

Introduced variable KNOT_ZONE to resolve issue #2881

pull/3093/head
Roman Danko 5 years ago
parent
commit
faa702a4e5
  1. 28
      dnsapi/dns_knot.sh

28
dnsapi/dns_knot.sh

@ -8,9 +8,12 @@ dns_knot_add() {
txtvalue=$2 txtvalue=$2
_checkKey || return 1 _checkKey || return 1
[ -n "${KNOT_SERVER}" ] || KNOT_SERVER="localhost" [ -n "${KNOT_SERVER}" ] || KNOT_SERVER="localhost"
KNOT_ZONE="${KNOT_ZONE:-$(_readaccountconf_mutable KNOT_ZONE)}"
# save the dns server and key to the account.conf file. # save the dns server and key to the account.conf file.
_saveaccountconf KNOT_SERVER "${KNOT_SERVER}" _saveaccountconf KNOT_SERVER "${KNOT_SERVER}"
_saveaccountconf KNOT_KEY "${KNOT_KEY}" _saveaccountconf KNOT_KEY "${KNOT_KEY}"
_saveaccountconf KNOT_ZONE "${KNOT_ZONE}"
if ! _get_root "$fulldomain"; then if ! _get_root "$fulldomain"; then
_err "Domain does not exist." _err "Domain does not exist."
@ -18,14 +21,23 @@ dns_knot_add() {
fi fi
_info "Adding ${fulldomain}. 60 TXT \"${txtvalue}\"" _info "Adding ${fulldomain}. 60 TXT \"${txtvalue}\""
knsupdate -y "${KNOT_KEY}" <<EOF
if [ -z "${KNOT_ZONE}" ]; then
knsupdate -y "${KNOT_KEY}" <<EOF
server ${KNOT_SERVER} server ${KNOT_SERVER}
zone ${_domain}. zone ${_domain}.
update add ${fulldomain}. 60 TXT "${txtvalue}" update add ${fulldomain}. 60 TXT "${txtvalue}"
send send
quit quit
EOF EOF
else
knsupdate -y "${KNOT_KEY}" <<EOF
server ${KNOT_SERVER}
zone ${KNOT_ZONE}.
update add ${fulldomain}. 60 TXT "${txtvalue}"
send
quit
EOF
fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
_err "Error updating domain." _err "Error updating domain."
@ -49,13 +61,23 @@ dns_knot_rm() {
_info "Removing ${fulldomain}. TXT" _info "Removing ${fulldomain}. TXT"
knsupdate -y "${KNOT_KEY}" <<EOF
if [ -z "${KNOT_ZONE}" ]; then
knsupdate -y "${KNOT_KEY}" <<EOF
server ${KNOT_SERVER} server ${KNOT_SERVER}
zone ${_domain}. zone ${_domain}.
update del ${fulldomain}. TXT update del ${fulldomain}. TXT
send send
quit quit
EOF EOF
else
knsupdate -y "${KNOT_KEY}" <<EOF
server ${KNOT_SERVER}
zone ${KNOT_ZONE}.
update del ${fulldomain}. TXT
send
quit
EOF
fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
_err "error updating domain" _err "error updating domain"

Loading…
Cancel
Save