From dc548b7f08fb8ed7b4efd25657e0b280834b942e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=BE=D0=BD=D1=8B=D1=88=D0=B5=D0=B2?= Date: Thu, 30 Mar 2023 15:16:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=BE=D1=87=D1=82=D1=8B=20=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profiles/templates/mastodon/mastodon/ini.env | 2 +- scripts/mastodon/stages/3-config.sh | 3 ++- scripts/mastodon/stages/4-migrate.sh | 28 ++++++-------------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/profiles/templates/mastodon/mastodon/ini.env b/profiles/templates/mastodon/mastodon/ini.env index d36b147..a6ceda0 100644 --- a/profiles/templates/mastodon/mastodon/ini.env +++ b/profiles/templates/mastodon/mastodon/ini.env @@ -6,7 +6,7 @@ node=16.18.0 git_tag=4.1.1 ruby=3.0.4 login=owner -smtp_from_address=Mastodon +smtp_from_address=support@calculate.ru smtp_login= smtp_password= smtp_port=465 diff --git a/scripts/mastodon/stages/3-config.sh b/scripts/mastodon/stages/3-config.sh index 1c5a9dc..2a76fa9 100755 --- a/scripts/mastodon/stages/3-config.sh +++ b/scripts/mastodon/stages/3-config.sh @@ -27,8 +27,9 @@ replace=( LOCAL_DOMAIN "${ini[mastodon.local_domain]}" DB_USER "${ini[postgresql.mastodon_user]}" DB_PASS "${ini[postgresql.mastodon_password]}" - SMTP_FROM_ADDRESS "${ini[mastodon.smtp_from_address]}" + SMTP_FROM_ADDRESS "Mastodon <${ini[mastodon.smtp_from_address]}>" SMTP_PORT "${ini[mastodon.smtp_port]}" + SMTP_SERVER "${ini[mastodon.smtp_server]}" ) configure_conf live/.env.production diff --git a/scripts/mastodon/stages/4-migrate.sh b/scripts/mastodon/stages/4-migrate.sh index cb1c3ec..1161348 100755 --- a/scripts/mastodon/stages/4-migrate.sh +++ b/scripts/mastodon/stages/4-migrate.sh @@ -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