forked from unifiedstreaming/live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·51 lines (40 loc) · 1.17 KB
/
entrypoint.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
#!/bin/sh
# set env vars to defaults if not already set
if [ -z "$LOG_LEVEL" ]
then
export LOG_LEVEL=warn
fi
if [ -z "$LOG_FORMAT" ]
then
export LOG_FORMAT="%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %D"
fi
# validate required variables are set
if [ -z "$USP_LICENSE_KEY" ]
then
echo >&2 "Error: USP_LICENSE_KEY environment variable is required but not set."
exit 1
fi
if [ -z "$CHANNEL" ]
then
echo >&2 "Error: CHANNEL environment variable is required but not set."
exit 1
fi
# update configuration based on env vars
/bin/sed "s/{{LOG_LEVEL}}/${LOG_LEVEL}/g; s/{{LOG_FORMAT}}/'${LOG_FORMAT}'/g" /etc/apache2/conf.d/unified-origin.conf.in > /etc/apache2/conf.d/unified-origin.conf
# USP license
echo $USP_LICENSE_KEY > /etc/usp-license.key
# create publishing point
if [ ! -f /var/www/live/$CHANNEL/$CHANNEL.isml ]
then
mkdir -p /var/www/live/$CHANNEL
chown -R apache:apache /var/www/live
mp4split --license-key=$USP_LICENSE_KEY \
-o /var/www/live/$CHANNEL/$CHANNEL.isml \
$PUB_POINT_OPTS
fi
rm -f /run/apache2/httpd.pid
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- httpd "$@"
fi
exec "$@"