|
@ -87,6 +87,49 @@ shepherd.appConfig = { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
shepherd.saveLocalAppConf = function(appSettings) { |
|
|
|
|
|
var appConfFileName = iguanaDir + '/config.json'; |
|
|
|
|
|
|
|
|
|
|
|
var FixFilePermissions = function() { |
|
|
|
|
|
return new Promise(function(resolve, reject) { |
|
|
|
|
|
var result = 'config.json file permissions updated to Read/Write'; |
|
|
|
|
|
|
|
|
|
|
|
fsnode.chmodSync(appConfFileName, '0666'); |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(function() { |
|
|
|
|
|
console.log(result); |
|
|
|
|
|
resolve(result); |
|
|
|
|
|
}, 1000); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var FsWrite = function() { |
|
|
|
|
|
return new Promise(function(resolve, reject) { |
|
|
|
|
|
var result = 'config.json write file is done' |
|
|
|
|
|
|
|
|
|
|
|
fs.writeFile(appConfFileName, |
|
|
|
|
|
JSON.stringify(appSettings) |
|
|
|
|
|
.replace(/,/g, ',\n') // format json in human readable form
|
|
|
|
|
|
.replace(/:/g, ': ') |
|
|
|
|
|
.replace(/{/g, '{\n') |
|
|
|
|
|
.replace(/}/g, '\n}'), 'utf8', function(err) { |
|
|
|
|
|
if (err) |
|
|
|
|
|
return console.log(err); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
fsnode.chmodSync(appConfFileName, '0666'); |
|
|
|
|
|
setTimeout(function() { |
|
|
|
|
|
console.log(result); |
|
|
|
|
|
console.log('app conf.json file is created successfully at: ' + iguanaConfsDir); |
|
|
|
|
|
resolve(result); |
|
|
|
|
|
}, 2000); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FsWrite() |
|
|
|
|
|
.then(FixFilePermissions()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
shepherd.loadLocalConfig = function() { |
|
|
shepherd.loadLocalConfig = function() { |
|
|
if (fs.existsSync(iguanaDir + '/config.json')) { |
|
|
if (fs.existsSync(iguanaDir + '/config.json')) { |
|
|
var localAppConfig = fs.readFileSync(iguanaDir + '/config.json', 'utf8'); |
|
|
var localAppConfig = fs.readFileSync(iguanaDir + '/config.json', 'utf8'); |
|
@ -106,6 +149,7 @@ shepherd.loadLocalConfig = function() { |
|
|
return result; |
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (localAppConfig) { |
|
|
var compareConfigs = compareJSON(shepherd.appConfig, JSON.parse(localAppConfig)); |
|
|
var compareConfigs = compareJSON(shepherd.appConfig, JSON.parse(localAppConfig)); |
|
|
if (Object.keys(compareConfigs).length) { |
|
|
if (Object.keys(compareConfigs).length) { |
|
|
var newConfig = Object.assign(JSON.parse(localAppConfig), compareConfigs); |
|
|
var newConfig = Object.assign(JSON.parse(localAppConfig), compareConfigs); |
|
@ -119,7 +163,9 @@ shepherd.loadLocalConfig = function() { |
|
|
} else { |
|
|
} else { |
|
|
return JSON.parse(localAppConfig); |
|
|
return JSON.parse(localAppConfig); |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
return shepherd.appConfig; |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
console.log('local config file is not found!'); |
|
|
console.log('local config file is not found!'); |
|
|
shepherd.saveLocalAppConf(shepherd.appConfig); |
|
|
shepherd.saveLocalAppConf(shepherd.appConfig); |
|
@ -722,49 +768,6 @@ function slayer(flock) { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
shepherd.saveLocalAppConf = function(appSettings) { |
|
|
|
|
|
var appConfFileName = iguanaDir + '/config.json'; |
|
|
|
|
|
|
|
|
|
|
|
var FixFilePermissions = function() { |
|
|
|
|
|
return new Promise(function(resolve, reject) { |
|
|
|
|
|
var result = 'config.json file permissions updated to Read/Write'; |
|
|
|
|
|
|
|
|
|
|
|
fsnode.chmodSync(appConfFileName, '0666'); |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(function() { |
|
|
|
|
|
console.log(result); |
|
|
|
|
|
resolve(result); |
|
|
|
|
|
}, 1000); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var FsWrite = function() { |
|
|
|
|
|
return new Promise(function(resolve, reject) { |
|
|
|
|
|
var result = 'config.json write file is done' |
|
|
|
|
|
|
|
|
|
|
|
fs.writeFile(appConfFileName, |
|
|
|
|
|
JSON.stringify(appSettings) |
|
|
|
|
|
.replace(/,/g, ',\n') // format json in human readable form
|
|
|
|
|
|
.replace(/:/g, ': ') |
|
|
|
|
|
.replace(/{/g, '{\n') |
|
|
|
|
|
.replace(/}/g, '\n}'), 'utf8', function(err) { |
|
|
|
|
|
if (err) |
|
|
|
|
|
return console.log(err); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
fsnode.chmodSync(appConfFileName, '0666'); |
|
|
|
|
|
setTimeout(function() { |
|
|
|
|
|
console.log(result); |
|
|
|
|
|
console.log('app conf.json file is created successfully at: ' + iguanaConfsDir); |
|
|
|
|
|
resolve(result); |
|
|
|
|
|
}, 2000); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FsWrite() |
|
|
|
|
|
.then(FixFilePermissions()); // not really required now
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setConf(flock) { |
|
|
function setConf(flock) { |
|
|
console.log(flock); |
|
|
console.log(flock); |
|
|
|
|
|
|
|
|