mirror of
https://github.com/thelounge/thelounge.git
synced 2024-05-06 08:23:19 +02:00
d7bba325a7
User files contain secrets and should be protected. Chances are that the user folder can be protected as well, so let's do that if TL is creating the folder.
36 lines
985 B
JavaScript
36 lines
985 B
JavaScript
"use strict";
|
|
|
|
const log = require("../log");
|
|
const colors = require("chalk");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const program = require("commander");
|
|
const Helper = require("../helper");
|
|
const Utils = require("./utils");
|
|
|
|
program
|
|
.command("start")
|
|
.description("Start the server")
|
|
.option("--dev", "Development mode with hot module reloading")
|
|
.on("--help", Utils.extraHelp)
|
|
.action(function (options) {
|
|
initalizeConfig();
|
|
|
|
const server = require("../server");
|
|
server(options);
|
|
});
|
|
|
|
function initalizeConfig() {
|
|
if (!fs.existsSync(Helper.getConfigPath())) {
|
|
fs.mkdirSync(Helper.getHomePath(), {recursive: true});
|
|
fs.chmodSync(Helper.getHomePath(), "0700");
|
|
fs.copyFileSync(
|
|
path.resolve(path.join(__dirname, "..", "..", "defaults", "config.js")),
|
|
Helper.getConfigPath()
|
|
);
|
|
log.info(`Configuration file created at ${colors.green(Helper.getConfigPath())}.`);
|
|
}
|
|
|
|
fs.mkdirSync(Helper.getUsersPath(), {recursive: true, mode: 0o700});
|
|
}
|