Skip to content

Commit d6a460a

Browse files
authored
Merge pull request #18 from guzman-raphael/publicdemo
Fix auto certificate renewal
2 parents f814a34 + e220683 commit d6a460a

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ services:
111111
nginx:
112112
# build: ./nginx
113113
# image: registry.vathes.com/ibl-navigator/nginx:v0.0-dev5
114-
image: registry.vathes.com/ibl-navigator/nginx:v0.0-public3 # for public deploy ?
114+
image: registry.vathes.com/ibl-navigator/nginx:v0.0-public4 # for public deploy ?
115115
environment:
116116
# - URL=datajoint.io # for testdev deploy
117117
# - SUBDOMAINS=testdev # for testdev deploy

nginx/entrypoint.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,18 @@ echo "[$(date -u '+%Y-%m-%d %H:%M:%S')][DataJoint]: Enabling SSL feature"
3030
mv /ssl.conf /etc/nginx/conf.d/ssl.conf
3131
update_cert
3232

33-
inotifywait -m /etc/letsencrypt/live/${SUBDOMAINS}.${URL} |
34-
while read path action file; do
35-
if [ "$(echo $action | grep MODIFY)" ] || [ "$(echo $action | grep CREATE)" ] || [ "$(echo $action | grep MOVE)" ]; then
36-
echo "[$(date -u '+%Y-%m-%d %H:%M:%S')][DataJoint]: Renewal: Reloading NGINX since \`$file\` issue \`$action\` event"
37-
update_cert
38-
fi
39-
done
33+
INIT_TIME=$(date +%s)
34+
LAST_MOD_TIME=$(date -r $(echo /etc/letsencrypt/live/${SUBDOMAINS}.${URL}/$(ls -t /etc/letsencrypt/live/${SUBDOMAINS}.${URL}/ | head -n 1)) +%s)
35+
DELTA=$(expr $LAST_MOD_TIME - $INIT_TIME)
36+
while true; do
37+
CURR_FILEPATH=$(ls -t /etc/letsencrypt/live/${SUBDOMAINS}.${URL}/ | head -n 1)
38+
CURR_LAST_MOD_TIME=$(date -r $(echo /etc/letsencrypt/live/${SUBDOMAINS}.${URL}/${CURR_FILEPATH}) +%s)
39+
CURR_DELTA=$(expr $CURR_LAST_MOD_TIME - $INIT_TIME)
40+
if [ "$DELTA" -lt "$CURR_DELTA" ]; then
41+
echo "[$(date -u '+%Y-%m-%d %H:%M:%S')][DataJoint]: Renewal: Reloading NGINX since \`$CURR_FILEPATH\` changed."
42+
update_cert
43+
DELTA=$CURR_DELTA
44+
else
45+
sleep 5
46+
fi
47+
done

0 commit comments

Comments
 (0)