Fixed meshctrl.js config.json path search.

This commit is contained in:
Ylian Saint-Hilaire 2020-06-23 12:35:23 -07:00
parent 3de4a33d1c
commit 329b37c3a3

View File

@ -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 = {}; }