-
Notifications
You must be signed in to change notification settings - Fork 16
/
conf.sh
70 lines (59 loc) · 1.67 KB
/
conf.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
69
70
#!/bin/bash
for i in "$@"
do
case $i in
--secret=*)
RTMPSECRET="${i#*=}"
;;
--streams=*)
STREAMS="${i#*=}"
;;
*)
;;
esac
done
# STREAMS="push ${STREAMS//;/;\npush }"
echo "rtmp {
server {
listen 1935;
chunk_size 4000;
application $RTMPSECRET {
live on;" > /usr/local/nginx/conf/nginx.conf
IFS=';' #setting comma as delimiter
read -a streamarr <<<"$STREAMS"
for stream in "${streamarr[@]}"
do
echo "push $stream;" >> /usr/local/nginx/conf/nginx.conf
done
echo " }
}
}
events {}
http {
index index.sh;
server {
listen 443 ssl;
keepalive_timeout 70;
ssl_certificate /usr/local/nginx/fah.cert;
ssl_certificate_key /usr/local/nginx/fah.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
auth_basic 'Administrators Area';
auth_basic_user_file /usr/local/nginx/.htpasswd;
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.sock;
fastcgi_intercept_errors on;
include /usr/local/nginx/conf/fastcgi_params;
}
}
}" >> /usr/local/nginx/conf/nginx.conf
if [ -S /var/run/fcgiwrap.sock ]; then
/usr/local/nginx/sbin/nginx -s reload
else
openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "/C=US/ST=WA/L=REDMOND/O=Dis/CN=www.example.com" -keyout /usr/local/nginx/fah.key -out /usr/local/nginx/fah.cert
htpasswd -b -c /usr/local/nginx/.htpasswd admin $PASSWORD
spawn-fcgi -s /var/run/fcgiwrap.sock /usr/sbin/fcgiwrap
/usr/local/nginx/sbin/nginx -g 'daemon off;'
fi
exit 0