-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·36 lines (26 loc) · 1.11 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
#!/bin/sh
cat /etc/envoy/envoy.yaml.tmpl | sed 's/TARGET_PORT/'"$TARGET_PORT"'/' | sed 's/TARGET_HOST/'"$TARGET_HOST"'/' | sed 's/LISTENER_PORT/'"$LISTENER_PORT"'/' | sed 's/WEBSOCKET_ENABLED/'"$WEBSOCKET_ENABLED"'/' > /etc/envoy/envoy.yaml
if expr "$TARGET_HOST" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then
echo "VALID IP, DO NOTHING"
else
echo "NOT AN IP, SETTING TYPE TO STRICT_DNS"
sed -i 's/STATIC/strict_dns/' /etc/envoy/envoy.yaml
fi
certHash=$(md5sum /etc/ssl/private/tls.crt)
keyHash=$(md5sum /etc/ssl/private/tls.key)
python /etc/envoy/hot-restart.py /etc/envoy/hot-restart.sh &
pythonPid=$(echo $!)
echo "Python process id: ${pythonPid}"
sleep ${REFRESH_INTERVAL}
while [ 1 ]
do
compareCertHash=$(md5sum /etc/ssl/private/tls.crt)
compareKeyHash=$(md5sum /etc/ssl/private/tls.key)
if [ "${certHash}" != "${compareCertHash}" ]; then
certHash=$(md5sum /etc/ssl/private/tls.crt)
keyHash=$(md5sum /etc/ssl/private/tls.key)
echo "$(date) SSL Cert has changed, update Envoy!"
kill -s SIGHUP $pythonPid
fi
sleep ${REFRESH_INTERVAL}
done