#!/bin/sh
set -e

bundle check || bundle install

# First boot: run the install generator the way a real host would. It creates
# the create_warp_engine_tables migration; --skip leaves our initializer alone.
if ! ls db/migrate/*create_warp_engine_tables* >/dev/null 2>&1; then
  bin/rails generate warp_engine:install --skip
fi

bin/rails db:prepare

rm -f tmp/pids/server.pid

exec "$@"
