mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
simplistic detect can't write settings and set readOnly flag
This commit is contained in:
parent
3f41036919
commit
c256e27a83
16
red.js
16
red.js
@ -31,6 +31,7 @@ var app = express();
|
|||||||
|
|
||||||
var settingsFile;
|
var settingsFile;
|
||||||
var flowFile;
|
var flowFile;
|
||||||
|
var readonly;
|
||||||
|
|
||||||
var knownOpts = {
|
var knownOpts = {
|
||||||
"credentialSecret": String,
|
"credentialSecret": String,
|
||||||
@ -105,8 +106,15 @@ if (parsedArgs.settings) {
|
|||||||
var settingsStat = fs.statSync(defaultSettings);
|
var settingsStat = fs.statSync(defaultSettings);
|
||||||
if (settingsStat.mtime.getTime() <= settingsStat.ctime.getTime()) {
|
if (settingsStat.mtime.getTime() <= settingsStat.ctime.getTime()) {
|
||||||
// Default settings file has not been modified - safe to copy
|
// Default settings file has not been modified - safe to copy
|
||||||
fs.copySync(defaultSettings,userSettingsFile);
|
try {
|
||||||
settingsFile = userSettingsFile;
|
fs.copySync(defaultSettings,userSettingsFile);
|
||||||
|
settingsFile = userSettingsFile;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log("Can't copy settings file.");
|
||||||
|
settingsFile = defaultSettings;
|
||||||
|
readonly = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Use default settings.js as it has been modified
|
// Use default settings.js as it has been modified
|
||||||
settingsFile = defaultSettings;
|
settingsFile = defaultSettings;
|
||||||
@ -118,6 +126,10 @@ if (parsedArgs.settings) {
|
|||||||
try {
|
try {
|
||||||
var settings = require(settingsFile);
|
var settings = require(settingsFile);
|
||||||
settings.settingsFile = settingsFile;
|
settings.settingsFile = settingsFile;
|
||||||
|
if (readonly === true) {
|
||||||
|
console.log("Setting to read Only mode.");
|
||||||
|
settings.readOnly = true;
|
||||||
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.log("Error loading settings file: "+settingsFile)
|
console.log("Error loading settings file: "+settingsFile)
|
||||||
if (err.code == 'MODULE_NOT_FOUND') {
|
if (err.code == 'MODULE_NOT_FOUND') {
|
||||||
|
Loading…
Reference in New Issue
Block a user