Skip to content
Snippets Groups Projects
Commit f890c210 authored by Ferenc Schulcz's avatar Ferenc Schulcz
Browse files

Make knot usage more robust

parent 63bb147d
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ const exec = util.promisify(require('child_process').exec); ...@@ -4,6 +4,7 @@ const exec = util.promisify(require('child_process').exec);
const config = require('./config'); const config = require('./config');
async function updateRecord(domain, ip) { async function updateRecord(domain, ip) {
try {
await exec("/usr/sbin/knotc zone-begin " + config.config().higherLevelDomain); await exec("/usr/sbin/knotc zone-begin " + config.config().higherLevelDomain);
try { try {
await exec("/usr/sbin/knotc zone-unset " + config.config().higherLevelDomain + " " + domain); await exec("/usr/sbin/knotc zone-unset " + config.config().higherLevelDomain + " " + domain);
...@@ -12,6 +13,14 @@ async function updateRecord(domain, ip) { ...@@ -12,6 +13,14 @@ async function updateRecord(domain, ip) {
} }
await exec("/usr/sbin/knotc zone-set " + config.config().higherLevelDomain + " " + domain + " 60 A " + ip); 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("/usr/sbin/knotc zone-commit " + config.config().higherLevelDomain);
} catch {
try {
await exec("/usr/sbin/knotc 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.");
}
}
} }
module.exports = { module.exports = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment