forked from mjstealey/wordpress-nginx-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
letsencrypt-renew.sh
executable file
·55 lines (48 loc) · 1.22 KB
/
letsencrypt-renew.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
#!/usr/bin/env bash
# check to see where the script is being run from and set local variables
if [ -f .env ]; then
echo "INFO: running from top level of repository"
source .env
LE_DIR=$(pwd)/letsencrypt
else
if [ ! -f ../.env ]; then
echo "ERROR: Could not find the .env file?"
exit 1;
fi
echo "INFO: running from the letsencrypt directory"
source ../.env
LE_DIR=$(pwd)
cd ../
fi
REPO_DIR=$(dirname ${LE_DIR})
# get full directory path
if [ $(dirname ${SSL_CERTS_DIR}) = '.' ]; then
CERTS=$REPO_DIR${SSL_CERTS_DIR:1}
else
CERTS=${SSL_CERTS_DIR}
fi
if [ $(dirname ${SSL_CERTS_DATA_DIR}) = '.' ]; then
CERTS_DATA=$REPO_DIR${SSL_CERTS_DATA_DIR:1}
else
CERTS_DATA=${SSL_CERTS_DATA_DIR}
fi
# certs and certs-data directory expected to already exist and
# contain prior certificate information
if [ ! -d "${CERTS}" ]; then
echo "WARNING: no certs directory!"
exit 1;
fi
if [ ! -d "${CERTS_DATA}" ]; then
echo "WARNING: no certs-data directory!"
exit 1;
fi
docker run -t --rm \
-v ${CERTS}:/etc/letsencrypt \
-v ${CERTS_DATA}:/data/letsencrypt \
certbot/certbot \
renew \
--webroot --webroot-path=/data/letsencrypt
cd ${REPO_DIR}
docker-compose kill -s HUP nginx
cd ${LE_DIR}
exit 0;