mirror of
https://github.com/YunoHost-Apps/weblate_ynh.git
synced 2024-10-01 13:35:04 +02:00
Add 3.1.1 upgrade with two steps upgrade
This commit is contained in:
parent
84c2ceb7a8
commit
ff2fda78db
3 changed files with 60 additions and 8 deletions
|
@ -27,7 +27,7 @@ from logging.handlers import SysLogHandler
|
||||||
# Django settings for Weblate project.
|
# Django settings for Weblate project.
|
||||||
#
|
#
|
||||||
|
|
||||||
DEBUG = FALSE
|
DEBUG = False
|
||||||
|
|
||||||
ADMINS = (
|
ADMINS = (
|
||||||
('__ADMIN__', '__ADMINMAIL__'),
|
('__ADMIN__', '__ADMINMAIL__'),
|
||||||
|
|
18
hooks/post_app_upgrade
Normal file
18
hooks/post_app_upgrade
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
migration311=$(yunohost app setting "$YNH_APP_INSTANCE_NAME" "migration311" --output-as plain --quiet)
|
||||||
|
mig_type=$(yunohost app setting "$YNH_APP_INSTANCE_NAME" "migration311_type" --output-as plain --quiet)
|
||||||
|
mig_parm=$(yunohost app setting "$YNH_APP_INSTANCE_NAME" "migration311_parm" --output-as plain --quiet)
|
||||||
|
|
||||||
|
if [[ "$migration311" = "two_steps_upgrade_3.0to3.1-needed" ]]
|
||||||
|
then
|
||||||
|
yunohost app setting "$YNH_APP_INSTANCE_NAME" "migration311" --value="two_steps_upgrade_3.0to3.1-progress" --quiet
|
||||||
|
if [ "$mig_type" = "file" ]
|
||||||
|
then
|
||||||
|
yunohost app upgrade "$YNH_APP_INSTANCE_NAME" --file "$mig_parm"
|
||||||
|
else
|
||||||
|
yunohost app upgrade "$YNH_APP_INSTANCE_NAME" --url "$mig_parm"
|
||||||
|
fi
|
||||||
|
|
||||||
|
yunohost app setting "$YNH_APP_INSTANCE_NAME" "migration311" --value="two_steps_upgrade_3.0to3.1-done" --quiet
|
||||||
|
fi
|
|
@ -26,6 +26,7 @@ admin=$(ynh_app_setting_get "$app" admin)
|
||||||
admin_mail=$(ynh_user_get_info "$admin" mail)
|
admin_mail=$(ynh_user_get_info "$admin" mail)
|
||||||
memc_port=$(ynh_app_setting_get "$app" memc_port)
|
memc_port=$(ynh_app_setting_get "$app" memc_port)
|
||||||
github_account=$(ynh_app_setting_get "$app" github_account)
|
github_account=$(ynh_app_setting_get "$app" github_account)
|
||||||
|
migration311=$(ynh_app_setting_get "$app" migration311)
|
||||||
key=$(ynh_string_random)
|
key=$(ynh_string_random)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -84,7 +85,7 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# (<2.20) remove your old sockets!
|
# (<2.20) remove your old sockets!
|
||||||
if [ -e "/etc/systemd/system/uwsgi-app@.socket" ]
|
if [ -e "/etc/systemd/system/uwsgi-app@$app.socket" ]
|
||||||
then
|
then
|
||||||
systemctl stop "uwsgi-app@$app.socket"
|
systemctl stop "uwsgi-app@$app.socket"
|
||||||
yunohost service remove "uwsgi-app@$app.socket"
|
yunohost service remove "uwsgi-app@$app.socket"
|
||||||
|
@ -104,6 +105,34 @@ then
|
||||||
ynh_secure_remove "$final_path/bin/"
|
ynh_secure_remove "$final_path/bin/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Weblate requires an update to 3.0 before 3.1
|
||||||
|
# the upgrade hook will launch this script again to make sure it works
|
||||||
|
if [[ -z "$migration311" ]]
|
||||||
|
then
|
||||||
|
# $migration311 is not set, version is <3.0
|
||||||
|
migration311="two_steps_upgrade_3.0to3.1-needed"
|
||||||
|
|
||||||
|
mig_type=$(cat "/etc/yunohost/apps/$YNH_APP_ID/status.json" | sed -e 's/.*"type":.*"\(.\+\)".*/\1/gi')
|
||||||
|
|
||||||
|
if [ "$mig_type" = "file" ]
|
||||||
|
then
|
||||||
|
mig_parm=$(cat "/etc/yunohost/apps/$YNH_APP_ID/status.json" | sed -e 's/.*"path": "\(.\+\)",.*/\1/gi')
|
||||||
|
else
|
||||||
|
mig_parm=$(cat "/etc/yunohost/apps/$YNH_APP_ID/status.json" | sed -e 's/.*"url": "\(.\+\)", "type".*/\1/gi')
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_app_setting_set "$app" migration311 "$migration311"
|
||||||
|
ynh_app_setting_set "$app" migration311_type "$mig_type"
|
||||||
|
ynh_app_setting_set "$app" migration311_parm "$mig_parm"
|
||||||
|
current_version="3.0.1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make sure the uwsgi service is stoped
|
||||||
|
if [[ -e "/var/run/uwsgi/$app.socket" ]]
|
||||||
|
then
|
||||||
|
systemctl stop "uwsgi-app@$app.service"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK THE PATH
|
# CHECK THE PATH
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -241,13 +270,18 @@ fi
|
||||||
|
|
||||||
# https://docs.weblate.org/en/latest/admin/upgrade.html#upgrade-3
|
# https://docs.weblate.org/en/latest/admin/upgrade.html#upgrade-3
|
||||||
# https://github.com/WeblateOrg/docker/blob/386aa8d98bb57dfec3707680827d4e4f4d79e3fd/start#L81-L88
|
# https://github.com/WeblateOrg/docker/blob/386aa8d98bb57dfec3707680827d4e4f4d79e3fd/start#L81-L88
|
||||||
weblate showmigrations --plan > /tmp/migrations.txt
|
if [[ $current_version = "3.0.1" ]]
|
||||||
if grep -Fq '[X] auth.0001_initial' /tmp/migrations.txt && grep -Fq '[ ] weblate_auth.0001_initial' /tmp/migrations.txt ; then
|
then
|
||||||
ynh_replace_string "AUTH_USER_MODEL" "#AUTH_USER_MODEL" "$settings"
|
weblate showmigrations --plan > /tmp/migrations.txt
|
||||||
weblate migrate weblate_auth 0001
|
if grep -Fq '[X] auth.0001_initial' /tmp/migrations.txt && grep -Fq '[ ] weblate_auth.0001_initial' /tmp/migrations.txt ; then
|
||||||
ynh_replace_string "#AUTH_USER_MODEL" "AUTH_USER_MODEL" "$settings"
|
ynh_replace_string "AUTH_USER_MODEL" "#AUTH_USER_MODEL" "$settings"
|
||||||
|
weblate migrate weblate_auth 0001
|
||||||
|
ynh_replace_string "#AUTH_USER_MODEL" "AUTH_USER_MODEL" "$settings"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_secure_remove /tmp/migrations.txt
|
||||||
fi
|
fi
|
||||||
ynh_secure_remove /tmp/migrations.txt
|
|
||||||
|
|
||||||
weblate migrate --noinput
|
weblate migrate --noinput
|
||||||
weblate collectstatic --noinput
|
weblate collectstatic --noinput
|
||||||
|
|
Loading…
Reference in a new issue