#!/bin/sh
# runs as root: the application tree belongs to root and only the state
# directories below are handed to the errbit user
set -e
export RAILS_ENV="${RAILS_ENV:=production}"
cd /srv/www/vhosts/errbit/
test -e tmp/rebuild.txt || exit 0
# errbit is mongodb-based and has no ActiveRecord migrations; errbit:bootstrap
# (re)creates the mongo indexes and the initial admin user if missing.
/usr/bin/bundle.ruby3.4 exec rake errbit:bootstrap
# picked up by puma's tmp_restart plugin
touch tmp/restart.txt
chown -R errbit:errbit tmp/
chmod -R go+rX public/assets public/plugins public/uploads
rm -f tmp/rebuild.txt
