aboutsummaryrefslogtreecommitdiff
path: root/scripts/upgrade
diff options
context:
space:
mode:
authorTagada <36127788+Tagadda@users.noreply.github.com>2025-01-02 14:27:38 +0100
committerGitHub <noreply@github.com>2025-01-02 14:27:38 +0100
commit31c04e0d3ad88e7bac36aa61ac6f9b44fca141b0 (patch)
treeceaad486f2b5648d40d8940687fa22b75eb5abed /scripts/upgrade
parent8102fffa52a4e3279bba9fbdafb3a0e5b1fe3e17 (diff)
parent0595ab38e0e46f6e2b68a1404f3bb5ce8528a5d0 (diff)
downloadmastodon_ynh-31c04e0d3ad88e7bac36aa61ac6f9b44fca141b0.tar.gz
mastodon_ynh-31c04e0d3ad88e7bac36aa61ac6f9b44fca141b0.tar.bz2
mastodon_ynh-31c04e0d3ad88e7bac36aa61ac6f9b44fca141b0.zip
Merge pull request #478 from YunoHost-Apps/ci-auto-update-4.3.2
Upgrade to v4.3.2
Diffstat (limited to 'scripts/upgrade')
-rw-r--r--scripts/upgrade29
1 files changed, 22 insertions, 7 deletions
diff --git a/scripts/upgrade b/scripts/upgrade
index c889e65..f7a3573 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -102,8 +102,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
- # Download Mastodon
- ynh_setup_source --dest_dir="$install_dir/live" --keep="public/system/"
+ # Download, check integrity, uncompress and patch the source from manifest.toml
+ ynh_setup_source --dest_dir="$install_dir/live" --full_replace=1 --keep="public/system .env.production"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
@@ -124,9 +124,9 @@ pushd "$install_dir/live"
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config set force_ruby_platform true --quiet
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
ynh_use_nodejs
- ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile --production --network-timeout 600000
- ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:clean
- ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile
+ env $ynh_node_load_PATH corepack enable
+ echo Y | ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn workspaces focus --production
+ ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --immutable
popd
chown "$app:www-data" "$install_dir"
@@ -163,6 +163,21 @@ ynh_use_logrotate --non-append
#=================================================
ynh_script_progression --message="Updating a config file..." --weight=1
+if ynh_compare_current_package_version --comparison lt --version "4.3.2~ynh1"; then
+ pushd "$install_dir/live"
+ ynh_use_ruby
+ # Generate active record encryption
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:encryption:init > active_record_encryption.txt
+ active_record_encryption_deterministic_key=$(grep -oP "ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=\K.+" "$install_dir/live/active_record_encryption.txt")
+ ynh_app_setting_set --app="$app" --key=active_record_encryption_deterministic_key --value="$active_record_encryption_deterministic_key"
+ active_record_encryption_key_derivation_salt=$(grep -oP "ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=\K.+" "$install_dir/live/active_record_encryption.txt")
+ ynh_app_setting_set --app="$app" --key=active_record_encryption_key_derivation_salt --value="$active_record_encryption_key_derivation_salt"
+ active_record_encryption_primary_key=$(grep -oP "ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=\K.+" "$install_dir/live/active_record_encryption.txt")
+ ynh_app_setting_set --app="$app" --key=active_record_encryption_primary_key --value="$active_record_encryption_primary_key"
+ ynh_secure_remove --file="$install_dir/live/active_record_encryption.txt"
+ popd
+fi
+
language="$(echo $language | head -c 2)"
ynh_add_config --template=".env.production.sample" --destination="$config"
@@ -177,8 +192,8 @@ ynh_script_progression --message="Applying migrations..." --weight=1
pushd "$install_dir/live"
ynh_use_ruby
- ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:migrate
- ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl cache clear
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:migrate --quiet
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile --quiet
popd
#=================================================