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
|
||||
site
|
||||
config/local.toml
|
||||
config/generated.toml
|
||||
install/db_setup.sql
|
||||
build/**
|
||||
lib/inspircd-*
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
saltRounds = 12
|
||||
|
||||
[satyr]
|
||||
name = ''
|
||||
domain = ''
|
||||
registration = false
|
||||
webFormat = 'hls'
|
||||
record = false
|
||||
restrictedNames = ['live','stream']
|
||||
|
||||
[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": {
|
||||
"start": "node build/controller.js",
|
||||
"build": "tsc",
|
||||
"user": "node build/cli.js"
|
||||
"user": "node build/cli.js",
|
||||
"setup": "sh install/setup.sh"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as db from "./database"
|
|||
import * as flags from "flags";
|
||||
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('remove', '', 'User to remove');
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import * as mediaserver from "./server";
|
||||
import * as ircd from "./ircd";
|
||||
import * as db from "./database";
|
||||
const config = require('config');
|
||||
import * as config from "config";
|
||||
|
||||
function run(): void{
|
||||
const dbcfg = config.database;
|
||||
const bcryptcfg = config.bcrypt;
|
||||
const dbcfg: object = config.database;
|
||||
const bcryptcfg: object = config.bcrypt;
|
||||
const satyr: object = {
|
||||
privateEndpoint: config.media.privateEndpoint,
|
||||
record: config.media.record,
|
||||
|
@ -47,9 +47,9 @@ function run(): void{
|
|||
}
|
||||
|
||||
};
|
||||
db.run(dbcfg, bcryptcfg);
|
||||
mediaserver.boot(nms, satyr);
|
||||
ircd.boot();
|
||||
db.init(dbcfg, bcryptcfg);
|
||||
mediaserver.init(nms, satyr);
|
||||
ircd.init();
|
||||
}
|
||||
run();
|
||||
export { run };
|
|
@ -5,7 +5,7 @@ import { resolve } from "url";
|
|||
var raw: any;
|
||||
var cryptoconfig: any;
|
||||
|
||||
function run (db: object, bcrypt: object){
|
||||
function init (db: object, bcrypt: object){
|
||||
raw = mysql.createPool(db);
|
||||
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";
|
||||
var ircd: child.ChildProcess;
|
||||
function boot():void{
|
||||
function init():void{
|
||||
ircd = child.execFile("./lib/inspircd-3.3.0/run/inspircd", ["restart"], (error, stdout, stderr) => {
|
||||
if (error){
|
||||
console.log("[IRCD] Failed to start Inspircd");
|
||||
|
@ -17,4 +17,4 @@ function reloadSSL():void{
|
|||
ircd.kill("SIGUSR1");
|
||||
}
|
||||
|
||||
export { boot, reloadSSL };
|
||||
export { init, reloadSSL };
|
|
@ -3,7 +3,7 @@ import { mkdir } from "fs";
|
|||
import * as db from "./database";
|
||||
const { exec } = require('child_process');
|
||||
|
||||
function boot (mediaconfig: any, satyrconfig: any) {
|
||||
function init (mediaconfig: any, satyrconfig: any) {
|
||||
const nms = new NodeMediaServer(mediaconfig);
|
||||
nms.run();
|
||||
|
||||
|
@ -95,4 +95,4 @@ function boot (mediaconfig: any, satyrconfig: any) {
|
|||
}
|
||||
});
|
||||
}
|
||||
export { boot };
|
||||
export { init };
|
|
@ -5,5 +5,5 @@
|
|||
},
|
||||
"include":[
|
||||
"src/**/*"
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue