From 42446e3dc6b20f3402e83059c8d2ce0cc64994ed Mon Sep 17 00:00:00 2001 From: Ferenc Schulcz <schulcz.ferenc@gmail.com> Date: Sun, 4 Feb 2024 18:18:36 +0100 Subject: [PATCH] Configurable knot location --- config.json.defaults | 1 + knotdns.js | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config.json.defaults b/config.json.defaults index 657c72b..802a077 100644 --- a/config.json.defaults +++ b/config.json.defaults @@ -1,5 +1,6 @@ { "higherLevelDomain": "dyndns.mydomain.com", + "knotLocation": "/usr/sbin/knotc", "dbHost": "localhost", "listenAddress": "127.0.0.1", "listenPort": 3000 diff --git a/knotdns.js b/knotdns.js index b50f862..5dd9d31 100644 --- a/knotdns.js +++ b/knotdns.js @@ -5,17 +5,17 @@ const config = require('./config'); async function updateRecord(domain, ip) { try { - await exec("/usr/sbin/knotc zone-begin " + config.config().higherLevelDomain); + await exec(config.config().knotLocation + " zone-begin " + config.config().higherLevelDomain); try { - await exec("/usr/sbin/knotc zone-unset " + config.config().higherLevelDomain + " " + domain); + await exec(config.config().knotLocation + " zone-unset " + config.config().higherLevelDomain + " " + domain); } catch { console.log("Could not unset domain " + domain); } - await exec("/usr/sbin/knotc zone-set " + config.config().higherLevelDomain + " " + domain + " 60 A " + ip); - await exec("/usr/sbin/knotc zone-commit " + config.config().higherLevelDomain); + await exec(config.config().knotLocation + " zone-set " + config.config().higherLevelDomain + " " + domain + " 60 A " + ip); + await exec(config.config().knotLocation + " zone-commit " + config.config().higherLevelDomain); } catch { try { - await exec("/usr/sbin/knotc zone-abort " + config.config().higherLevelDomain); + await exec(config.config().knotLocation + " zone-abort " + config.config().higherLevelDomain); console.log("Problem with manipulating DNS zone " + config.config().higherLevelDomain + ". Aborted transaction."); } catch { console.log("Problem with manipulating DNS zone " + config.config().higherLevelDomain + ". Could not even abort transaction."); -- GitLab