-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.sh
executable file
·76 lines (64 loc) · 2.41 KB
/
run.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
if [ "$ERROR_URL" != "" ]; then
cat <<ERR > /etc/rancher-conf/haproxy/500.http
HTTP/1.0 500 Internal Server Error
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html>
<head><script>window.location = "${ERROR_URL}?href=" + encodeURIComponent(window.location.href)</script></head>
</html>
ERR
cat <<ERR > /etc/rancher-conf/haproxy/502.http
HTTP/1.0 502 Bad Gateway
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html>
<head><script>window.location = "${ERROR_URL}?href=" + encodeURIComponent(window.location.href)</script></head>
</html>
ERR
cat <<ERR > /etc/rancher-conf/haproxy/503.http
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html>
<head><script>window.location = "${ERROR_URL}?href=" + encodeURIComponent(window.location.href)</script></head>
</html>
ERR
cat <<ERR > /etc/rancher-conf/haproxy/504.http
HTTP/1.0 504 Gateway Timeout
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html>
<head><script>window.location = "${ERROR_URL}?href=" + encodeURIComponent(window.location.href)</script></head>
</html>
ERR
else
wget -O /etc/rancher-conf/haproxy/500.http https://raw.githubusercontent.com/Jonathan-Rosewood/haproxy-custom-errors/master/500.http
wget -O /etc/rancher-conf/haproxy/502.http https://raw.githubusercontent.com/Jonathan-Rosewood/haproxy-custom-errors/master/502.http
wget -O /etc/rancher-conf/haproxy/503.http https://raw.githubusercontent.com/Jonathan-Rosewood/haproxy-custom-errors/master/503.http
wget -O /etc/rancher-conf/haproxy/504.http https://raw.githubusercontent.com/Jonathan-Rosewood/haproxy-custom-errors/master/504.http
fi
if [ "$FALLBACK_URL" != "" ]; then
cat <<ERR > /etc/rancher-conf/haproxy/404.http
HTTP/1.0 404 Not Found
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html>
<head><script>window.location = "${FALLBACK_URL}?href=" + encodeURIComponent(window.location.href)</script></head>
</html>
ERR
else
wget -O /etc/rancher-conf/haproxy/404.http https://raw.githubusercontent.com/Jonathan-Rosewood/haproxy-custom-errors/master/503.http
sed -i 's/503/404/g' /etc/rancher-conf/haproxy/404.http
sed -i 's/Service Unavailable/Not Found/g' /etc/rancher-conf/haproxy/404.http
fi
while [ ! -e /etc/rancher-conf/haproxy/haproxy.cfg ]; do
echo "Waiting for HAProxy config"
sleep 2
done
exec /usr/local/sbin/haproxy -W -f /etc/rancher-conf/haproxy/haproxy.cfg