From f8dbf7aef4f1b1648bd2980b62f2ef57d653e800 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Fri, 29 May 2020 08:49:19 -0400 Subject: renames --- etc/powerdns/dyndns-command.sh | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 etc/powerdns/dyndns-command.sh (limited to 'etc/powerdns/dyndns-command.sh') diff --git a/etc/powerdns/dyndns-command.sh b/etc/powerdns/dyndns-command.sh new file mode 100755 index 0000000..375d50b --- /dev/null +++ b/etc/powerdns/dyndns-command.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +die() { printf '%s\n' "$*" >&2; exit 1; } + +sql_string() +{ + printf '%s' "'${1//\'/\'\'}'" +} + +powerdns_sqlite_add_replace_record() +{ + local sql_new_domain="$(sql_string "$1.$3")" + local sql_ip_address="$(sql_string "$2")" + local sql_domain="$(sql_string "$3")" + local record_type="$(sql_string "$4")" + + DBDIR=/etc/powerdns + DBNAME=powerdns.sqlite3 + DB=$DBDIR/$DBNAME + + test -r $DB && test -w $DB || die "Wrong permissions on $DB" + test -r $DBDIR && test -w $DBDIR || die "Wrong permissions on $DBDIR" + + sqlite3 $DB <