-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·68 lines (49 loc) · 1.47 KB
/
setup.sh
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
#!/bin/bash
NGINXCONF="/etc/nginx/nginx.conf"
NGINXSERVICE="/lib/systemd/system/nginx.service"
# Quit if not running as root
if (( $EUID != 0 )); then
echo -e '\e[1mYou MUST run this setup script as root\e[0m'
exit 1
else
echo -e '\e[1mInstalling livestream setup\e[0m'
fi
# LIVESTREAM
if [ ! -d /root/bin ]; then
mkdir /root/bin
fi
cp -f livestream/livestream.sh /root/bin/
chmod 0500 /root/bin/livestream.sh
# NGINX
echo -e '\e[1mUpdating package list\e[0m'
apt-get update
echo -e '\e[1mInstalling nginx, libnginx-mod-rtmp, and ffmpeg\e[0m'
apt install -y nginx libnginx-mod-rtmp ffmpeg
read -p 'Enter Twitch stream key: ' twitchkey
if [ -z $twitchkey ]; then
echo -e '\e[1mYou did not enter a stream key, so quitting. Bye!\e[0m'
exit 1
fi
echo -e '\e[1mInstalling new nginx.conf\e[0m'
if [ -f $NGINXCONF ]; then
echo -e '\e[1mBacking up existing nginx.conf to nginx.conf.orig\e[0m'
mv $NGINXCONF $NGINXCONF.orig
fi
sed "s/MY_STREAM_KEY/$twitchkey/" nginx/nginx.conf > $NGINXCONF
# Enable nginx service
cp -f nginx/nginx.service $NGINXSERVICE
# LIVESTREAM SERVICE
echo -e '\e[1mInstalling stream service\e[0m'
cp -f livestream/livestream.service /etc/systemd/system/
# SERVICES
systemctl daemon-reload
systemctl enable nginx
systemctl enable livestream
# DONE
echo -e '\e[1mFINISHED with install\e[0m'
read -p 'Do you want to reboot now? [y/n]: ' do_reboot
if [ $do_reboot = 'y' ]; then
echo -e '\e[1mRebooting now!\e[0m'
reboot
fi
exit 0