|
|
@ -2,7 +2,8 @@ |
|
|
|
|
|
|
|
# Here is a script to add/remove TXT records to DNS Server on Synology DSM |
|
|
|
# |
|
|
|
# Author: Arabezar (on github) aka Arkadii Zhuchenko ©13.07.2020 |
|
|
|
# Author: Arabezar aka Arkadii Zhuchenko © 13.07.2020 |
|
|
|
# Great thanks to loderunner84 for the invaluable help in synowebapi research |
|
|
|
# |
|
|
|
#returns 0 means success, otherwise error. |
|
|
|
|
|
|
@ -22,7 +23,7 @@ dns_synology_dsm_add() { |
|
|
|
maindomain="${fulldomain//_acme-challenge\./}" |
|
|
|
_debug3 maindomain "$maindomain" |
|
|
|
|
|
|
|
# WebAPI-call can be replaced by adding line to the "/var/packages/DNSServer/target/named/etc/zone/master/$maindomain" file |
|
|
|
# SynoWebAPI call can be replaced by adding the line to the "/var/packages/DNSServer/target/named/etc/zone/master/$maindomain" file |
|
|
|
response=$(synowebapi --exec api=SYNO.DNSServer.Zone.Record method=create version=1 runner=admin \ |
|
|
|
zone_name='"'"${maindomain}"'"' \ |
|
|
|
domain_name='"'"${maindomain}"'"' \ |
|
|
@ -52,9 +53,18 @@ dns_synology_dsm_rm() { |
|
|
|
maindomain="${fulldomain//_acme-challenge\./}" |
|
|
|
_debug3 maindomain "$maindomain" |
|
|
|
|
|
|
|
# Just removing TXT record from file (calling synowebapi failed due to some bug in specifying "items" param) |
|
|
|
_dns_zone_url="/var/packages/DNSServer/target/named/etc/zone/master/$maindomain" |
|
|
|
sed -i "/^${fulldomain}.[[:blank:]]${_DNS_TTL}[[:blank:]]TXT[[:blank:]]\"${txtvalue}\"/d" "$_dns_zone_url" |
|
|
|
response=$(synowebapi --exec api=SYNO.DNSServer.Zone.Record method=delete version=1 runner=admin \ |
|
|
|
items=["{\"zone_name\":\"$maindomain\",\"domain_name\":\"$maindomain\",\"rr_owner\":\"$fulldomain.\",\"rr_type\":\"TXT\",\"rr_ttl\":\"$_DNS_TTL\",\"rr_info\":\"\\\"$txtvalue\\\"\",\"full_record\":\"$fulldomain.\t$_DNS_TTL\tTXT\t\\\"$txtvalue\\\"\"}"] 2> /dev/null) |
|
|
|
|
|
|
|
return 0 |
|
|
|
# WebAPI-call can be replaced by removing the line from the "/var/packages/DNSServer/target/named/etc/zone/master/$maindomain" file |
|
|
|
#_dns_zone_url="/var/packages/DNSServer/target/named/etc/zone/master/$maindomain" |
|
|
|
#sed -i "/^${fulldomain}.[[:blank:]]${_DNS_TTL}[[:blank:]]TXT[[:blank:]]\"${txtvalue}\"/d" "$_dns_zone_url" |
|
|
|
|
|
|
|
_debug3 response "$response" |
|
|
|
|
|
|
|
if [ "$(echo "$response" | jq '.success')" == true ]; then |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
|
|
|
|
return 1 |
|
|
|
} |