might work now

This commit is contained in:
2019-12-09 01:15:23 -08:00
parent c7b081f5b9
commit 72a9dc7d78
11 changed files with 159 additions and 20 deletions

View File

@@ -5,18 +5,43 @@ echo "mastodon-startup starting up..."
if [[ ! -d /state/envdir ]]; then
mkdir -p /state/envdir
chown mastodon:mastodon /state/envdir
fi
if [[ ! -e /state/envdir/HOME ]]; then
echo "/mastodon" > /state/envdir/HOME
fi
if [[ ! -e /state/envdir/RAILS_ENV ]]; then
echo "production" > /state/envdir/RAILS_ENV
fi
chown mastodon:mastodon /state/envdir /state/envdir/*
cd /mastodon/app
if [ "$RUN_DB_MIGRATIONS" == "true" ]; then
if [[ ! -e /state/envdir/OTP_SECRET ]]; then
envdir /state/envdir \
chpst -u mastodon:mastodon \
bash -i -c "bundle exec rake secret > /state/envdir/OTP_SECRET"
fi
if [[ ! -e /state/envdir/SECRET_KEY_BASE ]]; then
envdir /state/envdir \
chpst -u mastodon:mastodon \
bash -i -c "bundle exec rake secret > /state/envdir/SECRET_KEY_BASE"
fi
echo "
create database mastodon_production;
create user mastodon createdb;
grant all privileges on database mastodon_production to mastodon;
" | chpst -u postgres:postgres psql
if [[ -n "$RUN_DB_MIGRATIONS" ]]; then
echo "Running database migrations..."
envdir /state/envdir chpst -u mastodon:mastodon bash -c "bundle exec rake db:migrate"
envdir /state/envdir \
chpst -u mastodon:mastodon \
bash -i -c "bundle exec rake db:migrate"
fi
rm /state/.starting