@ -1,12 +1,12 @@
#!/bin/bash
#set -ueo pipefail
set -ueo pipefail
export PATH = " /lib/rc/bin: $PATH "
SCRIPT = $( readlink -f $0 )
[ [ $UID = = 0 ] ] && exec su - mastodon -c " $SCRIPT "
. /var/db/repos/container/scripts/functions.sh
. /var/db/repos/calculate/scripts/ini.sh
@ -18,7 +18,8 @@ eval "$(rbenv init -)"
cd ~/live
get_variables( ) {
if ! [ " $( PGPASSWORD = ${ ini [postgresql.postgres_password] } psql -U postgres -XtAc " SELECT 1 FROM pg_database WHERE datname=' ${ ini [postgresql.mastodon_database] } ' " ) " = '1' ]
then
SECRET_KEY_BASE = $( RAILS_ENV = production bundle exec rake secret)
OTP_SECRET = $( RAILS_ENV = production bundle exec rake secret)
vapid_array = ( $( RAILS_ENV = production bundle exec rake mastodon:webpush:generate_vapid_key) )
@ -29,9 +30,7 @@ get_variables(){
sed -i -E " s|(OTP_SECRET=).*|\1 ${ OTP_SECRET } |g " ~/live/.env.production
sed -i -E " s|(VAPID_PRIVATE_KEY=).*|\1 ${ VAPID_PRIVATE_KEY } |g " ~/live/.env.production
sed -i -E " s|(VAPID_PUBLIC_KEY=).*|\1 ${ VAPID_PUBLIC_KEY } |g " ~/live/.env.production
}
migrate_pgsql( ) {
RAILS_ENV = production bundle exec rake db:setup
RAILS_ENV = production bundle exec rake assets:precompile
RAILS_ENV = production bin/tootctl accounts create ${ ini [mastodon.login] } \
@ -40,17 +39,6 @@ migrate_pgsql(){
einfo Mail: ${ ini [mastodon.smtp_from_address] }
einfo Login: ${ ini [mastodon.login] }
}
check_migrate( ) {
data = $( RAILS_ENV = production bundle exec rake db:migrate:status 2>/dev/null)
}
data = { :-}
#if [[ -z $data ]]; then
get_variables
migrate_pgsql
#else
check_migrate
#fi
else
RAILS_ENV = production bundle exec rake db:migrate:status
fi