mirror of
https://github.com/YunoHost-Apps/weblate_ynh.git
synced 2024-10-01 13:35:04 +02:00
Add upgrade support to 2.17.1
This commit is contained in:
parent
d8cbc1526a
commit
5743eb663a
5 changed files with 133 additions and 35 deletions
|
@ -60,10 +60,7 @@ DATA_DIR = os.path.join(BASE_DIR, 'data')
|
||||||
# Local time zone for this installation. Choices can be found here:
|
# Local time zone for this installation. Choices can be found here:
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||||
# although not all choices may be available on all operating systems.
|
# although not all choices may be available on all operating systems.
|
||||||
# On Unix systems, a value of None will cause Django to use the same
|
# In a Windows environment this must be set to your system time zone.
|
||||||
# timezone as the operating system.
|
|
||||||
# If running in a Windows environment this must be set to the same as your
|
|
||||||
# system time zone.
|
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
# Language code for this installation. All choices can be found here:
|
||||||
|
@ -235,8 +232,9 @@ SOCIAL_AUTH_PIPELINE = (
|
||||||
'social_core.pipeline.mail.mail_validation',
|
'social_core.pipeline.mail.mail_validation',
|
||||||
'weblate.accounts.pipeline.revoke_mail_code',
|
'weblate.accounts.pipeline.revoke_mail_code',
|
||||||
'weblate.accounts.pipeline.ensure_valid',
|
'weblate.accounts.pipeline.ensure_valid',
|
||||||
'weblate.accounts.pipeline.reauthenticate',
|
'weblate.accounts.pipeline.remove_account',
|
||||||
'social_core.pipeline.social_auth.associate_by_email',
|
'social_core.pipeline.social_auth.associate_by_email',
|
||||||
|
'weblate.accounts.pipeline.reauthenticate',
|
||||||
'weblate.accounts.pipeline.verify_username',
|
'weblate.accounts.pipeline.verify_username',
|
||||||
'social_core.pipeline.user.create_user',
|
'social_core.pipeline.user.create_user',
|
||||||
'social_core.pipeline.social_auth.associate_user',
|
'social_core.pipeline.social_auth.associate_user',
|
||||||
|
@ -298,6 +296,17 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||||
{
|
{
|
||||||
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
'NAME': 'weblate.accounts.password_validation.CharsPasswordValidator',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'weblate.accounts.password_validation.PastPasswordsValidator',
|
||||||
|
},
|
||||||
|
# Optional password strength validation by django-zxcvbn-password
|
||||||
|
# {
|
||||||
|
# 'NAME': 'zxcvbn_password.ZXCVBNValidator',
|
||||||
|
# 'OPTIONS': {
|
||||||
|
# 'min_score': 3,
|
||||||
|
# 'user_attributes': ('username', 'email', 'first_name')
|
||||||
|
# }
|
||||||
|
# },
|
||||||
]
|
]
|
||||||
|
|
||||||
# Middleware
|
# Middleware
|
||||||
|
@ -316,10 +325,8 @@ MIDDLEWARE_CLASSES = (
|
||||||
|
|
||||||
ROOT_URLCONF = 'weblate.urls'
|
ROOT_URLCONF = 'weblate.urls'
|
||||||
|
|
||||||
|
# Django and Weblate apps
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
# Has to be first to override Django admin templates:
|
|
||||||
'weblate.wladmin',
|
|
||||||
|
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
|
@ -340,16 +347,15 @@ INSTALLED_APPS = (
|
||||||
'weblate.screenshots',
|
'weblate.screenshots',
|
||||||
'weblate.accounts',
|
'weblate.accounts',
|
||||||
'weblate.utils',
|
'weblate.utils',
|
||||||
|
'weblate.wladmin',
|
||||||
|
'weblate',
|
||||||
|
|
||||||
# Optional: Git exporter
|
# Optional: Git exporter
|
||||||
# 'weblate.gitexport',
|
# 'weblate.gitexport',
|
||||||
|
|
||||||
# This application has to be placed last!
|
|
||||||
'weblate',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Path to locales
|
# Path to locales
|
||||||
LOCALE_PATHS = (os.path.join(BASE_DIR, 'locale'), )
|
LOCALE_PATHS = (os.path.join(BASE_DIR, 'weblate', 'locale'), )
|
||||||
|
|
||||||
# Custom exception reporter to include some details
|
# Custom exception reporter to include some details
|
||||||
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
DEFAULT_EXCEPTION_REPORTER_FILTER = \
|
||||||
|
@ -576,6 +582,9 @@ AUTO_LOCK = True
|
||||||
AUTO_LOCK_TIME = 60
|
AUTO_LOCK_TIME = 60
|
||||||
LOCK_TIME = 15 * 60
|
LOCK_TIME = 15 * 60
|
||||||
|
|
||||||
|
# Use simple language codes for default language/country combinations
|
||||||
|
SIMPLIFY_LANGUAGES = True
|
||||||
|
|
||||||
# Render forms using bootstrap
|
# Render forms using bootstrap
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"description": {
|
"description": {
|
||||||
"en": "A translation platform using Git and Python"
|
"en": "A translation platform using Git and Python"
|
||||||
},
|
},
|
||||||
"version": "2.16.0",
|
"version": "2.17.1",
|
||||||
"url": "https://weblate.org",
|
"url": "https://weblate.org",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
|
|
@ -1,5 +1,29 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
current_version="2.17.1"
|
||||||
|
|
||||||
|
weblate_fill_settings() {
|
||||||
|
settings="$1"
|
||||||
|
|
||||||
|
ynh_replace_string "__NAME__" "$app" "$settings"
|
||||||
|
ynh_replace_string "__DB_PWD__" "$db_pwd" "$settings"
|
||||||
|
ynh_replace_string "__ADMIN__" "$admin" "$settings"
|
||||||
|
ynh_replace_string "__ADMINMAIL__" "$admin_mail" "$settings"
|
||||||
|
ynh_replace_string "__DOMAIN__" "$domain" "$settings"
|
||||||
|
ynh_replace_string "__KEY__" "$key" "$settings"
|
||||||
|
ynh_replace_string "__FINALPATH__" "$final_path" "$settings"
|
||||||
|
ynh_replace_string "__MEMCPORT__" "$memc_port" "$settings"
|
||||||
|
ynh_replace_string "__GITHUBUSER__" "$github_account" "$settings"
|
||||||
|
|
||||||
|
# root install as an empty PATHURL to prevent '//static'
|
||||||
|
if [ "$path_url" == "/" ]
|
||||||
|
then
|
||||||
|
ynh_replace_string "__PATHURL__" "" "$settings"
|
||||||
|
else
|
||||||
|
ynh_replace_string "__PATHURL__" "$path_url" "$settings"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
ynh_psql_test_if_first_run() {
|
ynh_psql_test_if_first_run() {
|
||||||
if [ -f /etc/yunohost/psql ];
|
if [ -f /etc/yunohost/psql ];
|
||||||
then
|
then
|
||||||
|
|
|
@ -200,7 +200,7 @@ virtualenv "${final_path}/venv"
|
||||||
(
|
(
|
||||||
set +eu
|
set +eu
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
"${final_path}/venv/bin/pip" install Weblate==2.16
|
"${final_path}/venv/bin/pip" install Weblate=="$current_version"
|
||||||
"${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached
|
"${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached
|
||||||
# specific to YunoHost package:
|
# specific to YunoHost package:
|
||||||
"${final_path}/venv/bin/pip" install django_sendmail_backend
|
"${final_path}/venv/bin/pip" install django_sendmail_backend
|
||||||
|
@ -218,23 +218,8 @@ memc_port=$(ynh_find_port 8080)
|
||||||
settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||||
cp ../conf/settings.py "$settings"
|
cp ../conf/settings.py "$settings"
|
||||||
|
|
||||||
ynh_replace_string "__NAME__" "$app" "$settings"
|
weblate_fill_settings "$settings"
|
||||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$settings"
|
ynh_app_setting_set "$app" memc_port "$memc_port"
|
||||||
ynh_replace_string "__ADMIN__" "$admin" "$settings"
|
|
||||||
ynh_replace_string "__ADMINMAIL__" "$admin_mail" "$settings"
|
|
||||||
ynh_replace_string "__DOMAIN__" "$domain" "$settings"
|
|
||||||
ynh_replace_string "__KEY__" "$key" "$settings"
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$settings"
|
|
||||||
ynh_replace_string "__MEMCPORT__" "$memc_port" "$settings"
|
|
||||||
ynh_replace_string "__GITHUBUSER__" "$github_account" "$settings"
|
|
||||||
|
|
||||||
# root install as an empty PATHURL to prevent '//static'
|
|
||||||
if [ "$path_url" == "/" ]
|
|
||||||
then
|
|
||||||
ynh_replace_string "__PATHURL__" "" "$settings"
|
|
||||||
else
|
|
||||||
ynh_replace_string "__PATHURL__" "$path_url" "$settings"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP Filling up the database
|
# SPECIFIC SETUP Filling up the database
|
||||||
|
@ -300,6 +285,8 @@ then
|
||||||
|
|
||||||
# ynh panel is not needed
|
# ynh panel is not needed
|
||||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
||||||
|
|
||||||
|
ynh_store_file_checksum "$finalnginxconf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -22,6 +22,21 @@ final_path=$(ynh_app_setting_get "$app" final_path)
|
||||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Get previous version number
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
(
|
||||||
|
set +eu
|
||||||
|
source "${final_path}/venv/bin/activate"
|
||||||
|
"${final_path}/venv/bin/pip" install --upgrade pip
|
||||||
|
"${final_path}/venv/bin/pip" freeze --local > freeze.pip
|
||||||
|
)
|
||||||
|
previous_version=$(cat freeze.pip | grep "Weblate==" | sed "s|Weblate==||")
|
||||||
|
|
||||||
|
previous_version_file="../conf/settings_history/settings.$previous_version.py"
|
||||||
|
test -e "$previous_version_file" || ynh_die "Previous version unknown: $previous_version"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -87,17 +102,77 @@ chsh --shell /bin/bash "$app"
|
||||||
# PIP INSTALLATION
|
# PIP INSTALLATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
old_settings="./settings.$previous_version.old.py"
|
||||||
|
settings_diff="./settings.diff"
|
||||||
|
settings="$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||||
|
|
||||||
|
db_pwd=$(ynh_app_setting_get "$app" psqlpwd)
|
||||||
|
admin=$(ynh_app_setting_get "$app" admin)
|
||||||
|
admin_mail=$(ynh_user_get_info "$admin" mail)
|
||||||
|
key=$(ynh_string_random)
|
||||||
|
memc_port=$(ynh_app_setting_get "$app" memc_port)
|
||||||
|
github_account=$(ynh_app_setting_get "$app" github_account)
|
||||||
|
|
||||||
|
#save memc_port if it doesn't exist
|
||||||
|
if [[ -z "$memc_port" ]]
|
||||||
|
then
|
||||||
|
memc_port=$(cat "$settings" \
|
||||||
|
| grep "'LOCATION': '127.0.0.1:" \
|
||||||
|
| sed "s|.*:\\(.*\\)'.*|\\1|")
|
||||||
|
ynh_app_setting_set "$app" memc_port "$memc_port"
|
||||||
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
set +eu
|
set +eu
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
"${final_path}/venv/bin/pip" install Weblate==2.16
|
"${final_path}/venv/bin/pip" install Weblate=="$current_version"
|
||||||
"${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached
|
"${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached
|
||||||
# specific to YunoHost package:
|
# specific to YunoHost package:
|
||||||
"${final_path}/venv/bin/pip" install django_sendmail_backend
|
"${final_path}/venv/bin/pip" install django_sendmail_backend
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# generate previous defaults settings
|
||||||
|
cp "$previous_version_file" "$old_settings"
|
||||||
|
weblate_fill_settings "$old_settings"
|
||||||
|
|
||||||
|
# store diff between defaults and local settings
|
||||||
|
diff --unified "$old_settings" "$settings" > "$settings_diff"
|
||||||
|
|
||||||
|
# generate new defaults settings
|
||||||
|
cp ../conf/settings.py "$settings"
|
||||||
|
weblate_fill_settings "$settings"
|
||||||
|
|
||||||
|
# send diff to the server administrator
|
||||||
|
mail_subject="'$app' settings diff from $previous_version to $current_version"
|
||||||
|
mail_message="
|
||||||
|
Weblate was updated from version $previous_version to $current_version
|
||||||
|
|
||||||
|
A new settings.py has been created in:
|
||||||
|
$settings
|
||||||
|
|
||||||
|
You may have changed your defaults settings.
|
||||||
|
To help you to apply it again, here is a diff file with every changes you did.
|
||||||
|
|
||||||
|
Please note secret key is updated, this is normal.
|
||||||
|
|
||||||
|
For any issue, please file a bug in: https://github.com/YunoHost-Apps/weblate_ynh
|
||||||
|
"
|
||||||
|
|
||||||
|
echo "$mail_message" | mail -s "$mail_subject" root -u root -a "$settings_diff"
|
||||||
|
|
||||||
|
# inform weblate's admin
|
||||||
|
mail_subject="'$app' was updated from $previous_version to $current_version"
|
||||||
|
mail_message="
|
||||||
|
Weblate was updated from version $previous_version to $current_version
|
||||||
|
|
||||||
|
A new settings.py has been created and a diff has been sent to root user.
|
||||||
|
Your administrator may have to update your settings.py to have a fully working installation.
|
||||||
|
"
|
||||||
|
|
||||||
|
echo "$mail_subject" | mail -s "$mail_subject" "$admin_mail"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Migrate databases
|
# Run migration scripts
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
(
|
(
|
||||||
|
@ -106,10 +181,11 @@ chsh --shell /bin/bash "$app"
|
||||||
export DJANGO_SETTINGS_MODULE="weblate.settings"
|
export DJANGO_SETTINGS_MODULE="weblate.settings"
|
||||||
cd "${final_path}"
|
cd "${final_path}"
|
||||||
weblate migrate --noinput
|
weblate migrate --noinput
|
||||||
|
weblate collectstatic --noinput
|
||||||
|
weblate setuplang
|
||||||
|
weblate setupgroups
|
||||||
)
|
)
|
||||||
|
|
||||||
# Verify the checksum and backup the file if it's different
|
|
||||||
ynh_backup_if_checksum_is_different "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
|
||||||
# Recalculate and store the config file checksum into the app settings
|
# Recalculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
ynh_store_file_checksum "$final_path/venv/lib/python2.7/site-packages/weblate/settings.py"
|
||||||
|
|
||||||
|
@ -140,6 +216,8 @@ then
|
||||||
|
|
||||||
# ynh panel is not needed
|
# ynh panel is not needed
|
||||||
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
ynh_replace_string " include conf.d/" " #include conf.d/" "$finalnginxconf"
|
||||||
|
|
||||||
|
ynh_store_file_checksum "$finalnginxconf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue