diff --git a/docker-compose.yml b/docker-compose.yml index ecba4bf3..283cf059 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -111,7 +111,7 @@ services: nginx: # build: ./nginx # image: registry.vathes.com/ibl-navigator/nginx:v0.0-dev5 - image: registry.vathes.com/ibl-navigator/nginx:v0.0-public3 # for public deploy ? + image: registry.vathes.com/ibl-navigator/nginx:v0.0-public4 # for public deploy ? environment: # - URL=datajoint.io # for testdev deploy # - SUBDOMAINS=testdev # for testdev deploy diff --git a/nginx/entrypoint.sh b/nginx/entrypoint.sh index c444c52f..57ef6282 100644 --- a/nginx/entrypoint.sh +++ b/nginx/entrypoint.sh @@ -30,10 +30,18 @@ echo "[$(date -u '+%Y-%m-%d %H:%M:%S')][DataJoint]: Enabling SSL feature" mv /ssl.conf /etc/nginx/conf.d/ssl.conf update_cert -inotifywait -m /etc/letsencrypt/live/${SUBDOMAINS}.${URL} | - while read path action file; do - if [ "$(echo $action | grep MODIFY)" ] || [ "$(echo $action | grep CREATE)" ] || [ "$(echo $action | grep MOVE)" ]; then - echo "[$(date -u '+%Y-%m-%d %H:%M:%S')][DataJoint]: Renewal: Reloading NGINX since \`$file\` issue \`$action\` event" - update_cert - fi - done \ No newline at end of file +INIT_TIME=$(date +%s) +LAST_MOD_TIME=$(date -r $(echo /etc/letsencrypt/live/${SUBDOMAINS}.${URL}/$(ls -t /etc/letsencrypt/live/${SUBDOMAINS}.${URL}/ | head -n 1)) +%s) +DELTA=$(expr $LAST_MOD_TIME - $INIT_TIME) +while true; do + CURR_FILEPATH=$(ls -t /etc/letsencrypt/live/${SUBDOMAINS}.${URL}/ | head -n 1) + CURR_LAST_MOD_TIME=$(date -r $(echo /etc/letsencrypt/live/${SUBDOMAINS}.${URL}/${CURR_FILEPATH}) +%s) + CURR_DELTA=$(expr $CURR_LAST_MOD_TIME - $INIT_TIME) + if [ "$DELTA" -lt "$CURR_DELTA" ]; then + echo "[$(date -u '+%Y-%m-%d %H:%M:%S')][DataJoint]: Renewal: Reloading NGINX since \`$CURR_FILEPATH\` changed." + update_cert + DELTA=$CURR_DELTA + else + sleep 5 + fi +done \ No newline at end of file