diff --git a/.gitignore b/.gitignore index 7bbc71c..ac45474 100644 --- a/.gitignore +++ b/.gitignore @@ -99,3 +99,6 @@ ENV/ # mypy .mypy_cache/ +*~ +*.sw[op] +.DS_Store diff --git a/ALL_README.md b/ALL_README.md index 152f2e7..df3708b 100644 --- a/ALL_README.md +++ b/ALL_README.md @@ -5,4 +5,7 @@ - [Irakurri README euskaraz](README_eu.md) - [Lire le README en français](README_fr.md) - [Le o README en galego](README_gl.md) +- [Baca README dalam bahasa bahasa Indonesia](README_id.md) +- [Lees de README in het Nederlands](README_nl.md) +- [Прочитать README на русский](README_ru.md) - [阅读中文(简体)的 README](README_zh_Hans.md) diff --git a/README.md b/README.md index 845d78c..8d06df1 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # Weblate for YunoHost -[![Integration level](https://dash.yunohost.org/integration/weblate.svg)](https://dash.yunohost.org/appci/app/weblate) ![Working status](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/weblate.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) ![Working status](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) [![Install Weblate with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) @@ -18,7 +18,7 @@ It shall NOT be edited by hand. Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. -**Shipped version:** 5.4.3~ynh1 +**Shipped version:** 5.5.3~ynh1 **Demo:** diff --git a/README_es.md b/README_es.md index 487f4b0..4953a92 100644 --- a/README_es.md +++ b/README_es.md @@ -5,7 +5,7 @@ No se debe editar a mano. # Weblate para Yunohost -[![Nivel de integración](https://dash.yunohost.org/integration/weblate.svg)](https://dash.yunohost.org/appci/app/weblate) ![Estado funcional](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Estado En Mantención](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) +[![Nivel de integración](https://dash.yunohost.org/integration/weblate.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) ![Estado funcional](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Estado En Mantención](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) [![Instalar Weblate con Yunhost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) @@ -18,7 +18,7 @@ No se debe editar a mano. Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. -**Versión actual:** 5.4.3~ynh1 +**Versión actual:** 5.5.3~ynh1 **Demo:** @@ -37,7 +37,7 @@ Weblate is a libre web-based translation tool with tight version control integra ## Información para desarrolladores -Por favor enviar sus correcciones a la [`branch testing`](https://github.com/YunoHost-Apps/weblate_ynh/tree/testing +Por favor enviar sus correcciones a la [rama `testing`](https://github.com/YunoHost-Apps/weblate_ynh/tree/testing). Para probar la rama `testing`, sigue asÍ: diff --git a/README_eu.md b/README_eu.md index 765e537..4fdb601 100644 --- a/README_eu.md +++ b/README_eu.md @@ -5,7 +5,7 @@ EZ editatu eskuz. # Weblate YunoHost-erako -[![Integrazio maila](https://dash.yunohost.org/integration/weblate.svg)](https://dash.yunohost.org/appci/app/weblate) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) +[![Integrazio maila](https://dash.yunohost.org/integration/weblate.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) [![Instalatu Weblate YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) @@ -18,7 +18,7 @@ EZ editatu eskuz. Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. -**Paketatutako bertsioa:** 5.4.3~ynh1 +**Paketatutako bertsioa:** 5.5.3~ynh1 **Demoa:** diff --git a/README_fr.md b/README_fr.md index 09c13a9..5294406 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,7 +5,7 @@ Il NE doit PAS être modifié à la main. # Weblate pour YunoHost -[![Niveau d’intégration](https://dash.yunohost.org/integration/weblate.svg)](https://dash.yunohost.org/appci/app/weblate) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/weblate.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) [![Installer Weblate avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) @@ -18,7 +18,7 @@ Il NE doit PAS être modifié à la main. Weblate est un outil de traduction libre avec une intégration étroite du contrôle de version. Il fournit deux interfaces utilisateur, la propagation des traductions entre les composants, les contrôles de qualité et la liaison automatique aux fichiers source. -**Version incluse :** 5.4.3~ynh1 +**Version incluse :** 5.5.3~ynh1 **Démo :** diff --git a/README_gl.md b/README_gl.md index 0e531eb..561bace 100644 --- a/README_gl.md +++ b/README_gl.md @@ -5,7 +5,7 @@ NON debe editarse manualmente. # Weblate para YunoHost -[![Nivel de integración](https://dash.yunohost.org/integration/weblate.svg)](https://dash.yunohost.org/appci/app/weblate) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) +[![Nivel de integración](https://dash.yunohost.org/integration/weblate.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) [![Instalar Weblate con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) @@ -18,7 +18,7 @@ NON debe editarse manualmente. Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. -**Versión proporcionada:** 5.4.3~ynh1 +**Versión proporcionada:** 5.5.3~ynh1 **Demo:** diff --git a/README_id.md b/README_id.md new file mode 100644 index 0000000..43c5274 --- /dev/null +++ b/README_id.md @@ -0,0 +1,50 @@ + + +# Weblate untuk YunoHost + +[![Tingkat integrasi](https://dash.yunohost.org/integration/weblate.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) ![Status kerja](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Status pemeliharaan](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) + +[![Pasang Weblate dengan YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) + +*[Baca README ini dengan bahasa yang lain.](./ALL_README.md)* + +> *Paket ini memperbolehkan Anda untuk memasang Weblate secara cepat dan mudah pada server YunoHost.* +> *Bila Anda tidak mempunyai YunoHost, silakan berkonsultasi dengan [panduan](https://yunohost.org/install) untuk mempelajari bagaimana untuk memasangnya.* + +## Ringkasan + +Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. + +**Versi terkirim:** 5.5.3~ynh1 + +**Demo:** + +## Tangkapan Layar + +![Tangkapan Layar pada Weblate](./doc/screenshots/BigScreenshot.png) + +## Dokumentasi dan sumber daya + +- Website aplikasi resmi: +- Dokumentasi pengguna resmi: +- Dokumentasi admin resmi: +- Depot kode aplikasi hulu: +- Gudang YunoHost: +- Laporkan bug: + +## Info developer + +Silakan kirim pull request ke [`testing` branch](https://github.com/YunoHost-Apps/weblate_ynh/tree/testing). + +Untuk mencoba branch `testing`, silakan dilanjutkan seperti: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug +atau +sudo yunohost app upgrade weblate -u https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug +``` + +**Info lebih lanjut mengenai pemaketan aplikasi:** diff --git a/README_nl.md b/README_nl.md new file mode 100644 index 0000000..3f9e274 --- /dev/null +++ b/README_nl.md @@ -0,0 +1,50 @@ + + +# Weblate voor Yunohost + +[![Integratieniveau](https://dash.yunohost.org/integration/weblate.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) ![Mate van functioneren](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Onderhoudsstatus](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) + +[![Weblate met Yunohost installeren](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) + +*[Deze README in een andere taal lezen.](./ALL_README.md)* + +> *Met dit pakket kun je Weblate snel en eenvoudig op een YunoHost-server installeren.* +> *Als je nog geen YunoHost hebt, lees dan [de installatiehandleiding](https://yunohost.org/install), om te zien hoe je 'm installeert.* + +## Overzicht + +Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. + +**Geleverde versie:** 5.5.3~ynh1 + +**Demo:** + +## Schermafdrukken + +![Schermafdrukken van Weblate](./doc/screenshots/BigScreenshot.png) + +## Documentatie en bronnen + +- Officiele website van de app: +- Officiele gebruikersdocumentatie: +- Officiele beheerdersdocumentatie: +- Upstream app codedepot: +- YunoHost-store: +- Meld een bug: + +## Ontwikkelaarsinformatie + +Stuur je pull request alsjeblieft naar de [`testing`-branch](https://github.com/YunoHost-Apps/weblate_ynh/tree/testing). + +Om de `testing`-branch uit te proberen, ga als volgt te werk: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug +of +sudo yunohost app upgrade weblate -u https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug +``` + +**Verdere informatie over app-packaging:** diff --git a/README_ru.md b/README_ru.md new file mode 100644 index 0000000..0f3af64 --- /dev/null +++ b/README_ru.md @@ -0,0 +1,50 @@ + + +# Weblate для YunoHost + +[![Уровень интеграции](https://dash.yunohost.org/integration/weblate.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) ![Состояние работы](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![Состояние сопровождения](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) + +[![Установите Weblate с YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) + +*[Прочтите этот README на других языках.](./ALL_README.md)* + +> *Этот пакет позволяет Вам установить Weblate быстро и просто на YunoHost-сервер.* +> *Если у Вас нет YunoHost, пожалуйста, посмотрите [инструкцию](https://yunohost.org/install), чтобы узнать, как установить его.* + +## Обзор + +Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. + +**Поставляемая версия:** 5.5.3~ynh1 + +**Демо-версия:** + +## Снимки экрана + +![Снимок экрана Weblate](./doc/screenshots/BigScreenshot.png) + +## Документация и ресурсы + +- Официальный веб-сайт приложения: +- Официальная документация пользователя: +- Официальная документация администратора: +- Репозиторий кода главной ветки приложения: +- Магазин YunoHost: +- Сообщите об ошибке: + +## Информация для разработчиков + +Пришлите Ваш запрос на слияние в [ветку `testing`](https://github.com/YunoHost-Apps/weblate_ynh/tree/testing). + +Чтобы попробовать ветку `testing`, пожалуйста, сделайте что-то вроде этого: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug +или +sudo yunohost app upgrade weblate -u https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug +``` + +**Больше информации о пакетировании приложений:** diff --git a/README_zh_Hans.md b/README_zh_Hans.md index 8d764e1..14cd73c 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -5,7 +5,7 @@ # YunoHost 上的 Weblate -[![集成程度](https://dash.yunohost.org/integration/weblate.svg)](https://dash.yunohost.org/appci/app/weblate) ![工作状态](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) +[![集成程度](https://dash.yunohost.org/integration/weblate.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) ![工作状态](https://ci-apps.yunohost.org/ci/badges/weblate.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/weblate.maintain.svg) [![使用 YunoHost 安装 Weblate](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) @@ -18,7 +18,7 @@ Weblate is a libre web-based translation tool with tight version control integration. It provides two user interfaces, propagation of translations across components, quality checks and automatic linking to source files. -**分发版本:** 5.4.3~ynh1 +**分发版本:** 5.5.3~ynh1 **演示:** diff --git a/conf/settings.py b/conf/settings.py index d274ee9..9b55daa 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -15,9 +15,7 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -# Copyright © Michal Čihař -# -# SPDX-License-Identifier: GPL-3.0-or-later +# mypy: disable-error-code="var-annotated" import os import platform @@ -138,6 +136,7 @@ LANGUAGES = ( ("sr", "Српски"), ("sr-latn", "Srpski"), ("sv", "Svenska"), + ("ta", "தமிழ்"), ("th", "ไทย"), ("tr", "Türkçe"), ("uk", "Українська"), @@ -158,7 +157,7 @@ USE_TZ = True DEFAULT_AUTO_FIELD = "django.db.models.AutoField" # URL prefix to use, please see documentation for more details -# WARNING: this must be without trailing slash (this is why we set __PATH_NO_SLASH__ (cf. loaded settings in install and upgrade)) +# YUNOHOST_WARNING: this must be without trailing slash (this is why we set __PATH_NO_SLASH__ (cf. loaded settings in install and upgrade)) URL_PREFIX = "__PATH_NO_SLASH__" # Absolute filesystem path to the directory that will hold user-uploaded files. @@ -222,9 +221,6 @@ GITHUB_CREDENTIALS = { "token": "__GITHUB_TOKEN__", } } -# Azure DevOps username and token for sending pull requests. -# Please see the documentation for more details. -AZURE_DEVOPS_CREDENTIALS = {} # Azure DevOps username and token for sending pull requests. # Please see the documentation for more details. @@ -244,7 +240,7 @@ GITLAB_CREDENTIALS = { BITBUCKETSERVER_CREDENTIALS = {} # Authentication configuration -AUTHENTICATION_BACKENDS = ( +AUTHENTICATION_BACKENDS: tuple[str, ...] = ( "social_core.backends.email.EmailAuth", # "social_core.backends.google.GoogleOAuth2", # "social_core.backends.github.GithubOAuth2", @@ -431,7 +427,7 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", - "django.contrib.admin.apps.SimpleAdminConfig", + "django.contrib.admin", "django.contrib.admindocs", "django.contrib.sitemaps", "django.contrib.humanize", @@ -464,7 +460,7 @@ if platform.system() != "Windows": # Since Python 3.7 connect failures are silently discarded, so # the exception is almost never raised here. Instead we look whether the socket # to syslog is open after init. - HAVE_SYSLOG = handler.socket.fileno() != -1 + HAVE_SYSLOG = handler.socket.fileno() != -1 # type: ignore[attr-defined] handler.close() except OSError: HAVE_SYSLOG = False @@ -477,7 +473,7 @@ DEFAULT_LOGLEVEL = "DEBUG" if DEBUG else "INFO" # the site admins on every HTTP 500 error when DEBUG=False. # See http://docs.djangoproject.com/en/stable/topics/logging for # more details on how to customize your logging configuration. -LOGGING = { +LOGGING: dict = { "version": 1, "disable_existing_loggers": True, "filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}}, @@ -615,6 +611,10 @@ LOGOUT_URL = f"{URL_PREFIX}/accounts/logout/" # Default location for login LOGIN_REDIRECT_URL = f"{URL_PREFIX}/" +LOGOUT_REDIRECT_URL = f"{URL_PREFIX}/" + +# Opt-in for Django 6.0 default +FORMS_URLFIELD_ASSUME_HTTPS = True # Anonymous user name ANONYMOUS_USER_NAME = "anonymous" @@ -657,6 +657,7 @@ CRISPY_TEMPLATE_PACK = "bootstrap3" # "weblate.checks.chars.EndColonCheck", # "weblate.checks.chars.EndQuestionCheck", # "weblate.checks.chars.EndExclamationCheck", +# "weblate.checks.chars.EndInterrobangCheck", # "weblate.checks.chars.EndEllipsisCheck", # "weblate.checks.chars.EndSemicolonCheck", # "weblate.checks.chars.MaxLengthCheck", @@ -824,6 +825,7 @@ REST_FRAMEWORK = { "DEFAULT_PAGINATION_CLASS": "weblate.api.pagination.StandardPagination", "PAGE_SIZE": 50, "VIEW_DESCRIPTION_FUNCTION": "weblate.api.views.get_view_description", + "EXCEPTION_HANDLER": "weblate.api.views.weblate_exception_handler", "UNAUTHENTICATED_USER": "weblate.auth.models.get_anonymous", } @@ -850,6 +852,7 @@ if REQUIRE_LOGIN: # rf"{URL_PREFIX}/healthz/$", # Allowing public access to health check # rf"{URL_PREFIX}/api/(.*)$", # Allowing access to API # rf"{URL_PREFIX}/js/i18n/$", # JavaScript localization +# rf"{URL_PREFIX}/css/custom\.css$", # Custom CSS support # rf"{URL_PREFIX}/contact/$", # Optional for contact form # rf"{URL_PREFIX}/legal/(.*)$", # Optional for legal app # rf"{URL_PREFIX}/avatar/(.*)$", # Optional for avatars @@ -869,7 +872,9 @@ SILENCED_SYSTEM_CHECKS = [ # Celery worker configuration for production CELERY_TASK_ALWAYS_EAGER = False CELERY_BROKER_URL = "redis://127.0.0.1:6379/__REDIS_DB__" -CELERY_RESULT_BACKEND = CELERY_BROKER_URL +CELERY_RESULT_BACKEND: str | None = CELERY_BROKER_URL +CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP = True +CELERY_BROKER_CONNECTION_RETRY = True # Celery settings, it is not recommended to change these CELERY_WORKER_MAX_MEMORY_PER_CHILD = 200000 @@ -887,7 +892,7 @@ CELERY_TASK_ROUTES = { # CORS allowed origins CORS_ALLOWED_ORIGINS = [] -CORS_URLS_REGEX = r"^/api/.*$" +CORS_URLS_REGEX = rf"^{URL_PREFIX}/api/.*$" # Enable plain database backups DATABASE_BACKUP = "plain" diff --git a/manifest.toml b/manifest.toml index 33a3fe4..024f73e 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "Weblate" description.en = "Translation platform using Git and Python" description.fr = "Plateforme de traduction utilisant Git et Python" -version = "5.4.3~ynh1" +version = "5.5.3~ynh1" maintainers = ["Thovi98"] @@ -22,7 +22,8 @@ cpe = "cpe:2.3:a:weblate:weblate" fund = "https://weblate.org/fr/donate/" [integration] -yunohost = ">= 11.2.12" +yunohost = ">= 12.0.0" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = false @@ -86,6 +87,7 @@ ram.runtime = "3G" [resources.system_user] [resources.install_dir] + group = "www-data:r-x" [resources.permissions] main.url = "/" @@ -94,11 +96,29 @@ ram.runtime = "3G" main.default = 8080 [resources.apt] - # §1 = weblate dependecies, §2 = borgbackup dependencies - packages = ["libxml2-dev", "libxslt-dev", "libfreetype6-dev", "libjpeg-dev", "libz-dev", "libyaml-dev", "libffi-dev", "libcairo-dev", "gir1.2-pango-1.0", "libgirepository1.0-dev", "libacl1-dev", "libssl-dev", "libpq-dev", "libjpeg62-turbo-dev", "build-essential", "python3-gdbm", "python3-dev", "python3-pip", "python3-venv", "python3-virtualenv", "virtualenv", "git", "uwsgi", "uwsgi-plugin-python3", "redis-server", "postgresql", "postgresql-contrib", "hub", - - - "libacl1-dev", "libacl1", "libssl-dev", "liblz4-dev", "libzstd-dev", "libxxhash-dev", "build-essential", "pkg-config", "python3-pkgconfig"] + packages = [ + # Weblate dependencies + "build-essential", "git", + "gir1.2-pango-1.0", "libacl1-dev", "libcairo-dev", "libffi-dev", "libfreetype6-dev", + "libgirepository1.0-dev", "libjpeg-dev", "libjpeg62-turbo-dev", "libpq-dev", + "libssl-dev", "libxml2-dev", "libxslt-dev", "libyaml-dev", "libz-dev", "librsvg2-dev", + "python3-gdbm", + "python3-dev", + "python3-pip", + "python3-venv", + "python3-virtualenv", + "virtualenv", + "uwsgi", + "uwsgi-plugin-python3", + "redis-server", + "postgresql", + "postgresql-contrib", + "hub", + "gettext", + # Borg backup dependencies + "pkg-config", "python3-pkgconfig", + "libacl1-dev", "libacl1", "libssl-dev", "liblz4-dev", "libzstd-dev", "libxxhash-dev", + ] [resources.database] type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index c5f9ef0..5e9b55a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= debian_maj_version=$(sed 's/\..*//' /etc/debian_version) @@ -16,10 +16,6 @@ elif [ "$debian_maj_version" -eq 12 ] ; then weblate_pypath="python3.11" fi -#================================================= -# PERSONAL HELPERS -#================================================= - set_forge_variables() { if [ $used_forge = "GitHub" ] ; then github_username="$forge_username" @@ -33,11 +29,3 @@ set_forge_variables() { gitlab_token="$forge_token" fi } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index dbbe2a8..7899510 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,62 +1,38 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= +ynh_backup "/etc/logrotate.d/$app" -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app-celery.service" -#================================================= -# BACKUP SYSTEMD -#================================================= - -ynh_backup --src_path="/etc/systemd/system/$app.service" -ynh_backup --src_path="/etc/systemd/system/$app-celery.service" - -#================================================= -# BACKUP VARIOUS FILES -#================================================= - -ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini" +ynh_backup "/etc/uwsgi/apps-available/$app.ini" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." +ynh_print_info "Backing up the PostgreSQL database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 5a4d779..edda15b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,87 +1,75 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping systemd services..." --weight=1 +ynh_script_progression "Stopping systemd services..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/weblate.log" --line_match="goodbye to uWSGI" -ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="systemd" +ynh_systemctl --service=$app --action="stop" --log_path="/var/log/$app/weblate.log" --wait_until="goodbye to uWSGI" +ynh_systemctl --service="$app-celery" --action="stop" --log_path="systemd" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx -#================================================= -# SPECIFIC MODIFICATIONS #================================================= # MODIFY SETTINGS #================================================= -ynh_script_progression --message="Modify weblate's config file..." --weight=1 +ynh_script_progression "Modify weblate's config file..." settings="$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" -ynh_backup_if_checksum_is_different --file="$settings" +ynh_backup_if_checksum_is_different "$settings" # Change the path in the nginx config file if [ $change_path -eq 1 ] then - ynh_replace_string --match_string="URL_PREFIX = \"${old_path%/}\"" --replace_string="URL_PREFIX = \"${new_path%/}\"" --target_file="$settings" + ynh_replace --match="URL_PREFIX = \"${old_path%/}\"" --replace="URL_PREFIX = \"${new_path%/}\"" --file="$settings" fi # Change the domain for nginx if [ $change_domain -eq 1 ] then # replace SERVER_EMAIL - ynh_replace_string --match_string="noreply@$old_domain" --replace_string="noreply@$new_domain" --target_file="$settings" + ynh_replace --match="noreply@$old_domain" --replace="noreply@$new_domain" --file="$settings" # replace SITE_DOMAIN - ynh_replace_string --match_string="SITE_DOMAIN = \"$old_domain\"" --replace_string="SITE_DOMAIN = \"$new_domain\"" --target_file="$settings" + ynh_replace --match="SITE_DOMAIN = \"$old_domain\"" --replace="SITE_DOMAIN = \"$new_domain\"" --file="$settings" # replace ALLOWED_HOSTS - ynh_replace_string --match_string="ALLOWED_HOSTS = \[\"$old_domain\"\]" --replace_string="ALLOWED_HOSTS = \[\"$new_domain\"\]" --target_file="$settings" + ynh_replace --match="ALLOWED_HOSTS = \[\"$old_domain\"\]" --replace="ALLOWED_HOSTS = \[\"$new_domain\"\]" --file="$settings" fi -ynh_store_file_checksum --file="$settings" +ynh_store_file_checksum "$settings" #================================================= # MODIFY UWSGI #================================================= finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" -ynh_backup_if_checksum_is_different --file="$finaluwsgiini" +ynh_backup_if_checksum_is_different "$finaluwsgiini" # Change the path in the nginx config file if [ $change_path -eq 1 ] then - ynh_replace_string --match_string="mount = $old_path=" --replace_string="mount = $new_path=" --target_file="$finaluwsgiini" + ynh_replace --match="mount = $old_path=" --replace="mount = $new_path=" --file="$finaluwsgiini" fi -ynh_store_file_checksum --file="$finaluwsgiini" +ynh_store_file_checksum "$finaluwsgiini" -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=5 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/weblate.log" --line_match="spawned uWSGI" -ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/weblate-celery-celery.log" --line_match="mingle: all alone" +ynh_systemctl --service=$app --action="start" --log_path="/var/log/$app/weblate.log" --wait_until="spawned uWSGI" +ynh_systemctl --service="$app-celery" --action="start" --log_path="/var/log/$app/weblate-celery-celery.log" --wait_until="mingle: all alone" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 4e13e85..c4aad21 100755 --- a/scripts/install +++ b/scripts/install @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -19,11 +13,11 @@ key=$(ynh_string_random --length=50) #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +ynh_script_progression "Storing installation settings..." -ynh_app_setting_set --app=$app --key=used_forge --value=$used_forge -ynh_app_setting_set --app=$app --key=forge_username --value=$forge_username -ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token +ynh_app_setting_set --key=used_forge --value=$used_forge +ynh_app_setting_set --key=forge_username --value=$forge_username +ynh_app_setting_set --key=forge_token --value=$forge_token # Remove trailing "/" from the path path_no_slash=${path%/} @@ -31,14 +25,14 @@ path_no_slash=${path%/} #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 +ynh_script_progression "Creating a PostgreSQL database..." -ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name +ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pg_trgm;" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression "Setting up source files..." mkdir -p "$install_dir/avatar-cache" mkdir -p "$install_dir/data" @@ -50,17 +44,14 @@ chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=2 +ynh_script_progression "Configuring NGINX web server..." -# Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx -#================================================= -# SPECIFIC SETUP #================================================= # INSTALL XXHASH #================================================= -ynh_script_progression --message="Installing xxHash..." +ynh_script_progression "Installing xxHash..." tempdir="$(mktemp -d)" ynh_setup_source --dest_dir=$tempdir --source_id="libxxhash" @@ -68,17 +59,17 @@ pushd $tempdir make make install popd -ynh_secure_remove --file="$tempdir" +ynh_safe_rm "$tempdir" #================================================= # CONFIGURE HUB #================================================= if [ $used_forge = "GitHub" ] ; then - ynh_script_progression --message="Configure hub..." --weight=1 - + ynh_script_progression "Configure hub..." + mkdir "$install_dir/.config/" - ynh_add_config --template="../conf/hub_config" --destination="$install_dir/.config/hub" + ynh_config_add --template="hub_config" --destination="$install_dir/.config/hub" cat < "$install_dir/.bashrc" eval "$(hub alias -s /bin/bash)" @@ -88,7 +79,7 @@ fi #================================================= # PIP INSTALLATION #================================================= -ynh_script_progression --message="Install weblate using PIP..." --weight=80 +ynh_script_progression "Install weblate using PIP..." virtualenv --python=python3 "${install_dir}/venv" chown -R $app: "$install_dir" @@ -116,17 +107,20 @@ chown -R $app: "$install_dir" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." redis_db=$(ynh_redis_get_free_db) -ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db" +ynh_app_setting_set --key=redis_db --value="$redis_db" settings="$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" set_forge_variables -ynh_add_config --template="../conf/settings.py" --destination="$settings" -ynh_add_config --template="../conf/celery-weblate" --destination="$install_dir/celery-weblate" -ynh_add_config --template="../conf/uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini" +ynh_config_add --template="settings.py" --destination="$settings" +ynh_config_add --template="celery-weblate" --destination="$install_dir/celery-weblate" +ynh_config_add --template="uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini" + +chmod 640 "/etc/uwsgi/apps-available/$app.ini" +chown $app:$app "/etc/uwsgi/apps-available/$app.ini" touch "$install_dir/local_settings.py" ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" @@ -142,7 +136,7 @@ chown -R "$app:www-data" "$install_dir/data" # SPECIFIC SETUP Filling up the database # https://docs.weblate.org/en/latest/admin/install.html#filling-up-the-database #========================================== -ynh_script_progression --message="Filling up the database..." --weight=10 +ynh_script_progression "Filling up the database..." ( set +o nounset @@ -152,46 +146,44 @@ ynh_script_progression --message="Filling up the database..." --weight=10 cd "${install_dir}" # the user needs to be weblate for postgresql - ynh_exec_warn_less sudo --user=$app $install_dir/venv/bin/weblate migrate --noinput - - ynh_exec_warn_less sudo --user=$app $install_dir/venv/bin/weblate createadmin --no-color \ + ynh_hide_warnings sudo --user=$app $install_dir/venv/bin/weblate migrate --noinput + + ynh_hide_warnings sudo --user=$app $install_dir/venv/bin/weblate createadmin --no-color \ --password "$password" \ --username "$admin" \ --email "$admin_mail" # generate static files - ynh_exec_warn_less sudo --user=$app $install_dir/venv/bin/weblate collectstatic --noinput + ynh_hide_warnings sudo --user=$app $install_dir/venv/bin/weblate collectstatic --noinput # https://docs.weblate.org/en/latest/admin/install/venv-debian.html - ynh_exec_warn_less sudo --user=$app $install_dir/venv/bin/weblate compress + ynh_hide_warnings sudo --user=$app $install_dir/venv/bin/weblate compress # Check the configuration # This may fail in some cases with errors, etc., but the app works and the user can fix issues later. - ynh_exec_warn_less sudo --user=$app $install_dir/venv/bin/weblate check --deploy || true + ynh_hide_warnings sudo --user=$app $install_dir/venv/bin/weblate check --deploy || true ) #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=3 +ynh_script_progression "Configuring $app's systemd service..." -ynh_add_systemd_config --service=$app --template="weblate.service" -ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service" +ynh_config_add_systemd --template="weblate.service" +ynh_config_add_systemd --service="$app-celery" --template="celery-weblate.service" -#================================================= -# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression "Configuring log rotation..." # Use logrotate to manage application logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --log="/var/log/$app/weblate.log" yunohost service add "$app-celery" --log="/var/log/$app/weblate-celery-w1.log" @@ -199,13 +191,13 @@ yunohost service add "$app-celery" --log="/var/log/$app/weblate-celery-w1.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=5 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/weblate.log" --line_match="spawned uWSGI" -ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/weblate-celery-celery.log" --line_match="mingle: all alone" +ynh_systemctl --service=$app --action="start" --log_path="/var/log/$app/weblate.log" --wait_until="spawned uWSGI" +ynh_systemctl --service="$app-celery" --action="start" --log_path="/var/log/$app/weblate-celery-celery.log" --wait_until="mingle: all alone" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index f6d4bd6..c31f8fe 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,63 +1,33 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression "Removing system configurations related to $app..." -# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null -then - ynh_script_progression --message="Removing $app service integration..." --weight=1 +if ynh_hide_warnings yunohost service status $app >/dev/null; then yunohost service remove $app fi -# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status "$app-celery" >/dev/null -then - ynh_script_progression --message="Removing $app-celery service integration..." --weight=1 +if ynh_hide_warnings yunohost service status "$app-celery" >/dev/null; then yunohost service remove "$app-celery" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=5 +ynh_config_remove_systemd -# Remove the dedicated systemd config -ynh_remove_systemd_config --service=$app -ynh_remove_systemd_config --service="$app-celery" +ynh_config_remove_systemd "$app-celery" -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 +ynh_config_remove_logrotate -# Remove the app-specific logrotate config -ynh_remove_logrotate - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - -# Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # REMOVE XXHASH #================================================= -ynh_script_progression --message="Removing xxHash..." +ynh_script_progression "Removing xxHash..." tempdir="$(mktemp -d)" ynh_setup_source --dest_dir=$tempdir --source_id="libxxhash" @@ -65,18 +35,16 @@ pushd $tempdir make make uninstall popd -ynh_secure_remove --file="$tempdir" +ynh_safe_rm "$tempdir" -#================================================= -# SPECIFIC REMOVE #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression "Removing various files..." -ynh_secure_remove --file="/etc/uwsgi/apps-available/$app.ini" +ynh_safe_rm "/etc/uwsgi/apps-available/$app.ini" -ynh_secure_remove --file="/var/run/$app-celery" +ynh_safe_rm "/var/run/$app-celery" ynh_redis_remove_db @@ -84,4 +52,4 @@ ynh_redis_remove_db # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 0263875..2817485 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,21 +1,14 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=4 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" +ynh_restore "$install_dir" touch "$install_dir/local_settings.py" ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" @@ -29,21 +22,21 @@ chown -R $app:www-data "$install_dir/data" #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +ynh_script_progression "Restoring the NGINX web server configuration..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5 +ynh_script_progression "Restoring the PostgreSQL database..." -ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_db_shell < ./db.sql #================================================= # INSTALL XXHASH #================================================= -ynh_script_progression --message="Installing xxHash..." +ynh_script_progression "Installing xxHash..." tempdir="$(mktemp -d)" ynh_setup_source --dest_dir=$tempdir --source_id="libxxhash" @@ -51,37 +44,37 @@ pushd $tempdir make make install popd -ynh_secure_remove --file="$tempdir" +ynh_safe_rm "$tempdir" #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring various files..." --weight=1 +ynh_script_progression "Restoring various files..." -ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini" +ynh_restore "/etc/uwsgi/apps-available/$app.ini" #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=4 +ynh_script_progression "Restoring $app's systemd service..." -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/$app-celery.service" +ynh_restore "/etc/systemd/system/$app-celery.service" systemctl enable "$app-celery" --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." +ynh_script_progression "Restoring the logrotate configuration..." mkdir -p "/var/log/$app" -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --log="/var/log/$app/weblate.log" yunohost service add "$app-celery" --log="/var/log/$app/weblate-celery-w1.log" @@ -89,22 +82,20 @@ yunohost service add "$app-celery" --log="/var/log/$app/weblate-celery-w1.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=5 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/weblate.log" --line_match="spawned uWSGI" -ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/weblate-celery-w1.log" --line_match="mingle: all alone" +ynh_systemctl --service=$app --action="start" --log_path="/var/log/$app/weblate.log" --wait_until="spawned uWSGI" +ynh_systemctl --service="$app-celery" --action="start" --log_path="/var/log/$app/weblate-celery-w1.log" --wait_until="mingle: all alone" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression "Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 6d65747..b777037 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,18 +1,12 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +ynh_script_progression "Loading installation settings..." admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) key=$(ynh_string_random --length=50) @@ -20,51 +14,41 @@ key=$(ynh_string_random --length=50) # Remove trailing "/" from the path path_no_slash=${path%/} -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping systemd services..." --weight=5 +ynh_script_progression "Stopping systemd services..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/weblate.log" --line_match="goodbye to uWSGI" -ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="systemd" +ynh_systemctl --service=$app --action="stop" --log_path="/var/log/$app/weblate.log" --wait_until="goodbye to uWSGI" +ynh_systemctl --service="$app-celery" --action="stop" --log_path="systemd" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." # If used_forge, forge_username, forge_token don't exist, create them if [ -z "$used_forge" ]; then used_forge="GitHub" - forge_username=$(ynh_app_setting_get --app=$app --key=github_account) - forge_token=$(ynh_app_setting_get --app=$app --key=github_token) - ynh_app_setting_set --app=$app --key=used_forge --value=$used_forge - ynh_app_setting_set --app=$app --key=forge_username --value=$forge_username - ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token + forge_username=$(ynh_app_setting_get --key=github_account) + forge_token=$(ynh_app_setting_get --key=github_token) + ynh_app_setting_set --key=used_forge --value=$used_forge + ynh_app_setting_set --key=forge_username --value=$forge_username + ynh_app_setting_set --key=forge_token --value=$forge_token fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=3 +ynh_script_progression "Upgrading NGINX web server configuration..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx -#================================================= -# SPECIFIC UPGRADE #================================================= # INSTALL XXHASH #================================================= -ynh_script_progression --message="Installing xxHash..." +ynh_script_progression "Installing xxHash..." tempdir="$(mktemp -d)" ynh_setup_source --dest_dir=$tempdir --source_id="libxxhash" @@ -72,17 +56,17 @@ pushd $tempdir make make install popd -ynh_secure_remove --file="$tempdir" +ynh_safe_rm "$tempdir" #================================================= # CONFIGURE HUB #================================================= if [ $used_forge = "GitHub" ] ; then - ynh_script_progression --message="Configure hub..." --weight=1 - + ynh_script_progression "Configure hub..." + #mkdir "$install_dir/.config/" - ynh_add_config --template="../conf/hub_config" --destination="$install_dir/.config/hub" + ynh_config_add --template="hub_config" --destination="$install_dir/.config/hub" cat < "$install_dir/.bashrc" eval "$(hub alias -s /bin/bash)" @@ -92,19 +76,20 @@ fi #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=2 +ynh_script_progression "Updating configuration..." -ynh_add_config --template="../conf/uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini" +ynh_config_add --template="uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini" +chmod 600 "/etc/uwsgi/apps-available/$app.ini" -ynh_add_config --template="../conf/celery-weblate" --destination="$install_dir/celery-weblate" +ynh_config_add --template="celery-weblate" --destination="$install_dir/celery-weblate" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=3 +ynh_script_progression "Configuring $app's systemd service..." -ynh_add_systemd_config --service=$app --template="weblate.service" -ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service" +ynh_config_add_systemd --template="weblate.service" +ynh_config_add_systemd --service="$app-celery" --template="celery-weblate.service" #================================================= # UPGRADE WEBLATE @@ -116,12 +101,11 @@ upgrade() { #================================================= # PIP INSTALLATION #================================================= - ynh_script_progression --message="Install weblate using PIP..." --weight=15 + ynh_script_progression "Install weblate using PIP..." - ynh_secure_remove --file="${install_dir}/venv" + ynh_safe_rm "${install_dir}/venv" virtualenv --python=python3 "${install_dir}/venv" chown -R $app: "$install_dir" - #run source in a 'sub shell' ( set +o nounset @@ -144,19 +128,20 @@ upgrade() { #================================================= # MODIFY A CONFIG FILE #================================================= - ynh_script_progression --message="Create weblate configuration file..." --weight=2 + ynh_script_progression "Create weblate configuration file..." + # save old settings file settings="$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" path="${path%/}" set_forge_variables - ynh_add_config --template="../conf/settings.py" --destination="$settings" + ynh_config_add --template="settings.py" --destination="$settings" - ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db" + ynh_app_setting_set --key=redis_db --value="$redis_db" # Recalculate and store the config file checksum into the app settings - ynh_store_file_checksum --file="$settings" + ynh_store_file_checksum "$settings" touch "$install_dir/local_settings.py" ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" @@ -164,9 +149,9 @@ upgrade() { #================================================= # MIGRATE WEBLATE #================================================= - ynh_script_progression --message="Run migration scripts..." --weight=10 + ynh_script_progression "Run migration scripts..." - ynh_systemd_action --service_name="$app-celery" --action="start" + ynh_systemctl --service="$app-celery" --action="start" ( set +o nounset @@ -189,7 +174,7 @@ upgrade() { fi ) - ynh_systemd_action --service_name="$app-celery" --action="stop" + ynh_systemctl --service="$app-celery" --action="stop" } file_version="${install_dir}/venv/lib/$weblate_pypath/site-packages/weblate/__init__.py" @@ -205,7 +190,7 @@ else current_version=3 fi -ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name +ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pg_trgm;" if [ "$current_version" -lt "5" ] then @@ -223,20 +208,18 @@ chown -R "$app:www-data" "$install_dir/data" chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" -#================================================= -# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +ynh_script_progression "Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --log="/var/log/$app/weblate.log" yunohost service add "$app-celery" --log="/var/log/$app/weblate-celery-w1.log" @@ -244,13 +227,13 @@ yunohost service add "$app-celery" --log="/var/log/$app/weblate-celery-w1.log" #================================================= # START SYSTEMD SERVICES #================================================= -ynh_script_progression --message="Starting systemd services..." --weight=5 +ynh_script_progression "Starting systemd services..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/weblate.log" --line_match="spawned uWSGI" -ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/weblate-celery-celery.log" --line_match="mingle: all alone" +ynh_systemctl --service=$app --action="start" --log_path="/var/log/$app/weblate.log" --wait_until="spawned uWSGI" +ynh_systemctl --service="$app-celery" --action="start" --log_path="/var/log/$app/weblate-celery-celery.log" --wait_until="mingle: all alone" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" diff --git a/tests.toml b/tests.toml index b38404d..c6f8b1c 100644 --- a/tests.toml +++ b/tests.toml @@ -27,4 +27,5 @@ test_format = 1.0 test_upgrade_from.52db1ab.name = "5.3.1-ynh2" test_upgrade_from.e075efc.name = "5.4.1" - test_upgrade_from.40ff28f.name = "5.4.2" \ No newline at end of file + test_upgrade_from.40ff28f.name = "5.4.2" + test_upgrade_from.def94c9.name = "5.4.3" \ No newline at end of file