2016-10-09 19:14:02 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-09-09 11:12:23 +00:00
|
|
|
var ClientManager = new require("../clientManager");
|
|
|
|
var program = require("commander");
|
2016-12-15 06:13:43 +00:00
|
|
|
var colors = require("colors/safe");
|
2016-02-10 05:47:03 +00:00
|
|
|
var server = require("../server");
|
2014-10-01 15:59:35 +00:00
|
|
|
var Helper = require("../helper");
|
2014-09-09 11:12:23 +00:00
|
|
|
|
|
|
|
program
|
2016-12-15 06:29:44 +00:00
|
|
|
.command("start")
|
2017-02-18 03:23:01 +00:00
|
|
|
.option("-H, --host <ip>", "set the IP address or hostname for the web server to listen on")
|
|
|
|
.option("-P, --port <port>", "set the port to listen on")
|
|
|
|
.option("-B, --bind <ip>", "set the local IP to bind to for outgoing connections")
|
|
|
|
.option(" --public", "start in public mode")
|
|
|
|
.option(" --private", "start in private mode")
|
2014-09-09 11:12:23 +00:00
|
|
|
.description("Start the server")
|
2016-12-15 06:29:44 +00:00
|
|
|
.action(function(options) {
|
2014-09-09 11:12:23 +00:00
|
|
|
var users = new ClientManager().getUsers();
|
2016-06-08 09:26:24 +00:00
|
|
|
|
|
|
|
var mode = Helper.config.public;
|
2016-12-15 06:29:44 +00:00
|
|
|
if (options.public) {
|
2014-10-01 19:05:07 +00:00
|
|
|
mode = true;
|
2016-12-15 06:29:44 +00:00
|
|
|
} else if (options.private) {
|
2014-10-01 19:05:07 +00:00
|
|
|
mode = false;
|
|
|
|
}
|
2016-06-08 09:26:24 +00:00
|
|
|
|
2016-07-30 01:20:38 +00:00
|
|
|
if (!mode && !users.length && !Helper.config.ldap.enable) {
|
2016-12-15 06:13:43 +00:00
|
|
|
log.warn("No users found.");
|
|
|
|
log.info(`Create a new user with ${colors.bold("lounge add <name>")}.`);
|
2016-06-08 09:26:24 +00:00
|
|
|
|
|
|
|
return;
|
2014-09-09 11:12:23 +00:00
|
|
|
}
|
2016-06-08 09:26:24 +00:00
|
|
|
|
2016-12-15 06:29:44 +00:00
|
|
|
Helper.config.host = options.host || Helper.config.host;
|
|
|
|
Helper.config.port = options.port || Helper.config.port;
|
|
|
|
Helper.config.bind = options.bind || Helper.config.bind;
|
2016-06-08 09:26:24 +00:00
|
|
|
Helper.config.public = mode;
|
|
|
|
|
|
|
|
server();
|
2014-09-09 11:12:23 +00:00
|
|
|
});
|