-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
55 lines (41 loc) · 1.15 KB
/
entrypoint.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
#!/bin/sh
# ========================================================
echo "Starting nginx-certbot..."
set -e
# ========================================================
# Helper functions
# ========================================================
wait_nginx_start() {
while ! pgrep -l nginx | grep master >/dev/null; do
echo "Waiting for nginx to start..."
sleep 1
done
echo "nginx started."
}
wait_nginx_stop() {
echo "Waiting for nginx to stop..."
echo "Will use netstat to check if nginx is still running."
while netstat -tulnp | grep nginx >/dev/null; do
sleep 1
done
echo "nginx stopped."
}
# ========================================================
# Generate dh parameters for each domain.
/scripts/setup-dhparam.sh
# Start auto renewal service.
/scripts/renew-cert.sh &
# start nginx
nginx
wait_nginx_start
# Try obtaining certs.
/scripts/obtain-cert.sh
echo "Stopping nginx..."
# stop nginx and wait
nginx -s stop
wait_nginx_stop
# =================================================
# == Restart nginx with other entrypoint scripts ==
# =================================================
# start nginx
exec /docker-entrypoint.sh "$@"