1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00

Convert to v2 + some fixes

This commit is contained in:
Thomas 2024-01-17 14:07:41 +01:00 committed by GitHub
parent c3d0058d3d
commit 3d8762c2ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 345 additions and 364 deletions

View file

@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
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. 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.3.1~ynh1 **Shipped version:** 4.18.2~ynh1
**Demo:** https://hosted.weblate.org/ **Demo:** https://hosted.weblate.org/

View file

@ -18,7 +18,7 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
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. 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.3.1~ynh1 **Version incluse :** 4.18.2~ynh1
**Démo :** https://hosted.weblate.org/ **Démo :** https://hosted.weblate.org/

View file

@ -1,31 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
path="/path"
is_public=1
admin="john"
password="1Strong-Password"
used_forge="GitLab"
forge_username="myusername"
forge_token="myoauthtoken"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
# 4.9~ynh1
upgrade=1 from_commit=7fec5a47a80e00458a31f1270c4ace822961e7bf
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=all
;;; Upgrade options
; 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

View file

@ -2,7 +2,7 @@
CELERYD_NODES="celery notify memory backup translate" CELERYD_NODES="celery notify memory backup translate"
# Absolute or relative path to the 'celery' command: # Absolute or relative path to the 'celery' command:
CELERY_BIN="__FINALPATH__/venv/bin/celery" CELERY_BIN="__INSTALL_DIR__/venv/bin/celery"
# App instance to use # App instance to use
# comment out this line if you don't use an app # comment out this line if you don't use an app

View file

@ -6,8 +6,8 @@ After=network.target
Type=forking Type=forking
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
EnvironmentFile=__FINALPATH__/celery-weblate EnvironmentFile=__INSTALL_DIR__/celery-weblate
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
RuntimeDirectory=__APP__ RuntimeDirectory=__APP__
RuntimeDirectoryPreserve=restart RuntimeDirectoryPreserve=restart
LogsDirectory=celery LogsDirectory=celery

View file

@ -2,31 +2,31 @@
# https://github.com/WeblateOrg/weblate/blob/master/weblate/examples/weblate.nginx.conf # https://github.com/WeblateOrg/weblate/blob/master/weblate/examples/weblate.nginx.conf
location = __PATH__/favicon.ico { location = __PATH__/favicon.ico {
# DATA_DIR/static/favicon.ico # DATA_DIR/static/favicon.ico
alias __FINALPATH__/data/static/favicon.ico; alias __INSTALL_DIR__/data/static/favicon.ico;
expires 30d; expires 30d;
} }
location = __PATH__/robots.txt { location = __PATH__/robots.txt {
# DATA_DIR/static/robots.txt # DATA_DIR/static/robots.txt
alias __FINALPATH__/data/static/robots.txt; alias __INSTALL_DIR__/data/static/robots.txt;
expires 30d; expires 30d;
} }
location __PATH__/static/ { location __PATH__/static/ {
# DATA_DIR/static/ # DATA_DIR/static/
alias __FINALPATH__/data/static/; alias __INSTALL_DIR__/data/static/;
expires 30d; expires 30d;
} }
location __PATH__/media/ { location __PATH__/media/ {
# DATA_DIR/media/ # DATA_DIR/media/
alias __FINALPATH__/data/media/; alias __INSTALL_DIR__/data/media/;
expires 30d; expires 30d;
} }
location __PATH__/ { location __PATH__/ {
# Path to source # Path to source
alias __FINALPATH__/ ; alias __INSTALL_DIR__/ ;
include uwsgi_params; include uwsgi_params;
# Needed for long running operations in admin interface # Needed for long running operations in admin interface

View file

@ -63,7 +63,7 @@ DATABASES = {
} }
} }
BASE_DIR = "__FINALPATH__" BASE_DIR = "__INSTALL_DIR__"
# Data directory # Data directory
DATA_DIR = os.path.join(BASE_DIR, "data") DATA_DIR = os.path.join(BASE_DIR, "data")
@ -136,7 +136,7 @@ USE_L10N = True
USE_TZ = True USE_TZ = True
# URL prefix to use, please see documentation for more details # URL prefix to use, please see documentation for more details
URL_PREFIX = "__PATH_URL__" URL_PREFIX = "__PATH__"
# Absolute filesystem path to the directory that will hold user-uploaded files. # Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = os.path.join(DATA_DIR, "media") MEDIA_ROOT = os.path.join(DATA_DIR, "media")

View file

@ -5,7 +5,7 @@
################################################################################ ################################################################################
# Please do not modify this file, it will be reset at the next update. # Please do not modify this file, it will be reset at the next update.
# You can edit the file __FINALPATH__/local_settings.py and add/modify the settings you need. # You can edit the file __INSTALL_DIR__/local_settings.py and add/modify the settings you need.
# The parameters you add in local_settings.py will overwrite these, # The parameters you add in local_settings.py will overwrite these,
# but you can use the options and documentation in this file to find out what can be done. # but you can use the options and documentation in this file to find out what can be done.
@ -78,7 +78,7 @@ DATABASES = {
# Data directory, you can use following for the development purposes: # Data directory, you can use following for the development purposes:
# os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "data") # os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "data")
DATA_DIR = os.path.join("__FINALPATH__", "data") DATA_DIR = os.path.join("__INSTALL_DIR__", "data")
CACHE_DIR = f"{DATA_DIR}/cache" CACHE_DIR = f"{DATA_DIR}/cache"
# Local time zone for this installation. Choices can be found here: # Local time zone for this installation. Choices can be found here:
@ -156,7 +156,7 @@ USE_TZ = True
DEFAULT_AUTO_FIELD = "django.db.models.AutoField" DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
# URL prefix to use, please see documentation for more details # URL prefix to use, please see documentation for more details
URL_PREFIX = "__PATH_URL__" URL_PREFIX = "__PATH__"
# Absolute filesystem path to the directory that will hold user-uploaded files. # Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = os.path.join(DATA_DIR, "media") MEDIA_ROOT = os.path.join(DATA_DIR, "media")

View file

@ -5,14 +5,14 @@ protocol = uwsgi
socket = /var/run/__APP__/socket 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 # 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_URL__=__FINALPATH__/venv/lib/__WEBLATE_PYPATH__/site-packages/weblate/wsgi.py mount = __PATH__=__INSTALL_DIR__/venv/lib/__WEBLATE_PYPATH__/site-packages/weblate/wsgi.py
# Add path to Weblate checkout if you did not install # Add path to Weblate checkout if you did not install
# Weblate by pip # Weblate by pip
# python-path = /path/to/weblate # python-path = /path/to/weblate
# In case you're using virtualenv uncomment this: # In case you're using virtualenv uncomment this:
virtualenv = __FINALPATH__/venv virtualenv = __INSTALL_DIR__/venv
# Needed for OAuth/OpenID # Needed for OAuth/OpenID
buffer-size = 8192 buffer-size = 8192

View file

@ -1,95 +0,0 @@
{
"name": "Weblate",
"id": "weblate",
"packaging_format": 1,
"description": {
"en": "Translation platform using Git and Python",
"fr": "Plateforme de traduction utilisant Git et Python"
},
"version": "5.3.1~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": "YunoHost Contributors",
"email": "apps@yunohost.org"
},
"previous_maintainers": [
{
"name": "Jean-Baptiste Holcroft",
"email": "jean-baptiste@holcroft.fr"
}
],
"requirements": {
"yunohost": ">= 11.2"
},
"multi_instance": true,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/weblate",
"default": "/weblate"
},
{
"name": "is_public",
"type": "boolean",
"default": false
},
{
"name": "admin",
"type": "user"
},
{
"name": "password",
"type": "password"
},
{
"name": "used_forge",
"type": "select",
"ask": {
"en": "Choose the forge you use",
"fr": "Choisissez la forge que vous utilisez"
},
"choices": [
"GitHub",
"GitLab"
],
"default": "GitHub"
},
{
"name": "forge_username",
"type": "string",
"ask": {
"en": "Your forge's username",
"fr": "Nom d'utilisateur de votre forge"
},
"example": "Your username"
},
{
"name": "forge_token",
"type": "string",
"ask": {
"en": "Your forge's token (OAuth)",
"fr": "Jeton de votre forge (OAuth)"
},
"example": "A secret token"
}
]
}
}

86
manifest.toml Normal file
View file

@ -0,0 +1,86 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "weblate"
name = "Weblate"
description.en = "Translation platform using Git and Python"
description.fr = "Plateforme de traduction utilisant Git et Python"
version = "4.18.2~ynh1"
maintainers = ["YunoHost Contributors"]
[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"
cpe = "cpe:2.3:a:weblate:weblate"
[integration]
yunohost = ">= 11.2.0"
architectures = "all"
multi_instance = true
ldap = "false"
sso = "false"
disk = "1G"
ram.build = "3G"
ram.runtime = "3G"
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/weblate"
[install.init_main_permission]
type = "group"
default = false
[install.admin]
type = "user"
[install.password]
type = "password"
[install.used_forge]
ask.en = "Choose the forge you use"
ask.fr = "Choisissez la forge que vous utilisez"
type = "string"
choices = ["GitHub", "GitLab"]
default = "GitHub"
optional = true
[install.forge_username]
ask.en = "Your forge's username"
ask.fr = "Nom d'utilisateur de votre forge"
type = "string"
example = "Your username"
optional = true
[install.forge_token]
ask.en = "Your forge's token (OAuth)"
ask.fr = "Jeton de votre forge (OAuth)"
type = "string"
example = "A secret token"
optional = true
[resources]
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = "libxml2-dev, libxslt-dev, libfreetype6-dev, libjpeg-dev, libz-dev, libyaml-dev, libacl1-dev, libacl1, libssl-dev, liblz4-dev, libzstd-dev, libxxhash-dev"
[resources.database]
type = "postgresql"

View file

@ -5,17 +5,17 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
weblate_dependencies="libxml2-dev libxslt-dev libfreetype6-dev libjpeg-dev libz-dev libyaml-dev \ #REMOVEME? weblate_dependencies="libxml2-dev libxslt-dev libfreetype6-dev libjpeg-dev libz-dev libyaml-dev \
libffi-dev libcairo-dev gir1.2-pango-1.0 libgirepository1.0-dev \ libffi-dev libcairo-dev gir1.2-pango-1.0 libgirepository1.0-dev \
libacl1-dev libssl-dev libpq-dev libjpeg62-turbo-dev build-essential \ libacl1-dev libssl-dev libpq-dev libjpeg62-turbo-dev build-essential \
python3-gdbm python3-dev python3-pip python3-virtualenv virtualenv git \ python3-gdbm python3-dev python3-pip python3-virtualenv virtualenv git \
uwsgi uwsgi-plugin-python3 redis-server postgresql postgresql-contrib hub" uwsgi uwsgi-plugin-python3 redis-server postgresql postgresql-contrib hub"
# because weblate install borgbackup # because weblate install borgbackup
borgbackup_dependencies="libacl1-dev libacl1 libssl-dev liblz4-dev libzstd-dev libxxhash-dev \ #REMOVEME? borgbackup_dependencies="libacl1-dev libacl1 libssl-dev liblz4-dev libzstd-dev libxxhash-dev \
build-essential pkg-config python3-pkgconfig" build-essential pkg-config python3-pkgconfig"
pkg_dependencies="$weblate_dependencies $borgbackup_dependencies" #REMOVEME? pkg_dependencies="$weblate_dependencies $borgbackup_dependencies"
debian_maj_version=$(sed 's/\..*//' /etc/debian_version) debian_maj_version=$(sed 's/\..*//' /etc/debian_version)

View file

@ -14,22 +14,22 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..." #REMOVEME? ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -40,7 +40,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -13,55 +13,55 @@ source /usr/share/yunohost/helpers
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
old_domain=$YNH_APP_OLD_DOMAIN #REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH #REMOVEME? old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN #REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH #REMOVEME? new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config" #REMOVEME? # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#================================================= #=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." #REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting #REMOVEME? ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" #REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED # CHECK WHICH PARTS SHOULD BE CHANGED
#================================================= #=================================================
change_domain=0 #REMOVEME? change_domain=0
if [ "$old_domain" != "$new_domain" ] #REMOVEME? if [ "$old_domain" != "$new_domain" ]
then then
change_domain=1 #REMOVEME? change_domain=1
fi fi
change_path=0 #REMOVEME? change_path=0
if [ "$old_path" != "$new_path" ] #REMOVEME? if [ "$old_path" != "$new_path" ]
then then
change_path=1 #REMOVEME? change_path=1
fi fi
#================================================= #=================================================
@ -79,28 +79,30 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="syst
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file # Change the path in the NGINX config file
if [ $change_path -eq 1 ] if [ $change_path -eq 1 ]
then then
# Make a backup of the original NGINX config file if modified # Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path" #REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper # Set global variables for NGINX helper
domain="$old_domain" #REMOVEME? domain="$old_domain"
path_url="$new_path" #REMOVEME? path="$new_path"
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config #REMOVEME? ynh_add_nginx_config
fi fi
# Change the domain for NGINX # Change the domain for NGINX
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path" #REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf #REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location # Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" #REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi fi
#================================================= #=================================================
@ -110,16 +112,16 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Modify weblate's config file..." --weight=1 ynh_script_progression --message="Modify weblate's config file..." --weight=1
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" 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 --file="$settings"
# Change the path in the nginx config file #REMOVEME? # Change the path in the nginx config file
if [ $change_path -eq 1 ] if [ $change_path -eq 1 ]
then then
ynh_replace_string --match_string="URL_PREFIX = \"${old_path%/}\"" --replace_string="URL_PREFIX = \"${new_path%/}\"" --target_file="$settings" ynh_replace_string --match_string="URL_PREFIX = \"${old_path%/}\"" --replace_string="URL_PREFIX = \"${new_path%/}\"" --target_file="$settings"
fi fi
# Change the domain for nginx #REMOVEME? # Change the domain for nginx
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
# replace SERVER_EMAIL # replace SERVER_EMAIL
@ -139,7 +141,7 @@ ynh_store_file_checksum --file="$settings"
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
ynh_backup_if_checksum_is_different --file="$finaluwsgiini" ynh_backup_if_checksum_is_different --file="$finaluwsgiini"
# Change the path in the nginx config file #REMOVEME? # Change the path in the nginx config file
if [ $change_path -eq 1 ] if [ $change_path -eq 1 ]
then then
ynh_replace_string --match_string="mount = $old_path=" --replace_string="mount = $new_path=" --target_file="$finaluwsgiini" ynh_replace_string --match_string="mount = $old_path=" --replace_string="mount = $new_path=" --target_file="$finaluwsgiini"
@ -160,9 +162,9 @@ ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/va
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -13,26 +13,26 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN #REMOVEME? domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH #REMOVEME? path=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC #REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN #REMOVEME? admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD #REMOVEME? password=$YNH_APP_ARG_PASSWORD
used_forge=$YNH_APP_ARG_USED_FORGE #REMOVEME? used_forge=$YNH_APP_ARG_USED_FORGE
forge_username=$YNH_APP_ARG_FORGE_USERNAME #REMOVEME? forge_username=$YNH_APP_ARG_FORGE_USERNAME
forge_token=$YNH_APP_ARG_FORGE_TOKEN #REMOVEME? forge_token=$YNH_APP_ARG_FORGE_TOKEN
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
key=$(ynh_string_random --length=50) key=$(ynh_string_random --length=50)
@ -40,22 +40,22 @@ key=$(ynh_string_random --length=50)
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1 #REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app #REMOVEME? install_dir=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" #REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain #REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url #REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
ynh_app_setting_set --app=$app --key=admin --value=$admin #REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=used_forge --value=$used_forge 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_username --value=$forge_username
ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token
@ -65,44 +65,44 @@ ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=40 #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=40
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --weight=1 #REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --use_shell
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 #REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app) #REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name #REMOVEME? db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name #REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_test_if_first_run #REMOVEME? ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name #REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
mkdir -p "$final_path" mkdir -p "$install_dir"
mkdir -p "$final_path/avatar-cache" mkdir -p "$install_dir/avatar-cache"
mkdir -p "$final_path/data" mkdir -p "$install_dir/data"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -134,10 +134,10 @@ ynh_secure_remove --file="$tempdir"
if [ $used_forge = "GitHub" ] ; then if [ $used_forge = "GitHub" ] ; then
ynh_script_progression --message="Configure hub..." --weight=1 ynh_script_progression --message="Configure hub..." --weight=1
mkdir "$final_path/.config/" mkdir "$install_dir/.config/"
ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" ynh_add_config --template="../conf/hub_config" --destination="$install_dir/.config/hub"
cat <<EOF > "$final_path/.bashrc" cat <<EOF > "$install_dir/.bashrc"
eval "$(hub alias -s /bin/bash)" eval "$(hub alias -s /bin/bash)"
EOF EOF
fi fi
@ -147,26 +147,26 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Install weblate using PIP..." --weight=80 ynh_script_progression --message="Install weblate using PIP..." --weight=80
virtualenv --python=python3 "${final_path}/venv" virtualenv --python=python3 "${install_dir}/venv"
chown -R $app: "$final_path" chown -R $app: "$install_dir"
#run source in a 'sub shell' #run source in a 'sub shell'
( (
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${install_dir}/venv/bin/activate"
set -o nounset set -o nounset
cd "${final_path}" cd "${install_dir}"
sudo --user=$app $final_path/venv/bin/pip install --upgrade pip setuptools wheel pkgconfig xxhash sudo --user=$app $install_dir/venv/bin/pip install --upgrade pip setuptools wheel pkgconfig xxhash
# Read the "Note" section in https://docs.weblate.org/en/weblate-4.11/admin/install/venv-debian.html#python-modules # Read the "Note" section in https://docs.weblate.org/en/weblate-4.11/admin/install/venv-debian.html#python-modules
sudo --user=$app $final_path/venv/bin/pip install --force-reinstall --no-binary :all: cffi sudo --user=$app $install_dir/venv/bin/pip install --force-reinstall --no-binary :all: cffi
# Still needed with latest version of weblate? # Still needed with latest version of weblate?
sudo --user=$app BORG_OPENSSL_PREFIX=/usr/lib/x86_64-linux-gnu/ $final_path/venv/bin/pip install Weblate=="$(ynh_app_upstream_version)" sudo --user=$app BORG_OPENSSL_PREFIX=/usr/lib/x86_64-linux-gnu/ $install_dir/venv/bin/pip install Weblate=="$(ynh_app_upstream_version)"
sudo --user=$app $final_path/venv/bin/pip install psycopg2-binary ruamel.yaml aeidon phply sudo --user=$app $install_dir/venv/bin/pip install psycopg2-binary ruamel.yaml aeidon phply
#pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml #pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml
# specific to YunoHost package: # specific to YunoHost package:
sudo --user=$app $final_path/venv/bin/pip install django_sendmail_backend sudo --user=$app $install_dir/venv/bin/pip install django_sendmail_backend
) )
#================================================= #=================================================
@ -176,24 +176,24 @@ ynh_script_progression --message="Adding a configuration file..." --weight=1
redis_db=$(ynh_redis_get_free_db) redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db" ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db"
path_url="${path_url%/}" path="${path%/}"
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" settings="$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
set_forge_variables set_forge_variables
ynh_add_config --template="../conf/settings.py" --destination="$settings" ynh_add_config --template="../conf/settings.py" --destination="$settings"
ynh_add_config --template="../conf/celery-weblate" --destination="$final_path/celery-weblate" 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_add_config --template="../conf/uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini"
touch "$final_path/local_settings.py" touch "$install_dir/local_settings.py"
ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py"
# Set permissions to app files # Set permissions to app files
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app: "$final_path" chown -R $app: "$install_dir"
chown "$app:www-data" "$final_path" chown "$app:www-data" "$install_dir"
chown -R "$app:www-data" "$final_path/data" chown -R "$app:www-data" "$install_dir/data"
#================================================= #=================================================
# SPECIFIC SETUP Filling up the database # SPECIFIC SETUP Filling up the database
@ -203,23 +203,23 @@ ynh_script_progression --message="Filling up the database..." --weight=10
( (
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${install_dir}/venv/bin/activate"
set -o nounset set -o nounset
export DJANGO_SETTINGS_MODULE="weblate.settings" export DJANGO_SETTINGS_MODULE="weblate.settings"
cd "${final_path}" cd "${install_dir}"
# the user needs to be weblate for postgresql # the user needs to be weblate for postgresql
ynh_exec_warn_less sudo --user=$app $final_path/venv/bin/weblate migrate --noinput ynh_exec_warn_less sudo --user=$app $install_dir/venv/bin/weblate migrate --noinput
# generate static files # generate static files
ynh_exec_warn_less sudo --user=$app $final_path/venv/bin/weblate collectstatic --noinput ynh_exec_warn_less sudo --user=$app $install_dir/venv/bin/weblate collectstatic --noinput
ynh_exec_warn_less sudo --user=$app $final_path/venv/bin/weblate createadmin --no-color \ ynh_exec_warn_less sudo --user=$app $install_dir/venv/bin/weblate createadmin --no-color \
--password "$password" \ --password "$password" \
--username "$admin" \ --username "$admin" \
--email "$admin_mail" --email "$admin_mail"
# Check the configuration # Check the configuration
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later. # 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 $final_path/venv/bin/weblate check --deploy || true ynh_exec_warn_less sudo --user=$app $install_dir/venv/bin/weblate check --deploy || true
) )
#================================================= #=================================================
@ -259,20 +259,20 @@ ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/va
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1 #REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] #REMOVEME? if [ $is_public -eq 1 ]
then then
# Everyone can access the app. # Everyone can access the app.
# The "main" permission is automatically created before the install script. # The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors" #REMOVEME? ynh_permission_update --permission="main" --add="visitors"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name="nginx" --action="reload" ynh_systemd_action --service_name="nginx" --action="reload"

View file

@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name #REMOVEME? db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -61,18 +61,18 @@ ynh_remove_logrotate
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 #REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --weight=2 #REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" #REMOVEME? ynh_secure_remove --file="$install_dir"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -85,10 +85,10 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --weight=10 #REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=10
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_exec_warn_less ynh_remove_app_dependencies #REMOVEME? ynh_exec_warn_less ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE XXHASH # REMOVE XXHASH
@ -121,10 +121,10 @@ ynh_redis_remove_db
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1 #REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app #REMOVEME? ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -14,68 +14,68 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name #REMOVEME? db_user=$db_name
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1 #REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \ #REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $install_dir "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 #REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --use_shell
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=4 ynh_script_progression --message="Restoring the app main directory..." --weight=4
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
touch "$final_path/local_settings.py" touch "$install_dir/local_settings.py"
ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app: "$final_path" chown -R $app: "$install_dir"
chown $app:www-data "$final_path" chown $app:www-data "$install_dir"
chown -R $app:www-data "$final_path/data" chown -R $app:www-data "$install_dir/data"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=40 #REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=40
# Define and install dependencies # Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
@ -87,11 +87,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5 #REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_test_if_first_run #REMOVEME? ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd #REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql

View file

@ -12,21 +12,21 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) #REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name #REMOVEME? db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
used_forge=$(ynh_app_setting_get --app=$app --key=used_forge) #REMOVEME? used_forge=$(ynh_app_setting_get --app=$app --key=used_forge)
forge_username=$(ynh_app_setting_get --app=$app --key=forge_username) #REMOVEME? forge_username=$(ynh_app_setting_get --app=$app --key=forge_username)
forge_token=$(ynh_app_setting_get --app=$app --key=forge_token) #REMOVEME? forge_token=$(ynh_app_setting_get --app=$app --key=forge_token)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
key=$(ynh_string_random --length=50) key=$(ynh_string_random --length=50)
@ -40,17 +40,17 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=40 #REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=40
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -67,16 +67,16 @@ ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="syst
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if ynh_legacy_permissions_exists #REMOVEME? if ynh_legacy_permissions_exists
then then
ynh_legacy_permissions_delete_all #REMOVEME? ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public ynh_app_setting_delete --app=$app --key=is_public
fi fi
if [[ -d "$final_path/bin/" ]] if [[ -d "$install_dir/bin/" ]]
then then
ynh_secure_remove --file="$final_path/bin/" #REMOVEME? ynh_secure_remove --file="$install_dir/bin/"
fi fi
# (<3.8) log cleanups # (<3.8) log cleanups
@ -91,8 +91,8 @@ fi
# If used_forge, forge_username, forge_token don't exist, create them # If used_forge, forge_username, forge_token don't exist, create them
if [ -z "$used_forge" ]; then if [ -z "$used_forge" ]; then
used_forge="GitHub" used_forge="GitHub"
forge_username=$(ynh_app_setting_get --app=$app --key=github_account) #REMOVEME? forge_username=$(ynh_app_setting_get --app=$app --key=github_account)
forge_token=$(ynh_app_setting_get --app=$app --key=github_token) #REMOVEME? 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=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_username --value=$forge_username
ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token
@ -101,17 +101,17 @@ fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 #REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" --use_shell
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5 #REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=5
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" #REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -143,10 +143,10 @@ ynh_secure_remove --file="$tempdir"
if [ $used_forge = "GitHub" ] ; then if [ $used_forge = "GitHub" ] ; then
ynh_script_progression --message="Configure hub..." --weight=1 ynh_script_progression --message="Configure hub..." --weight=1
#mkdir "$final_path/.config/" #mkdir "$install_dir/.config/"
ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" ynh_add_config --template="../conf/hub_config" --destination="$install_dir/.config/hub"
cat <<EOF > "$final_path/.bashrc" cat <<EOF > "$install_dir/.bashrc"
eval "$(hub alias -s /bin/bash)" eval "$(hub alias -s /bin/bash)"
EOF EOF
fi fi
@ -158,7 +158,7 @@ ynh_script_progression --message="Updating a configuration file..." --weight=2
ynh_add_config --template="../conf/uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini" ynh_add_config --template="../conf/uwsgi.ini" --destination="/etc/uwsgi/apps-available/$app.ini"
ynh_add_config --template="../conf/celery-weblate" --destination="$final_path/celery-weblate" ynh_add_config --template="../conf/celery-weblate" --destination="$install_dir/celery-weblate"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -180,27 +180,27 @@ upgrade() {
#================================================= #=================================================
ynh_script_progression --message="Install weblate using PIP..." --weight=15 ynh_script_progression --message="Install weblate using PIP..." --weight=15
ynh_secure_remove --file="${final_path}/venv" ynh_secure_remove --file="${install_dir}/venv"
virtualenv --python=python3 "${final_path}/venv" virtualenv --python=python3 "${install_dir}/venv"
chown -R $app: "$final_path" chown -R $app: "$install_dir"
#run source in a 'sub shell' #run source in a 'sub shell'
( (
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${install_dir}/venv/bin/activate"
set -o nounset set -o nounset
cd "${final_path}" cd "${install_dir}"
sudo --user=$app $final_path/venv/bin/pip install --upgrade pip setuptools wheel pkgconfig xxhash sudo --user=$app $install_dir/venv/bin/pip install --upgrade pip setuptools wheel pkgconfig xxhash
# Read the "Note" section in https://docs.weblate.org/en/weblate-4.11/admin/install/venv-debian.html#python-modules # Read the "Note" section in https://docs.weblate.org/en/weblate-4.11/admin/install/venv-debian.html#python-modules
sudo --user=$app $final_path/venv/bin/pip install --force-reinstall --no-binary :all: cffi sudo --user=$app $install_dir/venv/bin/pip install --force-reinstall --no-binary :all: cffi
# Still needed with latest version of weblate? # Still needed with latest version of weblate?
sudo --user=$app $final_path/venv/bin/pip install --upgrade Weblate=="$new_version" sudo --user=$app $install_dir/venv/bin/pip install --upgrade Weblate=="$new_version"
sudo --user=$app $final_path/venv/bin/pip install psycopg2-binary ruamel.yaml aeidon phply sudo --user=$app $install_dir/venv/bin/pip install psycopg2-binary ruamel.yaml aeidon phply
#pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml #pip install pytz python-bidi PyYaML Babel pyuca pylibravatar py3dns psycopg2-binary phply django-redis hiredis aeidon ruamel.yaml
# specific to YunoHost package: # specific to YunoHost package:
sudo --user=$app $final_path/venv/bin/pip install django_sendmail_backend sudo --user=$app $install_dir/venv/bin/pip install django_sendmail_backend
) )
#================================================= #=================================================
@ -208,8 +208,8 @@ upgrade() {
#================================================= #=================================================
ynh_script_progression --message="Create weblate configuration file..." --weight=2 ynh_script_progression --message="Create weblate configuration file..." --weight=2
# save old settings file # save old settings file
settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" settings="$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
path_url="${path_url%/}" path="${path%/}"
set_forge_variables set_forge_variables
@ -220,8 +220,8 @@ upgrade() {
# Recalculate and store the config file checksum into the app settings # Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$settings" ynh_store_file_checksum --file="$settings"
touch "$final_path/local_settings.py" touch "$install_dir/local_settings.py"
ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py"
#================================================= #=================================================
# MIGRATE WEBLATE # MIGRATE WEBLATE
@ -232,34 +232,34 @@ upgrade() {
( (
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${install_dir}/venv/bin/activate"
set -o nounset set -o nounset
export DJANGO_SETTINGS_MODULE="weblate.settings" export DJANGO_SETTINGS_MODULE="weblate.settings"
cd "${final_path}" cd "${install_dir}"
sudo --user=$app $final_path/venv/bin/weblate migrate --noinput sudo --user=$app $install_dir/venv/bin/weblate migrate --noinput
sudo --user=$app $final_path/venv/bin/weblate collectstatic --noinput sudo --user=$app $install_dir/venv/bin/weblate collectstatic --noinput
sudo --user=$app $final_path/venv/bin/weblate setuplang sudo --user=$app $install_dir/venv/bin/weblate setuplang
sudo --user=$app $final_path/venv/bin/weblate setupgroups sudo --user=$app $install_dir/venv/bin/weblate setupgroups
sudo --user=$app $final_path/venv/bin/weblate compilemessages sudo --user=$app $install_dir/venv/bin/weblate compilemessages
# Check the configuration # Check the configuration
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later. # This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
if [ "$new_version" == "$(ynh_app_upstream_version)" ]; then if [ "$new_version" == "$(ynh_app_upstream_version)" ]; then
sudo --user=$app $final_path/venv/bin/weblate check --deploy || true sudo --user=$app $install_dir/venv/bin/weblate check --deploy || true
fi fi
) )
ynh_systemd_action --service_name="$app-celery" --action="stop" ynh_systemd_action --service_name="$app-celery" --action="stop"
} }
file_version="${final_path}/venv/lib/$weblate_pypath/site-packages/weblate/__init__.py" file_version="${install_dir}/venv/lib/$weblate_pypath/site-packages/weblate/__init__.py"
if [ -e $file_version ] if [ -e $file_version ]
then then
current_version=$(cat $file_version | grep "^VERSION = " | grep -o "[0-9].[0-9]" | head -n1 | cut -d"." -f1) current_version=$(cat $file_version | grep "^VERSION = " | grep -o "[0-9].[0-9]" | head -n1 | cut -d"." -f1)
if [ -z "$current_version" ] if [ -z "$current_version" ]
then then
file_version="${final_path}/venv/lib/$weblate_pypath/site-packages/weblate/utils/version.py" file_version="${install_dir}/venv/lib/$weblate_pypath/site-packages/weblate/utils/version.py"
current_version=$(cat $file_version | grep "^VERSION = " | grep -o "[0-9].[0-9]" | head -n1 | cut -d"." -f1) current_version=$(cat $file_version | grep "^VERSION = " | grep -o "[0-9].[0-9]" | head -n1 | cut -d"." -f1)
fi fi
else else
@ -276,13 +276,13 @@ fi
upgrade $(ynh_app_upstream_version) "../conf/settings.py" upgrade $(ynh_app_upstream_version) "../conf/settings.py"
# Set right permissions for curl installation # Set right permissions for curl installation
mkdir -p "$final_path/avatar-cache" mkdir -p "$install_dir/avatar-cache"
chown -R $app: "$final_path" chown -R $app: "$install_dir"
chown "$app:www-data" "$final_path" chown "$app:www-data" "$install_dir"
chown -R "$app:www-data" "$final_path/data" chown -R "$app:www-data" "$install_dir/data"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -313,9 +313,9 @@ ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/va
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

19
tests.toml Normal file
View file

@ -0,0 +1,19 @@
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------
# -------------------------------
# Default args to use for install
# -------------------------------
# -------------------------------
# Commits to test upgrade from
# -------------------------------

Binary file not shown.