Changed init functions to be more consistent.

Added setup script and templates for config and database setup.
Fixed typo in tsconfig.
This commit is contained in:
knotteye
2019-09-26 14:43:24 -05:00
parent d1cd2815e4
commit 085dd02148
13 changed files with 90 additions and 28 deletions

11
install/db_template.sql Normal file
View File

@ -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
);

43
install/setup.sh Normal file
View File

@ -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."

View File

@ -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>'