ffffng/server/config.js

111 lines
2.7 KiB
JavaScript
Raw Normal View History

2014-05-12 20:08:19 +02:00
'use strict';
var commandLineArgs = require('command-line-args');
var commandLineUsage = require('command-line-usage');
var commandLineDefs = [
{ name: 'help', alias: 'h', type: Boolean, description: 'Show this help' },
{ name: 'config', alias: 'c', type: String, description: 'Location of config.json' }
];
var commandLineOptions;
try {
commandLineOptions = commandLineArgs(commandLineDefs);
} catch (e) {
console.error(e.message);
console.error('Try \'--help\' for more information.');
process.exit(1);
}
if (commandLineOptions.help || !commandLineOptions.config) {
console.log(commandLineUsage([
{
header: 'ffffng - Freifunk node management form',
optionList: commandLineDefs
}
]));
process.exit(1);
}
2016-05-20 22:38:13 +02:00
var fs = require('fs');
var deepExtend = require('deep-extend');
var defaultConfig = {
server: {
baseUrl: 'http://localhost:8080',
port: 8080,
databaseFile: '/tmp/ffffng.sqlite',
peersPath: '/tmp/peers',
2016-05-24 16:40:57 +02:00
logging: {
2016-05-24 19:14:09 +02:00
directory: '/tmp/logs',
debug: false,
logRequests: false
2016-05-24 16:40:57 +02:00
},
2016-05-24 19:40:02 +02:00
internal: {
active: false,
user: 'admin',
password: 'secret'
},
2016-05-20 22:38:13 +02:00
email: {
from: 'Freifunk Knotenformular <no-reply@musterstadt.freifunk.net>',
// For details see: https://nodemailer.com/2-0-0-beta/setup-smtp/
smtp: {
host: 'mail.example.com',
port: '465',
secure: true,
auth: {
user: 'user@example.com',
pass: 'pass'
}
}
},
map: {
nodesJsonUrl: 'http://map.musterstadt.freifunk.net/nodes.json'
2016-05-20 22:38:13 +02:00
}
},
client: {
community: {
name: 'Freifunk Musterstadt',
domain: 'musterstadt.freifunk.net',
contactEmail: 'kontakt@musterstadt.freifunk.net'
},
map: {
mapUrl: 'http://map.musterstadt.freifunk.net'
2014-06-06 21:22:57 +02:00
},
2016-05-20 22:38:13 +02:00
monitoring: {
2016-05-24 19:14:09 +02:00
enabled: false
2016-05-20 22:38:13 +02:00
},
coordsSelector: {
showInfo: false,
showBorderForDebugging: false,
localCommunityPolygon: [],
lat: 53.565278,
lng: 10.001389,
defaultZoom: 10
2014-06-06 21:22:57 +02:00
}
2016-05-20 22:38:13 +02:00
}
};
var configJSONFile = commandLineOptions.config;
2016-05-20 22:38:13 +02:00
var configJSON = {};
2016-05-20 22:38:13 +02:00
if (fs.existsSync(configJSONFile)) {
configJSON = JSON.parse(fs.readFileSync(configJSONFile, 'utf8'));
} else {
console.error('config.json not found: ' + configJSONFile);
process.exit(1);
2016-05-20 22:38:13 +02:00
}
var config = deepExtend({}, defaultConfig, configJSON);
module.exports = config;
2016-06-07 14:08:04 +02:00
angular.module('ffffng').constant('config', config);