From be55cb66c609b460249142aa7bda23e5de8c2d4b Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 29 Aug 2014 15:06:11 +1000 Subject: [PATCH] FIX: on bootup ensure correct shared structure --- templates/web.template.yml | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/templates/web.template.yml b/templates/web.template.yml index 4521bfe..7918e95 100644 --- a/templates/web.template.yml +++ b/templates/web.template.yml @@ -172,11 +172,32 @@ run: # move state out of the container this fancy is done to support rapid rebuilds of containers, # we store anacron and logrotate state outside the container to ensure its maintained across builds # later move this snipped into an intialization script - - exec: - cmd: - - rm -fr /var/lib/logrotate - - mkdir -p /shared/state/logrotate - - ln -s /shared/state/logrotate /var/lib/logrotate - - rm -fr /var/spool/anacron - - mkdir -p /shared/state/anacron-spool - - ln -s /shared/state/anacron-spool /var/spool/anacron + # we also ensure all the symlinks we need to /shared are in place in the correct structure + # this allows us to bootstrap on one machine and then run on another + - file: + path: /etc/runit/1.d/00-ensure-links + chmod: +x + contents: | + #!/bin/bash + if [[ ! -L /var/lib/logrotate ]]; then + rm -fr /var/lib/logrotate + mkdir -p /shared/state/logrotate + ln -s /shared/state/logrotate /var/lib/logrotate + fi + if [[ ! -L /var/spool/anacron ]]; then + rm -fr /var/spool/anacron + mkdir -p /shared/state/anacron-spool + ln -s /shared/state/anacron-spool /var/spool/anacron + fi + if [[ ! -d /shared/log/rails ]]; then + mkdir -p /shared/log/rails + chown -R discourse:www-data /shared/log/rails + fi + if [[ ! -d /shared/uploads ]]; then + mkdir -p /shared/uploads + chown -R discourse:www-data /shared/uploads + fi + if [[ ! -d /shared/backups ]]; then + mkdir -p /shared/backups + chown -R discourse:www-data /shared/backups + fi -- 2.25.1