-
Notifications
You must be signed in to change notification settings - Fork 2
/
entry.sh
executable file
·60 lines (52 loc) · 1.5 KB
/
entry.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
#!/usr/bin/env bash
source /panubo-functions.sh
set -e
[[ "${DEBUG:-}" == 'true' ]] && set -x
# Defaults
export NGINX_SERVER_ROOT=${NGINX_SERVER_ROOT:='/var/www/html'}
export NGINX_SERVER_INDEX=${NGINX_SERVER_INDEX:='index.html index.htm'}
export NGINX_SINGLE_PAGE_ENABLED=${NGINX_SINGLE_PAGE_ENABLED:='false'}
export NGINX_SINGLE_PAGE_INDEX=${NGINX_SINGLE_PAGE_INDEX:-'index.html'}
export DEPLOYFILE_PRE=${DEPLOYFILE_PRE:-'/Deployfile.pre'}
export DEPLOYFILE_POST=${DEPLOYFILE_POST:-'/Deployfile.post'}
templater() {
echo "> Running templater"
/templater.sh
}
deployfile_pre() {
if [[ -f "${DEPLOYFILE_PRE}" ]] && [[ "${RUN_DEPLOYFILE_COMMANDS:-}" == 'true' ]]; then
echo "> Running all commands in ${DEPLOYFILE_PRE}"
run_all "${DEPLOYFILE_PRE}"
fi
}
echo "> Entrypoint command:" "${@}"
if [[ "${1}" == "s3sync" ]]; then
templater
deployfile_pre
echo "> Running s3sync"
/s3sync.sh
if [[ -f "${DEPLOYFILE_POST}" ]] && [[ "${RUN_DEPLOYFILE_COMMANDS:-}" == 'true' ]]; then
echo "> Running all commands in ${DEPLOYFILE_POST}"
run_all "${DEPLOYFILE_POST}"
fi
elif [[ "${1}" == "nginx" ]]; then
templater
deployfile_pre
echo "> Running nginx"
render_templates /etc/nginx/http.d/default.conf.tmpl
nginx
elif [[ "${1}" == "k8s-nginx" ]]; then
echo "> Running nginx"
nginx
elif [[ "${1}" == "k8s-init" ]]; then
echo "> Running Kubernetes template script"
/k8s-init.sh
exit
else
if [[ "$1" != "" ]]; then
exec "${@}"
else
echo "No command specified."
exit 127
fi
fi