-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-entrypoint.sh
48 lines (35 loc) · 1007 Bytes
/
docker-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
#!/bin/bash
create_certs () {
# start nginx with certbot config
nginx -c /etc/nginx/nginx.certbot.conf
echo "Creating certificates..."
# ensure certificate
certbot certonly -a webroot --webroot-path=/var/www/html -d "$CERTBOT_DOMAIN" \
--agree-tos \
--email "$CERTBOT_EMAIL" \
--hsts \
--non-interactive
# move certificates
echo "Moving certificates..."
cp /etc/letsencrypt/live/$CERTBOT_DOMAIN/fullchain.pem /home/ssl/fullchain.pem
cp /etc/letsencrypt/live/$CERTBOT_DOMAIN/privkey.pem /home/ssl/privkey.pem
# stop
service nginx stop
}
create_diffie () {
echo "Creating Diffie..."
openssl dhparam -out /home/ssl/dhparams.pem 2048
}
if [ ! -f "/home/ssl/fullchain.pem" ]; then
create_certs
fi
if [ ! -f "/home/ssl/privkey.pem" ]; then
create_certs
fi
if [ ! -f "/home/ssl/dhparams.pem" ]; then
create_diffie
fi
# add cronjob
echo "Starting NGINX..."
# start nginx
nginx -c /etc/nginx/nginx.conf