#!/bin/sh
# if [ "x$(id -un)" != "xerrbit" ] ; then
#   echo "Please run this script as errbit user" 1>&2
#   exit 1
# fi
set -e
export RAILS_ENV="${RAILS_ENV:=production}"
# Make the app's vendored gems visible next to the system gems.
export GEM_HOME=/srv/www/vhosts/errbit/vendor/bundle/ruby/4.0.0
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.ruby4.0 exec rake errbit:bootstrap
chown -R errbit:errbit tmp/
chmod -R go+rX public/{assets,plugins,uploads}
touch tmp/restart.txt
rm -f tmp/rebuild.txt
