forked from unifiedstreaming/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
70 lines (55 loc) · 2.15 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
set -e
# fix loading libxml2
/bin/sed "s@LoadFile /usr/lib/libxml2.so@LoadFile libxml2.so.2.8.0@g;" /etc/apache2/conf.d/proxy-html.conf > /etc/apache2/conf.d/proxy-html.conf
# 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
if [ -z "$REMOTE_PATH" ]
then
export REMOTE_PATH=remote
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
# update configuration based on env vars
# log levels
/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
# remote storage
if [ $REMOTE_STORAGE_URL ]
then
/bin/sed "s@{{REMOTE_PATH}}@${REMOTE_PATH}@g; s@{{REMOTE_STORAGE_URL}}@${REMOTE_STORAGE_URL}@g" /etc/apache2/conf.d/remote_storage.conf.in > /etc/apache2/conf.d/remote_storage.conf
fi
# s3 auth
if [ $S3_ACCESS_KEY ] && [ $S3_SECRET_KEY ] && [ $S3_REGION ]
then
S3_REGION="S3Region ${S3_REGION}"
/bin/sed "s@{{REMOTE_PATH}}@${REMOTE_PATH}@g; s@{{S3_ACCESS_KEY}}@${S3_ACCESS_KEY}@g; s@{{S3_SECRET_KEY}}@${S3_SECRET_KEY}@g; s@{{S3_REGION}}@${S3_REGION}@g" /etc/apache2/conf.d/s3_auth.conf.in > /etc/apache2/conf.d/s3_auth.conf
fi
# transcode
if [ $TRANSCODE_PATH ] && [ $TRANSCODE_URL ]
then
/bin/sed "s@{{TRANSCODE_PATH}}@${TRANSCODE_PATH}@g; s@{{TRANSCODE_URL}}@${TRANSCODE_URL}@g; s@{{REMOTE_STORAGE_URL}}@${REMOTE_STORAGE_URL}@g" /etc/apache2/conf.d/transcode.conf.in > /etc/apache2/conf.d/transcode.conf
fi
# remix catchup
if [ $REMIX_HOST ] && [ $REMIX_PORT ] && [ $CATCHUP_PATH ]
then
/bin/sed "s@{{REMIX_HOST}}@${REMIX_HOST}@g; s@{{REMIX_PORT}}@${REMIX_PORT}@g; s@{{CATCHUP_PATH}}@${CATCHUP_PATH}@g" /etc/apache2/conf.d/remix.conf.in > /etc/apache2/conf.d/remix.conf
fi
# USP license
echo $USP_LICENSE_KEY > /etc/usp-license.key
rm -f /run/apache2/httpd.pid
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- httpd "$@"
fi
exec "$@"