This repository was archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstartup.sh
More file actions
executable file
·61 lines (51 loc) · 1.4 KB
/
startup.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.4 KB
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
#!/bin/sh
conf_dir=/tmp
src_dir=/tmp/src
cert_dir=/tmp/proxy-cert
mkdir ${src_dir} ${cert_dir}
log() {
if [ "${GAMEON_LOG_FORMAT}" == "json" ]; then
# This needs to be escaped using jq
echo '{"message":"'$@'"}'
else
echo $@
fi
}
log "using /tmp for config"
cp /etc/nginx/nginx.conf ${conf_dir}/nginx.conf
if [ -f /etc/cert/cert.pem ]; then
cp /etc/cert/cert.pem ${src_dir}/cert.pem
fi
if [ "$ETCDCTL_ENDPOINT" != "" ]; then
log "Setting up etcd..."
etcdctl --debug ls
RC=$?
while [ $RC -ne 0 ]; do
sleep 15
# recheck condition
log "** Re-testing etcd connection"
etcdctl --debug ls
RC=$?
done
log "etcdctl returned sucessfully, continuing"
etcdctl get /proxy/third-party-ssl-cert > ${src_dir}/cert.pem
fi
if [ -f ${src_dir}/cert.pem ]; then
old_dir=$PWD
cd ${cert_dir}
awk '/-----BEGIN.*PRIVATE KEY-----/{x=++i}{print > "something"x".pem"}' ${src_dir}/cert.pem
mv something.pem server.pem
mv something1.pem private.pem
cd $old_dir
fi
if [ ! -f ${cert_dir}/server.pem ] || [ ! -f ${cert_dir}/private.pem ] ; then
log "Unable to find certificate"
exit 1
fi
if [ "${GAMEON_LOG_FORMAT}" == "json" ]; then
sed -i -e "s/access\.log .*$/access.log json_combined;/" ${conf_dir}/nginx.conf
else
sed -i -e "s/access\.log .*$/access.log combined;/" ${conf_dir}/nginx.conf
fi
log "Init complete. Starting nginx"
exec nginx -c ${conf_dir}/nginx.conf