From 63e2e039571010effaafdb515f90884a8f6a5766 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 23 Jun 2020 12:35:23 -0700 Subject: [PATCH] Fixed meshctrl.js config.json path search. --- meshctrl.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/meshctrl.js b/meshctrl.js index ffa92bd5..5eec08ab 100644 --- a/meshctrl.js +++ b/meshctrl.js @@ -451,10 +451,11 @@ function performConfigOperations(args) { if (fs.existsSync(configFile) == false) { configFile = path.join(__dirname, 'config.json'); } if (fs.existsSync(configFile) == false) { configFile = path.join(__dirname, 'meshcentral-data', 'config.json'); } if (fs.existsSync(configFile) == false) { configFile = path.join(__dirname, '..', 'meshcentral-data', 'config.json'); } + if (fs.existsSync(configFile) == false) { configFile = path.join(__dirname, '..', '..', 'meshcentral-data', 'config.json'); } if (fs.existsSync(configFile) == false) { console.log("Unable to find config.json."); return; } var config = null; - try { config = fs.readFileSync(configFile); } catch (ex) { console.log("Error: Unable to read config.json"); return; } - try { config = JSON.parse(config); } catch (ex) { console.log("Error: Unable to parse config.json"); return; } + try { config = fs.readFileSync(configFile).toString('utf8'); } catch (ex) { console.log("Error: Unable to read config.json"); return; } + try { config = require(configFile); } catch (e) { console.log('ERROR: Unable to parse ' + configFilePath + '.'); return null; } if (args.adddomain != null) { didSomething++; if (config.domains == null) { config.domains = {}; }