-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstart.bash
56 lines (42 loc) · 1.12 KB
/
start.bash
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
#!/bin/bash
#
# start.bash
#
[ -z "$ETCD_ADDR" ] && { echo "Need to set ETCD_ADDR"; exit 1; }
HAPROXY="/etc/haproxy"
CONFD="/etc/confd"
HAPROXY_OVERRIDE="/haproxy-override"
CONFD_OVERRIDE="/confd-override"
PIDFILE="/var/run/haproxy.pid"
CONFIG="haproxy.cfg"
ERRORS="errors"
CONF_D="conf.d"
TEMPLATES="templates"
ETCD_LOCATION="http://$ETCD_ADDR"
cd "$CONFD"
# Symlink conf.d directory
if [[ -d "$CONFD_OVERRIDE/$CONF_D" ]]; then
mkdir -p "$CONFD_OVERRIDE/$CONF_D"
rm -fr "$CONF_D"
ln -s "$CONFD_OVERRIDE/$CONF_D" "$CONF_D"
fi
# Symlink templates directory
if [[ -d "$CONFD_OVERRIDE/$TEMPLATES" ]]; then
mkdir -p "$CONFD_OVERRIDE/$TEMPLATES"
rm -fr "$TEMPLATES"
ln -s "$CONFD_OVERRIDE/$TEMPLATES" "$TEMPLATES"
fi
confd -node "$ETCD_LOCATION"
cd "$HAPROXY"
# Symlink errors directory
if [[ -d "$HAPROXY_OVERRIDE/$ERRORS" ]]; then
mkdir -p "$HAPROXY_OVERRIDE/$ERRORS"
rm -fr "$ERRORS"
ln -s "$HAPROXY_OVERRIDE/$ERRORS" "$ERRORS"
fi
# Symlink config file.
if [[ -f "$HAPROXY_OVERRIDE/$CONFIG" ]]; then
rm -f "$CONFIG"
ln -s "$HAPROXY_OVERRIDE/$CONFIG" "$CONFIG"
fi
haproxy -f /etc/haproxy/haproxy.cfg -p "$PIDFILE"