forked from turnkeylinux-apps/avideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain
executable file
·109 lines (86 loc) · 3.9 KB
/
main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash -ex
WEBROOT=/var/www/youphptube
ENCROOT=/var/www/YouPHPTube-Encoder
SRC=/usr/local/src
# modify php configuration for YouPHPTube requirements
PHPINI=/etc/php/7.0/apache2/php.ini
sed -i "s|^memory_limit.*|memory_limit = 512M|" $PHPINI
sed -i "s|^upload_max_filesize.*|upload_max_filesize = 1000M|" $PHPINI
sed -i "s|^post_max_size.*|post_max_size = 1000M|" $PHPINI
sed -i "s|^allow_url_fopen.*|allow_url_fopen = On|" $PHPINI
sed -i "s|^max_execution.*|max_execution_time = 21600|" $PHPINI
# enable chat (via Apache TLS)
systemctl enable youphptube-streamchat.service
cat > /etc/apache2/mods-available/proxy.conf << EOF
<IfModule mod_proxy.c>
ProxyPass /wss/ ws://127.0.0.1:8888/
</IfModule>
EOF
# more Apache conf
a2dissite 000-default
a2ensite youphptube
a2ensite encoder
a2enmod proxy_wstunnel
a2enmod rewrite
# add encoder ports (http 81 & https 445) to apache ports.conf
ports_conf=/etc/apache2/ports.conf
sed -i "\|Listen 80|a Listen 81" $ports_conf
sed -i "\|Listen 443|a \\\tListen 445" $ports_conf
# clone repo and create required dirs
git clone --depth=1 https://github.com/DanielnetoDotCom/YouPHPTube.git $WEBROOT
mkdir $WEBROOT/videos
# clone encoder repo and create required dirs
git clone --depth=1 https://github.com/DanielnetoDotCom/YouPHPTube-Encoder $ENCROOT
mkdir $ENCROOT/videos
# Move Config File Into Place
mv $SRC/youphptube_configuration.php $WEBROOT/videos/configuration.php
mv $SRC/youphptubeencoder_configuration.php $ENCROOT/videos/configuration.php
# ensure correct permissions set on web directories
chown -R www-data:www-data $WEBROOT
chown -R www-data:www-data $ENCROOT
# enable remote video download
curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
chmod a+rx /usr/local/bin/youtube-dl
# install nginx rtmp module (and nginx itself) from backports & configure
# including stats
echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list
apt-get -y update
apt-get -y -t stretch-backports install libnginx-mod-rtmp
mv $SRC/nginx.conf /etc/nginx/nginx.conf
rm /etc/nginx/sites-enabled/default
URL=https://raw.githubusercontent.com/arut/nginx-rtmp-module/master
wget $URL/stat.xsl -O /var/www/html/stat.xsl
# Create Directories necessary for live stream
mkdir /HLS
mkdir /HLS/live
##---------------YouPHPTube-----------------##
service mysql start
# Execute YouPHPTube Create Database and Run Database Structure Script
MYSQL_BATCH="mysql --user=root --password=$MYSQL_PASS --batch"
MYSQL_BATCHDB="mysql --user=root --password=$MYSQL_PASS --database=yphptube --batch"
MYSQL_ADMIN="mysqladmin --user=root --password=$MYSQL_PASS"
# Execute YouPHPTubeEncoder Create Database and Run Database Structure Script
MYSQL_BATCH="mysql --user=root --password=$MYSQL_PASS --batch"
MYSQL_BATCHDB2="mysql --user=root --password=$MYSQL_PASS --database=encoder --batch"
MYSQL_ADMIN="mysqladmin --user=root --password=$MYSQL_PASS"
#Create Databases
$MYSQL_ADMIN create yphptube;
$MYSQL_ADMIN create encoder;
# Modify Database Generation Script For MariaDB Compatibility
# https://github.com/DanielnetoDotCom/YouPHPTube/issues/171
sed -i "61s|255|191|" $WEBROOT/install/database.sql
# Populate YouPHPTube database
$MYSQL_BATCHDB < $WEBROOT/install/database.sql
$MYSQL_BATCHDB < $SRC/populatedb/usersyphptube.sql
$MYSQL_BATCHDB < $SRC/populatedb/configurationsyphptube.sql
$MYSQL_BATCHDB < $SRC/populatedb/categoriesyphptube.sql
# Populate YouPHPTubeEncoder database
$MYSQL_BATCHDB2 < $ENCROOT/install/database.sql
$MYSQL_BATCHDB2 < $SRC/populatedb/configurationsyphptubeencoder.sql
$MYSQL_BATCHDB2 < $SRC/populatedb/streamersyphptubeencoder.sql
# tubepass is changed at firstboot non-interactively (Secure At First Boot)
$MYSQL_BATCH -e "grant all on yphptube.* to 'tubeuser'@localhost identified by 'tubepass';"
$MYSQL_BATCH -e "grant all on encoder.* to 'tubeuser'@localhost identified by 'tubepass';"
service mysql stop
# Purge Temp Files
rm -rf $SRC/populatedb