From 6a02ec3617ec30c7b9e60f073df7af9432e38a0b Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 13 Oct 2020 14:54:18 -0400 Subject: fix the subdomains --- bin/cryptonomic-dyndns-command | 73 +++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/bin/cryptonomic-dyndns-command b/bin/cryptonomic-dyndns-command index 8e97de7..348ed74 100755 --- a/bin/cryptonomic-dyndns-command +++ b/bin/cryptonomic-dyndns-command @@ -1,6 +1,8 @@ #!/bin/bash -die() { printf '%s\n' "$*" >&2; exit 1; } +die() { printf 'Error: %s\n' "$*" >&2; exit 1; } + +warn() { printf 'Warning: %s\n' "$*" >&2; } sql_string() { @@ -9,13 +11,21 @@ sql_string() powerdns_sqlite_add_replace_record() { - local fqdn="$1" - local record_type="$(sql_string "$2")" + local sql_record_type="$(sql_string "$2")" local sql_ip_address="$(sql_string "$3")" - fqdn=${fqdn: -64 : 64} - local sql_new_domain="$(sql_string "$fqdn")" - local sql_domain="$(sql_string "${fqdn#*.}")" + zone=${1#*.} + new_name=${label:+$label.}${1: -64 : 64} + + local sql_new_name="$(sql_string "$new_name")" + local sql_zone="$(sql_string "$zone")" + + if false + then + pdnsutil create-zone "$zone" + pdnsutil add-record "$zone" "$new_name" "$2" "$3" + return + fi DBDIR=/etc/powerdns DBNAME=powerdns.sqlite3 @@ -27,7 +37,7 @@ powerdns_sqlite_add_replace_record() sqlite3 $DB <