This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
65 lines (52 loc) · 2.09 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
#!/bin/sh
set -e
# 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/httpd/conf.d/unified-origin.conf.in > /etc/httpd/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/httpd/conf.d/remote_storage.conf.in > /etc/httpd/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_STORAGE_URL}}@${REMOTE_STORAGE_URL}@g; 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/httpd/conf.d/s3_auth.conf.in > /etc/httpd/conf.d/s3_auth.conf
fi
if [ $S3_ACCESS_KEY ] && [ $S3_SECRET_KEY ] && [ -z $S3_REGION ]
then
/bin/sed "s@{{REMOTE_STORAGE_URL}}@${REMOTE_STORAGE_URL}@g; 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}}@@g" /etc/httpd/conf.d/s3_auth.conf.in > /etc/httpd/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/httpd/conf.d/transcode.conf.in > /etc/httpd/conf.d/transcode.conf
fi
# USP license
echo $USP_LICENSE_KEY > /etc/usp-license.key
rm -f /run/httpd/httpd.pid
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- httpd "$@"
fi
exec "$@"