# 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