-
Notifications
You must be signed in to change notification settings - Fork 29
/
docker-entrypoint.sh
executable file
·58 lines (45 loc) · 1.32 KB
/
docker-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
#!/usr/bin/env bash
set -e
if [[ -n "${DEBUG}" ]]; then
set -x
fi
function _gotpl {
if [[ -f "/etc/gotpl/$1" ]]; then
gotpl "/etc/gotpl/$1" > "$2"
fi
}
init_varnish_secret() {
if [[ -z "${VARNISH_SECRET}" ]]; then
export VARNISH_SECRET=$(pwgen -s 128 1)
echo "Generated Varnish secret: ${VARNISH_SECRET}"
fi
echo -e "${VARNISH_SECRET}" > /etc/varnish/secret
}
init_purge_key() {
if [[ -z "${VARNISH_PURGE_KEY}" ]]; then
export VARNISH_PURGE_KEY=$(pwgen -s 64 1)
echo "Varnish purge key is missing. Generating random: ${VARNISH_PURGE_KEY}"
fi
}
process_templates() {
_gotpl 'varnishd.init.d.tmpl' '/etc/init.d/varnishd'
_gotpl 'default.vcl.tmpl' '/etc/varnish/default.vcl'
if [[ -n "${VARNISH_CONFIG_PRESET}" ]]; then
_gotpl "presets/${VARNISH_CONFIG_PRESET}.vcl.tmpl" '/etc/varnish/preset.vcl'
fi
for f in /etc/gotpl/defaults/*.tmpl; do
_gotpl "defaults/${f##*/}" "/etc/varnish/defaults/$(basename "${f%.tmpl}")";
done
for f in /etc/gotpl/includes/*.tmpl; do
_gotpl "includes/${f##*/}" "/etc/varnish/includes/$(basename "${f%.tmpl}")";
done
}
init_varnish_secret
init_purge_key
process_templates
exec_init_scripts
if [[ "${1}" == "make" ]]; then
exec "${@}" -f /usr/local/bin/actions.mk
else
exec $@
fi