2016-10-09 15:14:02 -04:00
|
|
|
"use strict";
|
|
|
|
|
2014-09-09 07:12:23 -04:00
|
|
|
var ClientManager = new require("../clientManager");
|
|
|
|
var program = require("commander");
|
2016-12-15 01:13:43 -05:00
|
|
|
var colors = require("colors/safe");
|
2016-02-10 00:47:03 -05:00
|
|
|
var server = require("../server");
|
2014-10-01 11:59:35 -04:00
|
|
|
var Helper = require("../helper");
|
2014-09-09 07:12:23 -04:00
|
|
|
|
|
|
|
program
|
2016-12-15 01:29:44 -05:00
|
|
|
.command("start")
|
2017-02-17 22:23:01 -05: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 07:12:23 -04:00
|
|
|
.description("Start the server")
|
2016-12-15 01:29:44 -05:00
|
|
|
.action(function(options) {
|
2014-09-09 07:12:23 -04:00
|
|
|
var users = new ClientManager().getUsers();
|
2016-06-08 05:26:24 -04:00
|
|
|
|
|
|
|
var mode = Helper.config.public;
|
2016-12-15 01:29:44 -05:00
|
|
|
if (options.public) {
|
2014-10-01 15:05:07 -04:00
|
|
|
mode = true;
|
2016-12-15 01:29:44 -05:00
|
|
|
} else if (options.private) {
|
2014-10-01 15:05:07 -04:00
|
|
|
mode = false;
|
|
|
|
}
|
2016-06-08 05:26:24 -04:00
|
|
|
|
2016-07-29 21:20:38 -04:00
|
|
|
if (!mode && !users.length && !Helper.config.ldap.enable) {
|
2016-12-15 01:13:43 -05:00
|
|
|
log.warn("No users found.");
|
|
|
|
log.info(`Create a new user with ${colors.bold("lounge add <name>")}.`);
|
2016-06-08 05:26:24 -04:00
|
|
|
|
|
|
|
return;
|
2014-09-09 07:12:23 -04:00
|
|
|
}
|
2016-06-08 05:26:24 -04:00
|
|
|
|
2016-12-15 01:29:44 -05: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 05:26:24 -04:00
|
|
|
Helper.config.public = mode;
|
|
|
|
|
|
|
|
server();
|
2014-09-09 07:12:23 -04:00
|
|
|
});
|