1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/glitchsoc_ynh.git synced 2024-09-03 19:15:59 +02:00
This commit is contained in:
yalh76 2020-05-26 13:50:52 +02:00
parent 5108846acb
commit d9cac4a31a

View file

@ -65,8 +65,8 @@ fi
# Check if admin is not null # Check if admin is not null
if [[ "$admin" = "" || "$language" = "" ]]; then if [[ "$admin" = "" || "$language" = "" ]]; then
echo "Unable to upgrade, please contact support" echo "Unable to upgrade, please contact support"
ynh_die ynh_die
fi fi
# If port_web doesn't exist, create it, need for old install # If port_web doesn't exist, create it, need for old install
@ -94,7 +94,7 @@ fi
if [[ -z "$paperclip_secret" ]]; then if [[ -z "$paperclip_secret" ]]; then
paperclip_secret=$(grep -oP "PAPERCLIP_SECRET=\K\w+" $config) paperclip_secret=$(grep -oP "PAPERCLIP_SECRET=\K\w+" $config)
if [[ -z "$paperclip_secret" ]]; then if [[ -z "$paperclip_secret" ]]; then
paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128)
fi fi
ynh_app_setting_set --app=$app --key=paperclip_secret --value="$paperclip_secret" ynh_app_setting_set --app=$app --key=paperclip_secret --value="$paperclip_secret"
fi fi
@ -103,7 +103,7 @@ fi
if [[ -z "$secret_key_base" ]]; then if [[ -z "$secret_key_base" ]]; then
secret_key_base=$(grep -oP "SECRET_KEY_BASE=\K\w+" $config) secret_key_base=$(grep -oP "SECRET_KEY_BASE=\K\w+" $config)
if [[ -z "$secret_key_base" ]]; then if [[ -z "$secret_key_base" ]]; then
secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128)
fi fi
ynh_app_setting_set --app=$app --key=secret_key_base --value="$secret_key_base" ynh_app_setting_set --app=$app --key=secret_key_base --value="$secret_key_base"
fi fi
@ -112,7 +112,7 @@ fi
if [[ -z "$otp_secret" ]]; then if [[ -z "$otp_secret" ]]; then
otp_secret=$(grep -oP "OTP_SECRET=\K\w+" $config) otp_secret=$(grep -oP "OTP_SECRET=\K\w+" $config)
if [[ -z "$otp_secret" ]]; then if [[ -z "$otp_secret" ]]; then
otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128)
fi fi
ynh_app_setting_set --app=$app --key=otp_secret --value="$otp_secret" ynh_app_setting_set --app=$app --key=otp_secret --value="$otp_secret"
fi fi
@ -172,30 +172,30 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --weight=14 ynh_script_progression --message="Upgrading source files..." --weight=14
# Download Mastodon # Download Mastodon
tmpdir="$(mktemp -d)" tmpdir="$(mktemp -d)"
mkdir $tmpdir/system mkdir $tmpdir/system
if [ -d "$final_path/live/public/system" ]; then if [ -d "$final_path/live/public/system" ]; then
rsync -a "$final_path/live/public/system" "$tmpdir/." rsync -a "$final_path/live/public/system" "$tmpdir/."
fi fi
rsync -a "$config" "$tmpdir/." rsync -a "$config" "$tmpdir/."
ynh_secure_remove --file="$final_path/live" ynh_secure_remove --file="$final_path/live"
ynh_setup_source --dest_dir="$final_path/live" ynh_setup_source --dest_dir="$final_path/live"
# Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 # Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292
ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock"
if [ -d "$tmpdir/system" ]; then if [ -d "$tmpdir/system" ]; then
rsync -a "$tmpdir/system" "$final_path/live/public/." rsync -a "$tmpdir/system" "$final_path/live/public/."
fi fi
rsync -a "$tmpdir/.env.production" "$final_path/live/." rsync -a "$tmpdir/.env.production" "$final_path/live/."
ynh_secure_remove --file="$tmpdir" ynh_secure_remove --file="$tmpdir"
# Clean files which are not needed anymore # Clean files which are not needed anymore
ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb" ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb"
fi fi
#================================================= #=================================================
@ -285,15 +285,15 @@ ynh_script_progression --message="Upgrading Mastodon..." --weight=2640
chown -R "$app": "$final_path" chown -R "$app": "$final_path"
pushd "$final_path/live" pushd "$final_path/live"
ynh_use_nodejs ynh_use_nodejs
bundle config deployment 'true' bundle config deployment 'true'
bundle config without 'development test' bundle config without 'development test'
bundle install -j$(getconf _NPROCESSORS_ONLN) bundle install -j$(getconf _NPROCESSORS_ONLN)
yarn install --pure-lockfile yarn install --pure-lockfile
RAILS_ENV=production bundle exec rails assets:clean RAILS_ENV=production bundle exec rails assets:clean
RAILS_ENV=production bundle exec rails assets:precompile RAILS_ENV=production bundle exec rails assets:precompile
RAILS_ENV=production bundle exec rails db:migrate RAILS_ENV=production bundle exec rails db:migrate
RAILS_ENV=production bin/tootctl cache clear RAILS_ENV=production bin/tootctl cache clear
popd popd
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.