2019-12-08 06:50:36 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
touch /state/.starting
|
2019-12-09 11:55:55 +00:00
|
|
|
sleep 5
|
|
|
|
|
2019-12-08 06:50:36 +00:00
|
|
|
echo "mastodon-startup starting up..."
|
|
|
|
|
|
|
|
if [[ ! -d /state/envdir ]]; then
|
|
|
|
mkdir -p /state/envdir
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -e /state/envdir/HOME ]]; then
|
|
|
|
echo "/mastodon" > /state/envdir/HOME
|
|
|
|
fi
|
|
|
|
|
2019-12-09 09:15:23 +00:00
|
|
|
if [[ ! -e /state/envdir/RAILS_ENV ]]; then
|
|
|
|
echo "production" > /state/envdir/RAILS_ENV
|
|
|
|
fi
|
|
|
|
|
|
|
|
chown mastodon:mastodon /state/envdir /state/envdir/*
|
|
|
|
|
2019-12-08 06:50:36 +00:00
|
|
|
cd /mastodon/app
|
|
|
|
|
2019-12-09 09:15:23 +00:00
|
|
|
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
|
2019-12-08 06:50:36 +00:00
|
|
|
echo "Running database migrations..."
|
2019-12-09 09:15:23 +00:00
|
|
|
envdir /state/envdir \
|
|
|
|
chpst -u mastodon:mastodon \
|
|
|
|
bash -i -c "bundle exec rake db:migrate"
|
2019-12-08 06:50:36 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
rm /state/.starting
|
|
|
|
while true ; do
|
|
|
|
sleep 86400
|
|
|
|
done
|