From 0d70aefb72bcef186cd73cb506be8197f740977d Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Fri, 29 May 2020 07:20:52 -0400 Subject: initial commit --- dyndns-command.sh | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 dyndns-command.sh (limited to 'dyndns-command.sh') diff --git a/dyndns-command.sh b/dyndns-command.sh new file mode 100755 index 0000000..375d50b --- /dev/null +++ b/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 <