diff --git a/README.md b/README.md index 9423af3..b44bcf8 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,31 @@ + + # Weblate for YunoHost [![Integration level](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) [![Install Weblate with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) -> *This package allows you to install Weblate quickly and simply on a YunoHost server. +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allows you to install Weblate quickly and simply on a YunoHost server. If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview 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:** 4.7 +**Shipped version:** 4.8~ynh1 + +**Demo:** https://hosted.weblate.org/ ## Screenshots -![](https://weblate.org/static/img/BigScreenshot.png) +![](./doc/screenshots/BigScreenshot.png) -## Demo - -* [YunoHost project uses Weblate for translations](https://translate.yunohost.org) +## Disclaimers / important information ## GitHub @@ -38,31 +45,16 @@ You can edit the file `$final_path/local_settings.py` to enable or disable featu It doesn't work yet, but while [it looks doable](https://docs.weblate.org/en/latest/admin/auth.html?highlight=LDAP#ldap-authentication), I'm unsure it is a good idea to connect this kind of tools to your LDAP. -#### Supported architectures +## Documentation and resources -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/weblate%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/weblate/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/weblate%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/weblate/) +* Official app website: https://weblate.org +* Official user documentation: https://docs.weblate.org/ +* Official admin documentation: https://docs.weblate.org/ +* Upstream app code repository: https://github.com/WeblateOrg/weblate +* YunoHost documentation for this app: https://yunohost.org/app_weblate +* Report a bug: https://github.com/YunoHost-Apps/weblate_ynh/issues -## Limitations - -* Any known limitations. - -## Additional information - -* Other info you would like to add about this app. - -## Links - - * Report a bug about this package: https://github.com/YunoHost-Apps/weblate_ynh - * Report a bug about Weblate itself: https://github.com/WeblateOrg/weblate - * Documentation: https://docs.weblate.org/ - * Weblate website: https://weblate.org/ - * YunoHost website: https://yunohost.org/ - ---- - -Developer info ----------------- +## Developer info Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/weblate_ynh/tree/testing). @@ -72,3 +64,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/weblate_ynh/tree/test or sudo yunohost app upgrade weblate -u https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug ``` + +**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..8d01fb8 --- /dev/null +++ b/README_fr.md @@ -0,0 +1,63 @@ +# Weblate pour YunoHost + +[![Niveau d'intégration](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) +[![Installer Weblate avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=weblate) + +*[Read this readme in english.](./README.md)* +*[Lire ce readme en français.](./README_fr.md)* + +> *Ce package vous permet d'installer Weblate rapidement et simplement sur un serveur YunoHost. +Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* + +## Vue d'ensemble + +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 :** 4.8~ynh1 + +**Démo :** https://hosted.weblate.org/ + +## Captures d'écran + +![](./doc/screenshots/BigScreenshot.png) + +## Avertissements / informations importantes + +## GitHub + +Vous devrez donner à Weblate un utilisateur GitHub et un jeton. Veuillez lire [la documentation de GitHub sur le jeton](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). +Cet utilisateur ne sera utilisé que pour ouvrir la pull-request, chaque traduction garde son auteur. + +**Clés SSH**, vous devrez vous rendre dans l'administration, générer une clé publique pour Weblate et ajouter github.com pour que Weblate connaisse l'empreinte digitale. Veuillez noter que si votre compte possède déjà une clé publique (ssh-rsa), vous devrez ajouter manuellement celle de Weblate à votre compte GitHub. + +## Paramètres et mises à niveau + +Presque tout ce qui concerne la configuration de Weblate est géré dans un fichier `settings.py`. +Vous pouvez éditer le fichier `$final_path/local_settings.py` pour activer ou désactiver des fonctionnalités. + +# Divers + +## Connexion LDAP + +Cela ne fonctionne pas encore, mais bien que [cela semble faisable](https://docs.weblate.org/en/latest/admin/auth.html?highlight=LDAP#ldap-authentication), je ne suis pas sûr que ce soit le cas une bonne idée de connecter ce genre d'outils à votre LDAP. +## Documentations et ressources + +* Site officiel de l'app : https://weblate.org +* Documentation officielle utilisateur : https://docs.weblate.org/ +* Documentation officielle de l'admin : https://docs.weblate.org/ +* Dépôt de code officiel de l'app : https://github.com/WeblateOrg/weblate +* Documentation YunoHost pour cette app : https://yunohost.org/app_weblate +* Signaler un bug : https://github.com/YunoHost-Apps/weblate_ynh/issues + +## Informations pour les développeurs + +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/weblate_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug +ou +sudo yunohost app upgrade weblate -u https://github.com/YunoHost-Apps/weblate_ynh/tree/testing --debug +``` + +**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/check_process b/check_process index f34e813..130a260 100644 --- a/check_process +++ b/check_process @@ -1,15 +1,10 @@ -# See here for more informations -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) + domain="domain.tld" + path="/path" + admin="john" password="randompass" - is_public=1 (PUBLIC|public=1|private=0) + is_public=1 github_account="myaccount" github_token="myoauthtoken" ; Checks @@ -20,7 +15,8 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=cef22ac5634565cecd2d8545229efe3fe79d85bc + #4.6.1 + upgrade=1 from_commit=3f8363cdc588e609a775cb8b78b9d080f96405d9 backup_restore=1 multi_instance=1 port_already_use=0 @@ -29,6 +25,6 @@ Email= Notification=all ;;; Upgrade options - ; commit=cef22ac5634565cecd2d8545229efe3fe79d85bc - name=Upgrade from 3.11.3 + ; commit=3f8363cdc588e609a775cb8b78b9d080f96405d9 + name=Upgrade from 4.6.1 manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&github_account=fake&github_token=fake diff --git a/conf/hub_config b/conf/hub_config index 289ab03..99df3d0 100644 --- a/conf/hub_config +++ b/conf/hub_config @@ -1,4 +1,4 @@ github.com: -- user: __GITHUBUSER__ - oauth_token: __GITHUBTOKEN__ +- user: __GITHUB_ACCOUNT__ + oauth_token: __GITHUB_TOKEN__ protocol: https diff --git a/conf/settings.4.1.1.py b/conf/settings.4.1.1.py index 52fe16b..3174475 100644 --- a/conf/settings.4.1.1.py +++ b/conf/settings.4.1.1.py @@ -136,7 +136,7 @@ USE_L10N = True USE_TZ = True # URL prefix to use, please see documentation for more details -URL_PREFIX = "__PATHURL__" +URL_PREFIX = "__PATH_URL__" # Absolute filesystem path to the directory that will hold user-uploaded files. MEDIA_ROOT = os.path.join(DATA_DIR, "media") diff --git a/conf/settings.py b/conf/settings.py index e15e977..8a56107 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -35,6 +35,15 @@ import os import platform from logging.handlers import SysLogHandler +# Title of site to use +SITE_TITLE = "Weblate" + +# Site domain +SITE_DOMAIN = "__DOMAIN__" + +# Whether site uses https +ENABLE_HTTPS = True + # # Django settings for Weblate project. # @@ -42,7 +51,7 @@ from logging.handlers import SysLogHandler DEBUG = False ADMINS = ( - ('__ADMIN__', '__ADMINMAIL__'), + ('__ADMIN__', '__ADMIN_MAIL__'), ) MANAGERS = ADMINS @@ -52,9 +61,9 @@ DATABASES = { # Use "postgresql" or "mysql". "ENGINE": "django.db.backends.postgresql", # Database name. - "NAME": "__NAME__", + "NAME": "__APP__", # Database user. - "USER": "__NAME__", + "USER": "__APP__", # Name of role to alter to set parameters in PostgreSQL, # use in case role name is different than user used for authentication. # "ALTER_ROLE": "weblate", @@ -135,6 +144,7 @@ LANGUAGES = ( ("sr", "Српски"), ("sr-latn", "Srpski"), ("sv", "Svenska"), + ("th", "ไทย"), ("tr", "Türkçe"), ("uk", "Українська"), ("zh-hans", "简体字"), @@ -158,7 +168,7 @@ USE_TZ = True DEFAULT_AUTO_FIELD = "django.db.models.AutoField" # URL prefix to use, please see documentation for more details -URL_PREFIX = "__PATHURL__" +URL_PREFIX = "__PATH_URL__" # Absolute filesystem path to the directory that will hold user-uploaded files. MEDIA_ROOT = os.path.join(DATA_DIR, "media") @@ -221,8 +231,8 @@ TEMPLATES = [ # GitHub username and token for sending pull requests. # Please see the documentation for more details. -GITHUB_USERNAME = "__GITHUBUSER__" -GITHUB_TOKEN = "__GITHUBTOKEN__" +GITHUB_USERNAME = "__GITHUB_ACCOUNT__" +GITHUB_TOKEN = "__GITHUB_TOKEN__" # GitLab username and token for sending merge requests. # Please see the documentation for more details. @@ -365,6 +375,7 @@ MIDDLEWARE = [ "weblate.accounts.middleware.RequireLoginMiddleware", "weblate.api.middleware.ThrottlingMiddleware", "weblate.middleware.SecurityMiddleware", + "weblate.wladmin.middleware.ManageMiddleware", ] ROOT_URLCONF = "weblate.urls" @@ -529,6 +540,7 @@ MT_SERVICES = ( # "weblate.machinery.glosbe.GlosbeTranslation", # "weblate.machinery.google.GoogleTranslation", # "weblate.machinery.googlev3.GoogleV3Translation", + # "weblate.machinery.libretranslate.LibreTranslateTranslation", # "weblate.machinery.microsoft.MicrosoftCognitiveTranslation", # "weblate.machinery.microsoftterminology.MicrosoftTerminologyService", # "weblate.machinery.modernmt.ModernMTTranslation", @@ -551,6 +563,10 @@ MT_APERTIUM_APY = None # DeepL API key MT_DEEPL_KEY = None +# LibreTranslate +MT_LIBRETRANSLATE_API_URL = None +MT_LIBRETRANSLATE_KEY = None + # Microsoft Cognitive Services Translator API, register at # https://portal.azure.com/ MT_MICROSOFT_COGNITIVE_KEY = None @@ -599,15 +615,6 @@ MT_SAP_USERNAME = None MT_SAP_PASSWORD = None MT_SAP_USE_MT = True -# Title of site to use -SITE_TITLE = "Weblate" - -# Site domain -SITE_DOMAIN = "__DOMAIN__" - -# Whether site uses https -ENABLE_HTTPS = True - # Use HTTPS when creating redirect URLs for social authentication, see # documentation for more details: # https://python-social-auth-docs.readthedocs.io/en/latest/configuration/settings.html#processing-redirects-and-urlopen @@ -716,6 +723,7 @@ CRISPY_TEMPLATE_PACK = "bootstrap3" # "weblate.checks.format.PerlFormatCheck", # "weblate.checks.format.JavaScriptFormatCheck", # "weblate.checks.format.LuaFormatCheck", +# "weblate.checks.format.ObjectPascalFormatCheck", # "weblate.checks.format.SchemeFormatCheck", # "weblate.checks.format.CSharpFormatCheck", # "weblate.checks.format.JavaFormatCheck", @@ -931,7 +939,7 @@ MATOMO_SITE_ID = None MATOMO_URL = None GOOGLE_ANALYTICS_ID = None SENTRY_DSN = None -SENTRY_ENVIRONMENT = None +SENTRY_ENVIRONMENT = SITE_DOMAIN AKISMET_API_KEY = None try: diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index 31a67b9..bbabbad 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -5,7 +5,7 @@ protocol = uwsgi socket = /var/run/__APP__/socket # http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info -mount = __PATH__=__FINALPATH__/venv/lib/__PYTHONPATH__/site-packages/weblate/wsgi.py +mount = __PATH_URL__=__FINALPATH__/venv/lib/__WEBLATE_PYPATH__/site-packages/weblate/wsgi.py # Add path to Weblate checkout if you did not install # Weblate by pip diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..92a23fe --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +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. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..f72b0f3 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +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. \ No newline at end of file diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..fa73e74 --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,17 @@ +## GitHub + +You'll need to give Weblate a GitHub user and a token. Please read [GitHub's documentation about token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). +This user will only be used to open the pull-request, each translation keep his author. + +**SSH keys**, you will have to go in administration, and generate a public key for Weblate and add github.com so Weblate knows the fingerprint. Please note if your account already have a public key (ssh-rsa), you will have to manually add the Weblate's one to your GitHub account. + +## Settings and upgrades + +Almost everything related to Weblate's configuration is handled in a `settings.py` file. +You can edit the file `$final_path/local_settings.py` to enable or disable features. + +# Miscellaneous + +## LDAP connexion + +It doesn't work yet, but while [it looks doable](https://docs.weblate.org/en/latest/admin/auth.html?highlight=LDAP#ldap-authentication), I'm unsure it is a good idea to connect this kind of tools to your LDAP. diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..ffab432 --- /dev/null +++ b/doc/DISCLAIMER_fr.md @@ -0,0 +1,17 @@ +## GitHub + +Vous devrez donner à Weblate un utilisateur GitHub et un jeton. Veuillez lire [la documentation de GitHub sur le jeton](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). +Cet utilisateur ne sera utilisé que pour ouvrir la pull-request, chaque traduction garde son auteur. + +**Clés SSH**, vous devrez vous rendre dans l'administration, générer une clé publique pour Weblate et ajouter github.com pour que Weblate connaisse l'empreinte digitale. Veuillez noter que si votre compte possède déjà une clé publique (ssh-rsa), vous devrez ajouter manuellement celle de Weblate à votre compte GitHub. + +## Paramètres et mises à niveau + +Presque tout ce qui concerne la configuration de Weblate est géré dans un fichier `settings.py`. +Vous pouvez éditer le fichier `$final_path/local_settings.py` pour activer ou désactiver des fonctionnalités. + +# Divers + +## Connexion LDAP + +Cela ne fonctionne pas encore, mais bien que [cela semble faisable](https://docs.weblate.org/en/latest/admin/auth.html?highlight=LDAP#ldap-authentication), je ne suis pas sûr que ce soit le cas une bonne idée de connecter ce genre d'outils à votre LDAP. \ No newline at end of file diff --git a/doc/screenshots/BigScreenshot.png b/doc/screenshots/BigScreenshot.png new file mode 100644 index 0000000..b2bf4d9 Binary files /dev/null and b/doc/screenshots/BigScreenshot.png differ diff --git a/manifest.json b/manifest.json index 6722699..c3c1165 100644 --- a/manifest.json +++ b/manifest.json @@ -3,22 +3,30 @@ "id": "weblate", "packaging_format": 1, "description": { - "en": "A translation platform using Git and Python", - "fr": "Une plateforme de traduction utilisant Git et Python" + "en": "Translation platform using Git and Python", + "fr": "Plateforme de traduction utilisant Git et Python" }, - "version": "4.7~ynh1", + "version": "4.8~ynh1", "url": "https://weblate.org", + "upstream": { + "license": "AGPL-3.0", + "website": "https://weblate.org", + "demo": "https://hosted.weblate.org/", + "admindoc": "https://docs.weblate.org/", + "userdoc": "https://docs.weblate.org/", + "code": "https://github.com/WeblateOrg/weblate" + }, "license": "AGPL-3.0", "maintainer": { - "name": "", - "email": "" + "name": "YunoHost Contributors", + "email": "apps@yunohost.org" }, "previous_maintainers": [{ "name": "Jean-Baptiste Holcroft", "email": "jean-baptiste@holcroft.fr" }], "requirements": { - "yunohost": ">= 4.1.0" + "yunohost": ">= 4.2.0" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 063e018..bf0aa38 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,8 +12,7 @@ pkg_dependencies="libxml2-dev libxslt-dev libfreetype6-dev libjpeg-dev libz-dev libpq-dev libglib2.0-dev mailutils python-celery-common hub" # Weblate's version for PIP and settings file -weblate_version="4.7" - +weblate_version="4.8" debian_maj_version=$(sed 's/\..*//' /etc/debian_version) @@ -138,5 +137,3 @@ ynh_redis_remove_db() { #================================================= # EXPERIMENTAL HELPERS #================================================= - - diff --git a/scripts/change_url b/scripts/change_url index 47a73ca..4da5110 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 final_path=$(ynh_app_setting_get --app="$app" --key=final_path) is_public=$(ynh_app_setting_get --app="$app" --key=is_public) @@ -67,7 +67,7 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping systemd services..." +ynh_script_progression --message="Stopping systemd services..." --weight=1 ynh_systemd_action --service_name="$app" --action="stop" ynh_systemd_action --service_name="$app-celery" --action="stop" @@ -77,7 +77,7 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -108,7 +108,7 @@ fi #================================================= # MODIFY SETTINGS #================================================= -ynh_script_progression --message="Modify weblate's config file..." +ynh_script_progression --message="Modify weblate's config file..." --weight=1 settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" ynh_backup_if_checksum_is_different --file="$settings" @@ -160,7 +160,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index 0c7bdaf..61d19c1 100755 --- a/scripts/install +++ b/scripts/install @@ -33,7 +33,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -46,7 +46,7 @@ mkdir -p "$final_path" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app="$app" --key=domain --value="$domain" ynh_app_setting_set --app="$app" --key=path --value="$path_url" @@ -67,7 +67,7 @@ ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE A PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name="$app") db_user=$db_name @@ -81,7 +81,7 @@ ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated nginx config ynh_add_nginx_config @@ -89,7 +89,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." --weight=1 # Hub needs a home directory with a config file ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell @@ -97,12 +97,10 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell #================================================= # CONFIGURE HUB #================================================= -ynh_script_progression --message="Configure hub..." +ynh_script_progression --message="Configure hub..." --weight=1 mkdir "$final_path/.config/" -cp ../conf/hub_config "$final_path/.config/hub" -ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$final_path/.config/hub" -ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$final_path/.config/hub" +ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" cat < "$final_path/.bashrc" eval "$(hub alias -s /bin/bash)" @@ -141,31 +139,16 @@ chown -R "$app": "$final_path" # https://docs.weblate.org/en/latest/admin/install.html#installation # TODO: use --extra-search-dir=/path/to/dists #================================================= -ynh_script_progression --message="Create weblate configuration file..." +ynh_script_progression --message="Create weblate configuration file..." --weight=1 db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd) admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) key=$(ynh_string_random --length=50) redis_db=$(ynh_redis_get_free_db) - +path_url="${path_url%/}" settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" -cp "../conf/settings.py" "$settings" -ynh_replace_string --match_string="__NAME__" --replace_string="$app" --target_file="$settings" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings" -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings" -ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings" -ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$settings" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$settings" -ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$settings" -ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$settings" -ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings" -ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$settings" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings" - -# remove last "/" of $path_url -ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" --target_file="$settings" +ynh_add_config --template="../conf/settings.py" --destination="$settings" ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" @@ -209,36 +192,27 @@ ynh_store_file_checksum --file="$settings" #================================================= # SPECIFIC SETUP UWSGI #================================================= -ynh_script_progression --message="Configure uwsgi..." - +ynh_script_progression --message="Configure uwsgi..." --weight=1 finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" -cp ../conf/uwsgi.ini "$finaluwsgiini" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finaluwsgiini" -ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$finaluwsgiini" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finaluwsgiini" -ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$finaluwsgiini" - -ynh_store_file_checksum --file="$finaluwsgiini" +ynh_add_config --template="../conf/uwsgi.ini" --destination="$finaluwsgiini" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." --weight=2 ynh_add_systemd_config --service="$app" --template="weblate.service" #================================================= # ACTIVATE CELERY #================================================= -ynh_script_progression --message="Configure celery..." +ynh_script_progression --message="Configure celery..." --weight=1 celeryconf="$final_path/celery-weblate" -cp ../conf/celery-weblate "$celeryconf" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$celeryconf" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$celeryconf" +ynh_add_config --template="../conf/celery-weblate" --destination="$celeryconf" ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service" @@ -260,7 +234,7 @@ chmod -R o-rwx "$final_path" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." +ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate --non-append @@ -268,7 +242,7 @@ ynh_use_logrotate --non-append #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 yunohost service add "$app" --log "/var/log/$app/weblate.log" yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log" @@ -276,9 +250,7 @@ yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." - - +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ "$is_public" -eq 1 ] @@ -297,7 +269,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name="nginx" --action="reload" @@ -312,4 +284,8 @@ If you facing an issue or want to improve this app, please open a new issue in t ynh_send_readme_to_admin "$message" "$admin" +#================================================= +# END OF SCRIPT +#================================================= + ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index a490614..3db18e2 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app="$app" --key=domain) @@ -29,14 +29,14 @@ final_path=$(ynh_app_setting_get --app="$app" --key=final_path) # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status "$app" >/dev/null 2>&1 then - ynh_script_progression --message="Removing $app service integration..." + ynh_script_progression --message="Removing $app service integration..." --weight=1 yunohost service remove "$app" fi # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status "$app-celery" >/dev/null 2>&1 then - ynh_script_progression --message="Removing $app-celery service integration..." + ynh_script_progression --message="Removing $app-celery service integration..." --weight=1 yunohost service remove "$app-celery" fi @@ -51,7 +51,7 @@ ynh_remove_systemd_config --service="$app-celery" #================================================= # REMOVE THE PostgreSQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." +ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user=$db_user --db_name=$db_name @@ -75,7 +75,7 @@ ynh_exec_warn_less ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." --weight=2 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -83,7 +83,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config @@ -91,7 +91,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 # Remove the app-specific logrotate config ynh_remove_logrotate @@ -109,7 +109,7 @@ ynh_secure_remove --file="/var/run/$app-celery" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user ynh_system_user_delete --username="$app" diff --git a/scripts/restore b/scripts/restore index b590397..2389760 100755 --- a/scripts/restore +++ b/scripts/restore @@ -18,7 +18,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -32,7 +32,7 @@ db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -50,7 +50,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=4 ynh_restore_file --origin_path="$final_path" @@ -60,7 +60,7 @@ ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/sit #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell @@ -100,7 +100,7 @@ ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./d #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." --weight=4 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet @@ -110,14 +110,14 @@ systemctl enable "$app-celery" --quiet #================================================= # RESTORE UWSGI #================================================= -ynh_script_progression --message="Restoring uwsgi configurations..." +ynh_script_progression --message="Restoring uwsgi configurations..." --weight=1 ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 yunohost service add "$app" --log "/var/log/$app/weblate.log" yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log" @@ -142,7 +142,7 @@ ynh_systemd_action --service_name="$app-celery" --action="start" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name="nginx" --action="reload" diff --git a/scripts/upgrade b/scripts/upgrade index 9763411..91b1115 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,12 +11,11 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME path_url=$(ynh_app_setting_get --app="$app" --key=path) -is_public=$(ynh_app_setting_get --app="$app" --key=is_public) final_path=$(ynh_app_setting_get --app="$app" --key=final_path) db_name=$(ynh_app_setting_get --app="$app" --key=db_name) db_user=$db_name @@ -56,16 +55,7 @@ fi #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." - -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 if [[ -d "$final_path/bin/" ]] then @@ -94,7 +84,7 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=3 # Create a dedicated nginx config ynh_add_nginx_config @@ -104,14 +94,14 @@ ynh_add_nginx_config #================================================= # Update dependencies #================================================= -ynh_script_progression --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." --weight=5 ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a system user ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell @@ -119,12 +109,10 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell #================================================= # CONFIGURE HUB #================================================= -ynh_script_progression --message="Configure hub..." +ynh_script_progression --message="Configure hub..." --weight=2 mkdir -p "$final_path/.config/" -cp ../conf/hub_config "$final_path/.config/hub" -ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$final_path/.config/hub" -ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$final_path/.config/hub" +ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" cat < "$final_path/.bashrc" eval "$(hub alias -s /bin/bash)" @@ -133,36 +121,27 @@ EOF #================================================= # SPECIFIC SETUP UWSGI #================================================= -ynh_script_progression --message="Configure uwsgi..." +ynh_script_progression --message="Configure uwsgi..." --weight=2 finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" -ynh_backup_if_checksum_is_different --file="$finaluwsgiini" -cp ../conf/uwsgi.ini "$finaluwsgiini" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finaluwsgiini" -ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$finaluwsgiini" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finaluwsgiini" -ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$finaluwsgiini" - -ynh_store_file_checksum --file="$finaluwsgiini" +ynh_add_config --template="../conf/uwsgi.ini" --destination="$finaluwsgiini" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." --weight=3 ynh_add_systemd_config --service="$app" --template="weblate.service" #================================================= # ACTIVATE CELERY #================================================= -ynh_script_progression --message="Configure celery..." +ynh_script_progression --message="Configure celery..." --weight=2 celeryconf="$final_path/celery-weblate" -cp ../conf/celery-weblate "$celeryconf" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$celeryconf" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$celeryconf" +ynh_add_config --template="../conf/celery-weblate" --destination="$celeryconf" ynh_add_systemd_config --service="$app-celery" --template="celery-weblate.service" @@ -202,28 +181,12 @@ upgrade() { #================================================= # MODIFY A CONFIG FILE #================================================= - ynh_script_progression --message="Create weblate configuration file..." + ynh_script_progression --message="Create weblate configuration file..." --weight=2 # save old settings file settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" + path_url="${path_url%/}" - ynh_backup_if_checksum_is_different --file="$settings" - cp "$settings_template" "$settings" - - ynh_replace_string --match_string="__NAME__" --replace_string="$app" --target_file="$settings" - ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings" - ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings" - ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings" - ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings" - ynh_replace_string --match_string="__KEY__" --replace_string="$key" --target_file="$settings" - ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$settings" - ynh_replace_string --match_string="__GITHUBUSER__" --replace_string="$github_account" --target_file="$settings" - ynh_replace_string --match_string="__GITHUBTOKEN__" --replace_string="$github_token" --target_file="$settings" - ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings" - ynh_replace_string --match_string="__PYTHONPATH__" --replace_string="$weblate_pypath" --target_file="$settings" - ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings" - - # remove last "/" of $path_url - ynh_replace_string --match_string="__PATHURL__" --replace_string="${path_url%/}" --target_file="$settings" + ynh_add_config --template="../conf/settings.py" --destination="$settings" ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" @@ -286,7 +249,7 @@ upgrade $weblate_version "../conf/settings.py" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -294,7 +257,7 @@ ynh_use_logrotate --non-append #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 yunohost service add "$app" --log "/var/log/$app/weblate.log" yunohost service add "$app-celery" --log "/var/log/$app/weblate-celery-w1.log" @@ -322,22 +285,10 @@ ynh_script_progression --message="Starting systemd services..." --weight=5 ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name="$app-celery" --action="start" -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." - -# Make app public if necessary -if [ "$is_public" -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" -fi - #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -345,4 +296,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last \ No newline at end of file +ynh_script_progression --message="Upgrade of $app completed" --last