Skip to content

Commit b0b320f

Browse files
committed
Squashed commit of the following:
commit 0ea7b10 Author: Viktor Roytman <vr2262@columbia.edu> Date: Tue Dec 6 13:02:02 2016 -0500 Update version number to 0.0.4 commit 9cd9f87 Author: Viktor Roytman <vr2262@columbia.edu> Date: Tue Dec 6 13:01:50 2016 -0500 Modify cron command
1 parent cb217bb commit b0b320f

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

prod/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22
services:
33
minigrid:
4-
image: selcolumbia/minigrid-server:0.0.3
4+
image: selcolumbia/minigrid-server:0.0.4
55
command: ./prod/run.sh --db_host=db --redis_url=redis://redis:6379/0 --minigrid-website-url=https://www.example.com
66
depends_on:
77
- redis

prod/install.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env sh
2-
# Minigrid Server installer for version 0.0.3
2+
# Minigrid Server installer for version 0.0.4
33
set -e
44

55
# Do you have docker installed?
@@ -108,8 +108,8 @@ $SUDO openssl dhparam -out /etc/letsencrypt/live/$LETSENCRYPT_DIR/dhparam.pem 20
108108
printf "========================================\n"
109109
printf " Downloading configuration files \n"
110110
printf "========================================\n"
111-
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/minigrid-server/0.0.3/prod/docker-compose.yml > docker-compose.yml
112-
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/minigrid-server/0.0.3/prod/nginx.conf > nginx.conf
111+
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/minigrid-server/0.0.4/prod/docker-compose.yml > docker-compose.yml
112+
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/minigrid-server/0.0.4/prod/nginx.conf > nginx.conf
113113

114114
sed -i s/www.example.com/$LETSENCRYPT_DIR/g docker-compose.yml
115115
sed -i s/www.example.com/$LETSENCRYPT_DIR/g nginx.conf
@@ -133,7 +133,19 @@ printf "========================================\n"
133133
printf " Adding twice-daily cron job to renew \n"
134134
printf " SSL certificate. \n"
135135
printf "========================================\n"
136-
CRON_CMD="mkdir -p /tmp/letsencrypt && docker run -it --rm --name certbot -v /etc/letsencrypt:/etc/letsencrypt:Z -v /var/lib/letsencrypt:/var/lib/letsencrypt:Z -v /tmp/letsencrypt:/tmp/letsencrypt:Z -v /var/log/letsencrypt:/var/log/letsencrypt:Z quay.io/letsencrypt/letsencrypt --renew certonly --webroot -w /tmp/letsencrypt $DOMAIN_ARGS && docker restart $NGINX_CONTAINER_NAME"
137-
CRON_JOB="07 01,13 * * * $CRON_CMD"
136+
# The --post-hook should just be docker restart $NGINX_CONTAINER_NAME... but
137+
# the container can't run the docker command properly.
138+
# So /tmp/renewed serves as a sentinel
139+
CRON_CMD="mkdir -p /tmp/letsencrypt && "\
140+
"docker run -it --rm --name certbot"\
141+
" -v /etc/letsencrypt:/etc/letsencrypt:Z"\
142+
" -v /var/lib/letsencrypt:/var/lib/letsencrypt:Z"\
143+
" -v /tmp:/tmp:Z"\
144+
" -v /var/log/letsencrypt:/var/log/letsencrypt:Z"\
145+
" quay.io/letsencrypt/letsencrypt renew --quiet --post-hook 'touch /tmp/renewed' ; "\
146+
"if [ -f /tmp/renewed ] ; then docker restart $NGINX_CONTAINER_NAME ; fi ; "\
147+
"rm -f /tmp/renewed"
148+
# https://certbot.eff.org/#ubuntuxenial-nginx recommends running this twice a day on random minute within the hour
149+
CRON_JOB="00 01,13 * * * sleep $(expr $RANDOM \% 59); $CRON_CMD"
138150
crontab -l | fgrep -i -v "$CRON_CMD" | { cat; echo "$CRON_JOB"; } | crontab -
139151
crontab -l

0 commit comments

Comments
 (0)