-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·68 lines (57 loc) · 3.65 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·68 lines (57 loc) · 3.65 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
62
63
64
65
66
67
#!/bin/bash
# haproxy not directly configured within /usr/local/etc/haproxy/haproxy.cfg
if ! test -e /usr/local/etc/haproxy/haproxy.cfg; then
if [ ! -z "$DNS_ENABLED" ]; then
# Backends are resolved using internal or external DNS service
touch /etc/haproxy/dns.backends
python3 /configure.py dns
echo "*/${DNS_TTL:-1} * * * * /track_dns | logger " > /var/crontab.txt
else
if [ ! -z "$BACKENDS" ]; then
# Backend provided via $BACKENDS env
python3 /configure.py env
else
# Find backend within /etc/hosts
touch /etc/haproxy/hosts.backends
python3 /configure.py hosts
echo "*/${DNS_TTL:-1} * * * * /track_hosts | logger " > /var/crontab.txt
fi
fi
#add crontab
crontab /var/crontab.txt
chmod 600 /etc/crontab
#Add env variables for haproxy
echo "export PATH=$PATH"':$PATH' >> /etc/environment
if [ ! -z "$BACKENDS" ]; then echo "export BACKENDS=\"$BACKENDS\"" >> /etc/environment; fi
if [ ! -z "$BACKENDS_PORT" ]; then echo "export BACKENDS_PORT=\"$BACKENDS_PORT\"" >> /etc/environment; fi
if [ ! -z "$BACKENDS_MODE" ]; then echo "export BACKENDS_MODE=\"$BACKENDS_MODE\"" >> /etc/environment; fi
if [ ! -z "$BACKEND_NAME" ]; then echo "export BACKEND_NAME=\"$BACKEND_NAME\"" >> /etc/environment; fi
if [ ! -z "$BALANCE" ]; then echo "export BALANCE=\"$BALANCE\"" >> /etc/environment; fi
if [ ! -z "$COOKIES_ENABLED" ]; then echo "export COOKIES_ENABLED=\"$COOKIES_ENABLED\"" >> /etc/environment; fi
if [ ! -z "$COOKIES_PARAMS" ]; then echo "export COOKIES_PARAMS=\"$COOKIES_PARAMS\"" >> /etc/environment; fi
if [ ! -z "$DOWN_INTER" ]; then echo "export DOWN_INTER=\"$DOWN_INTER\"" >> /etc/environment; fi
if [ ! -z "$FALL" ]; then echo "export FALL=\"$FALL\"" >> /etc/environment; fi
if [ ! -z "$FAST_INTER" ]; then echo "export FAST_INTER=\"$FAST_INTER\"" >> /etc/environment; fi
if [ ! -z "$FRONTEND_NAME" ]; then echo "export FRONTEND_NAME=\"$FRONTEND_NAME\"" >> /etc/environment; fi
if [ ! -z "$FRONTEND_PORT" ]; then echo "export FRONTEND_PORT=\"$FRONTEND_PORT\"" >> /etc/environment; fi
if [ ! -z "$FRONTEND_MODE" ]; then echo "export FRONTEND_MODE=\"$FRONTEND_MODE\"" >> /etc/environment; fi
if [ ! -z "$HTTPCHK" ]; then echo "export HTTPCHK=\"$HTTPCHK\"" >> /etc/environment; fi
if [ ! -z "$INTER" ]; then echo "export INTER=\"$INTER\"" >> /etc/environment; fi
if [ ! -z "$LOGGING" ]; then echo "export LOGGING=\"$LOGGING\"" >> /etc/environment; fi
if [ ! -z "$LOG_LEVEL" ]; then echo "export LOG_LEVEL=\"$LOG_LEVEL\"" >> /etc/environment; fi
if [ ! -z "$PROXY_PROTOCOL_ENABLED" ]; then echo "export PROXY_PROTOCOL_ENABLED=\"$PROXY_PROTOCOL_ENABLED\"" >> /etc/environment; fi
if [ ! -z "$RISE" ]; then echo "export RISE=\"$RISE\"" >> /etc/environment; fi
if [ ! -z "$SERVICE_NAMES" ]; then echo "export SERVICE_NAMES=\"$SERVICE_NAMES\"" >> /etc/environment; fi
if [ ! -z "$STATS_AUTH" ]; then echo "export STATS_AUTH=\"$STATS_AUTH\"" >> /etc/environment; fi
if [ ! -z "$STATS_PORT" ]; then echo "export STATS_PORT=\"$STATS_PORT\"" >> /etc/environment; fi
if [ ! -z "$TIMEOUT_CLIENT" ]; then echo "export TIMEOUT_CLIENT=\"$TIMEOUT_CLIENT\"" >> /etc/environment; fi
if [ ! -z "$TIMEOUT_CONNECT" ]; then echo "export TIMEOUT_CONNECT=\"$TIMEOUT_CONNECT\"" >> /etc/environment; fi
if [ ! -z "$TIMEOUT_SERVER" ]; then echo "export TIMEOUT_SERVER=\"$TIMEOUT_SERVER\"" >> /etc/environment; fi
fi
# merge config file
python3 /append.py
#start logging
service rsyslog restart
#start crontab
service cron restart
exec /usr/local/bin/haproxy-entrypoint.sh "$@"