Browse Source

init folders/files on first run

all-modes
pbca26 8 years ago
parent
commit
023bab4f2c
  1. 2
      main.js
  2. 20
      routes/shepherd.js

2
main.js

@ -43,6 +43,8 @@ if (os.platform() === 'linux') {
var shepherd = require('./routes/shepherd'),
guiapp = express();
shepherd.createIguanaDirs();
shepherd.writeLog('app init');
shepherd.writeLog('app info: ' + appBasicInfo.name + ' ' + appBasicInfo.version);
shepherd.writeLog('sys info:');

20
routes/shepherd.js

@ -24,7 +24,6 @@ var ps = require('ps-node'),
setconf = require('../private/setconf.js'),
//coincli = require('../private/coincli.js'),
assetChainPorts = require('./ports.js'),
md5 = require(),
shepherd = express.Router(),
iguanaInstanceRegistry = {},
syncOnlyIguanaInstanceInfo = {},
@ -92,9 +91,9 @@ shepherd.appConfig = {
},
"killIguanaOnStart": true,
"dev": false,
"v2": false,
"v2": true,
"forks": {
"basilisk": false,
"basilisk": true,
"all": false
}
};
@ -121,14 +120,20 @@ shepherd.writeLog = function(data) {
shepherd.createIguanaDirs = function() {
if (!fs.existsSync(iguanaDir)) {
fs.mkdirSync(iguanaDir);
shepherd.writeLog('creating iguana folder at ' + iguanaDir);
if (fs.existsSync(iguanaDir)) {
console.log('created iguana folder at ' + iguanaDir);
shepherd.writeLog('created iguana folder at ' + iguanaDir);
}
} else {
console.log('iguana folder already exists');
}
if (!fs.existsSync(iguanaDir + '/shepherd')) {
fs.mkdirSync(iguanaDir + '/shepherd');
shepherd.writeLog('creating shepherd folder at ' + iguanaDir + '/shepherd');
if (fs.existsSync(iguanaDir)) {
console.log('created shepherd folder at ' + iguanaDir + '/shepherd');
shepherd.writeLog('create shepherd folder at ' + iguanaDir + '/shepherd');
}
} else {
console.log('shepherd folder already exists');
}
@ -234,6 +239,9 @@ shepherd.post('/appconf', function(req, res, next) {
shepherd.saveLocalAppConf = function(appSettings) {
var appConfFileName = iguanaDir + '/config.json';
_fs.access(iguanaDir, fs.constants.R_OK, function(err) {
if (!err) {
var FixFilePermissions = function() {
return new Promise(function(resolve, reject) {
var result = 'config.json file permissions updated to Read/Write';
@ -275,6 +283,8 @@ shepherd.saveLocalAppConf = function(appSettings) {
FsWrite()
.then(FixFilePermissions());
}
});
}
shepherd.loadLocalConfig = function() {
if (fs.existsSync(iguanaDir + '/config.json')) {

Loading…
Cancel
Save