Changed init functions to be more consistent.
Added setup script and templates for config and database setup. Fixed typo in tsconfig.merge-requests/1/merge
parent
d1cd2815e4
commit
085dd02148
|
@ -1,5 +1,7 @@
|
||||||
node_modules
|
node_modules
|
||||||
site
|
site
|
||||||
config/local.toml
|
config/local.toml
|
||||||
|
config/generated.toml
|
||||||
|
install/db_setup.sql
|
||||||
build/**
|
build/**
|
||||||
lib/inspircd-*
|
lib/inspircd-*
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
saltRounds = 12
|
saltRounds = 12
|
||||||
|
|
||||||
[satyr]
|
[satyr]
|
||||||
|
name = ''
|
||||||
|
domain = ''
|
||||||
registration = false
|
registration = false
|
||||||
webFormat = 'hls'
|
webFormat = 'hls'
|
||||||
record = false
|
|
||||||
restrictedNames = ['live','stream']
|
restrictedNames = ['live','stream']
|
||||||
|
|
||||||
[ircd]
|
[ircd]
|
||||||
|
|
11
db_setup.sql
11
db_setup.sql
|
@ -1,11 +0,0 @@
|
||||||
CREATE USER 'satyr'@'localhost' IDENTIFIED BY 'password';
|
|
||||||
CREATE DATABASE satyr_db;
|
|
||||||
GRANT ALL PRIVILEGES ON satyr_db.* TO 'satyr'@'localhost';
|
|
||||||
USE satyr_db;
|
|
||||||
CREATE TABLE users(
|
|
||||||
username VARCHAR(25),
|
|
||||||
password_hash BINARY(60),
|
|
||||||
stream_key CHAR(20),
|
|
||||||
record_flag TINYINT,
|
|
||||||
is_mod TINYINT
|
|
||||||
);
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
CREATE USER '<dbuser>'@'<dbclient>' IDENTIFIED BY '<dbpass>';
|
||||||
|
CREATE DATABASE <dbname>;
|
||||||
|
GRANT ALL PRIVILEGES ON <dbname>.* TO '<dbuser>'@'<dbclient>';
|
||||||
|
USE <dbname>;
|
||||||
|
CREATE TABLE users(
|
||||||
|
username VARCHAR(25),
|
||||||
|
password_hash BINARY(60),
|
||||||
|
stream_key CHAR(20),
|
||||||
|
record_flag TINYINT,
|
||||||
|
is_mod TINYINT
|
||||||
|
);
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/sh
|
||||||
|
echo "Please answer a few questions about your instance to get started."
|
||||||
|
echo "Default values are in brackets."
|
||||||
|
name=""
|
||||||
|
while [ -z "$name" ]
|
||||||
|
do
|
||||||
|
echo "Please enter a name for your instance.[]"
|
||||||
|
read name
|
||||||
|
done
|
||||||
|
domain=""
|
||||||
|
while [ -z "$domain" ]
|
||||||
|
do
|
||||||
|
echo "Please the domain name for your instance.[]"
|
||||||
|
read domain
|
||||||
|
done
|
||||||
|
echo "Please enter the path to the ffmpeg binary on your system.[$(which ffmpeg)]"
|
||||||
|
read ffmpeg
|
||||||
|
ffmpeg="${ffmpeg:=$(which ffmpeg)}"
|
||||||
|
echo "Please enter the user for the database.[satyr]"
|
||||||
|
read dbuser
|
||||||
|
dbuser="${dbuser:=satyr}"
|
||||||
|
echo "Please enter the password for the database.[autogenerated]"
|
||||||
|
read dbpassword
|
||||||
|
dbpassword="${dbpass:=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n 1)}"
|
||||||
|
echo "Please enter the name for the database.[satyr_db]"
|
||||||
|
read dbname
|
||||||
|
dbname="${dbname:=satyr_db}"
|
||||||
|
echo "Please enter the hostname for the database.[localhost]"
|
||||||
|
read dbhost
|
||||||
|
dbhost="${dbhost:=localhost}"
|
||||||
|
if [ "$dbhost" != "localhost" ]
|
||||||
|
then
|
||||||
|
echo "Please enter the ip this server will connect to the database with.[*]"
|
||||||
|
read dbclient
|
||||||
|
dbclient="${dbclient:='*'}"
|
||||||
|
else
|
||||||
|
dbclient="localhost"
|
||||||
|
fi
|
||||||
|
sed -e "s#<iname>#$name#g" -e "s#<domain>#$domain#g" -e "s#<ffmpeg>#$ffmpeg#g" -e "s#<dbuser>#$dbuser#g" -e "s#<dbname>#$dbname#g" -e "s#<dbpass>#$dbpass#g" -e "s#<dbhost>#$dbhost#g" install/template.local.toml > config/generated.toml
|
||||||
|
sed -e "s#<dbuser>#$dbuser#g" -e "s#<dbname>#$dbname#g" -e "s#<dbpass>#$dbpass#g" -e "s#<dbhost>#$dbhost#g" -e "s#<dbclient>#$dbclient#g" install/db_template.sql > install/db_setup.sql
|
||||||
|
echo "A setup script for the database has been generated at install/db_setup.sql. Please run it by connecting to your database software and executing 'source install/db_setup.sql;''"
|
||||||
|
echo "A default configuration file has been generated at config/generated.toml"
|
||||||
|
echo "If everything looks fine, move it to config/local.toml and start your instance."
|
|
@ -0,0 +1,15 @@
|
||||||
|
[satyr]
|
||||||
|
name = '<iname>'
|
||||||
|
domain = '<domain>'
|
||||||
|
registration = false
|
||||||
|
|
||||||
|
[media]
|
||||||
|
streamKeys = false
|
||||||
|
record = false
|
||||||
|
ffmpeg = '<ffmpeg>'
|
||||||
|
|
||||||
|
[database]
|
||||||
|
user = '<dbuser>'
|
||||||
|
password = '<dbpass>'
|
||||||
|
database = '<dbname>'
|
||||||
|
host = '<dbhost>'
|
|
@ -7,7 +7,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node build/controller.js",
|
"start": "node build/controller.js",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"user": "node build/cli.js"
|
"user": "node build/cli.js",
|
||||||
|
"setup": "sh install/setup.sh"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as db from "./database"
|
||||||
import * as flags from "flags";
|
import * as flags from "flags";
|
||||||
import * as config from "config"
|
import * as config from "config"
|
||||||
|
|
||||||
db.run(config.database, config.bcrypt);
|
db.init(config.database, config.bcrypt);
|
||||||
|
|
||||||
flags.defineString('add', '', 'User to add');
|
flags.defineString('add', '', 'User to add');
|
||||||
flags.defineString('remove', '', 'User to remove');
|
flags.defineString('remove', '', 'User to remove');
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import * as mediaserver from "./server";
|
import * as mediaserver from "./server";
|
||||||
import * as ircd from "./ircd";
|
import * as ircd from "./ircd";
|
||||||
import * as db from "./database";
|
import * as db from "./database";
|
||||||
const config = require('config');
|
import * as config from "config";
|
||||||
|
|
||||||
function run(): void{
|
function run(): void{
|
||||||
const dbcfg = config.database;
|
const dbcfg: object = config.database;
|
||||||
const bcryptcfg = config.bcrypt;
|
const bcryptcfg: object = config.bcrypt;
|
||||||
const satyr: object = {
|
const satyr: object = {
|
||||||
privateEndpoint: config.media.privateEndpoint,
|
privateEndpoint: config.media.privateEndpoint,
|
||||||
record: config.media.record,
|
record: config.media.record,
|
||||||
|
@ -47,9 +47,9 @@ function run(): void{
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
db.run(dbcfg, bcryptcfg);
|
db.init(dbcfg, bcryptcfg);
|
||||||
mediaserver.boot(nms, satyr);
|
mediaserver.init(nms, satyr);
|
||||||
ircd.boot();
|
ircd.init();
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
export { run };
|
export { run };
|
|
@ -5,7 +5,7 @@ import { resolve } from "url";
|
||||||
var raw: any;
|
var raw: any;
|
||||||
var cryptoconfig: any;
|
var cryptoconfig: any;
|
||||||
|
|
||||||
function run (db: object, bcrypt: object){
|
function init (db: object, bcrypt: object){
|
||||||
raw = mysql.createPool(db);
|
raw = mysql.createPool(db);
|
||||||
cryptoconfig = bcrypt;
|
cryptoconfig = bcrypt;
|
||||||
}
|
}
|
||||||
|
@ -63,4 +63,4 @@ async function validatePassword(username: string, password: string){
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { query, raw, run, addUser, rmUser, addStreamKey, rmStreamKey };
|
export { query, raw, init, addUser, rmUser, addStreamKey, rmStreamKey };
|
|
@ -1,6 +1,6 @@
|
||||||
import * as child from "child_process";
|
import * as child from "child_process";
|
||||||
var ircd: child.ChildProcess;
|
var ircd: child.ChildProcess;
|
||||||
function boot():void{
|
function init():void{
|
||||||
ircd = child.execFile("./lib/inspircd-3.3.0/run/inspircd", ["restart"], (error, stdout, stderr) => {
|
ircd = child.execFile("./lib/inspircd-3.3.0/run/inspircd", ["restart"], (error, stdout, stderr) => {
|
||||||
if (error){
|
if (error){
|
||||||
console.log("[IRCD] Failed to start Inspircd");
|
console.log("[IRCD] Failed to start Inspircd");
|
||||||
|
@ -17,4 +17,4 @@ function reloadSSL():void{
|
||||||
ircd.kill("SIGUSR1");
|
ircd.kill("SIGUSR1");
|
||||||
}
|
}
|
||||||
|
|
||||||
export { boot, reloadSSL };
|
export { init, reloadSSL };
|
|
@ -3,7 +3,7 @@ import { mkdir } from "fs";
|
||||||
import * as db from "./database";
|
import * as db from "./database";
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
|
|
||||||
function boot (mediaconfig: any, satyrconfig: any) {
|
function init (mediaconfig: any, satyrconfig: any) {
|
||||||
const nms = new NodeMediaServer(mediaconfig);
|
const nms = new NodeMediaServer(mediaconfig);
|
||||||
nms.run();
|
nms.run();
|
||||||
|
|
||||||
|
@ -95,4 +95,4 @@ function boot (mediaconfig: any, satyrconfig: any) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export { boot };
|
export { init };
|
|
@ -5,5 +5,5 @@
|
||||||
},
|
},
|
||||||
"include":[
|
"include":[
|
||||||
"src/**/*"
|
"src/**/*"
|
||||||
],
|
]
|
||||||
}
|
}
|
Reference in New Issue