diff --git a/README.md b/README.md index d51b4f5..c908b96 100644 --- a/README.md +++ b/README.md @@ -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. -**Shipped version:** 5.3.1~ynh1 +**Shipped version:** 4.18.2~ynh1 **Demo:** https://hosted.weblate.org/ diff --git a/README_fr.md b/README_fr.md index 2996aed..98557db 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,7 +18,7 @@ Si vous n’avez 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. -**Version incluse :** 5.3.1~ynh1 +**Version incluse :** 4.18.2~ynh1 **Démo :** https://hosted.weblate.org/ diff --git a/check_process b/check_process deleted file mode 100644 index 53afd2b..0000000 --- a/check_process +++ /dev/null @@ -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 diff --git a/conf/celery-weblate b/conf/celery-weblate index 4624a9b..15436d5 100644 --- a/conf/celery-weblate +++ b/conf/celery-weblate @@ -2,7 +2,7 @@ CELERYD_NODES="celery notify memory backup translate" # 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 # comment out this line if you don't use an app diff --git a/conf/celery-weblate.service b/conf/celery-weblate.service index 867f85f..7f6254c 100644 --- a/conf/celery-weblate.service +++ b/conf/celery-weblate.service @@ -6,8 +6,8 @@ After=network.target Type=forking User=__APP__ Group=__APP__ -EnvironmentFile=__FINALPATH__/celery-weblate -WorkingDirectory=__FINALPATH__/ +EnvironmentFile=__INSTALL_DIR__/celery-weblate +WorkingDirectory=__INSTALL_DIR__/ RuntimeDirectory=__APP__ RuntimeDirectoryPreserve=restart LogsDirectory=celery diff --git a/conf/nginx.conf b/conf/nginx.conf index e65307b..12c4e0b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,31 +2,31 @@ # https://github.com/WeblateOrg/weblate/blob/master/weblate/examples/weblate.nginx.conf location = __PATH__/favicon.ico { # DATA_DIR/static/favicon.ico - alias __FINALPATH__/data/static/favicon.ico; + alias __INSTALL_DIR__/data/static/favicon.ico; expires 30d; } location = __PATH__/robots.txt { # DATA_DIR/static/robots.txt - alias __FINALPATH__/data/static/robots.txt; + alias __INSTALL_DIR__/data/static/robots.txt; expires 30d; } location __PATH__/static/ { # DATA_DIR/static/ - alias __FINALPATH__/data/static/; + alias __INSTALL_DIR__/data/static/; expires 30d; } location __PATH__/media/ { # DATA_DIR/media/ - alias __FINALPATH__/data/media/; + alias __INSTALL_DIR__/data/media/; expires 30d; } location __PATH__/ { # Path to source - alias __FINALPATH__/ ; + alias __INSTALL_DIR__/ ; include uwsgi_params; # Needed for long running operations in admin interface diff --git a/conf/settings.4.1.1.py b/conf/settings.4.1.1.py index 3174475..c234938 100644 --- a/conf/settings.4.1.1.py +++ b/conf/settings.4.1.1.py @@ -63,7 +63,7 @@ DATABASES = { } } -BASE_DIR = "__FINALPATH__" +BASE_DIR = "__INSTALL_DIR__" # Data directory DATA_DIR = os.path.join(BASE_DIR, "data") @@ -136,7 +136,7 @@ USE_L10N = True USE_TZ = True # 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. MEDIA_ROOT = os.path.join(DATA_DIR, "media") diff --git a/conf/settings.py b/conf/settings.py index 343688e..2f79bc6 100644 --- a/conf/settings.py +++ b/conf/settings.py @@ -5,7 +5,7 @@ ################################################################################ # 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, # 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: # 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" # 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" # 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. MEDIA_ROOT = os.path.join(DATA_DIR, "media") diff --git a/conf/uwsgi.ini b/conf/uwsgi.ini index bbabbad..38372c9 100644 --- a/conf/uwsgi.ini +++ b/conf/uwsgi.ini @@ -5,14 +5,14 @@ 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_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 # Weblate by pip # python-path = /path/to/weblate # In case you're using virtualenv uncomment this: -virtualenv = __FINALPATH__/venv +virtualenv = __INSTALL_DIR__/venv # Needed for OAuth/OpenID buffer-size = 8192 diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 8f50f4e..0000000 --- a/manifest.json +++ /dev/null @@ -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" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..9b46c0a --- /dev/null +++ b/manifest.toml @@ -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" diff --git a/scripts/_common.sh b/scripts/_common.sh index 85a0b0d..47f84c9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,17 +5,17 @@ #================================================= # 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 \ libacl1-dev libssl-dev libpq-dev libjpeg62-turbo-dev build-essential \ python3-gdbm python3-dev python3-pip python3-virtualenv virtualenv git \ uwsgi uwsgi-plugin-python3 redis-server postgresql postgresql-contrib hub" # 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" -pkg_dependencies="$weblate_dependencies $borgbackup_dependencies" +#REMOVEME? pkg_dependencies="$weblate_dependencies $borgbackup_dependencies" debian_maj_version=$(sed 's/\..*//' /etc/debian_version) diff --git a/scripts/backup b/scripts/backup index 9e36f62..4472f3d 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,22 +14,22 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # 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) -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # 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 #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 7bbb34d..afe336e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -13,55 +13,55 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? old_path=$YNH_APP_OLD_PATH -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN +#REMOVEME? new_path=$YNH_APP_NEW_PATH -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # 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" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? # Needed for helper "ynh_add_nginx_config" +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # 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 -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { + #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. - 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 - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # 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 #================================================= -change_domain=0 -if [ "$old_domain" != "$new_domain" ] +#REMOVEME? change_domain=0 +#REMOVEME? if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + #REMOVEME? change_domain=1 fi -change_path=0 -if [ "$old_path" != "$new_path" ] +#REMOVEME? change_path=0 +#REMOVEME? if [ "$old_path" != "$new_path" ] then - change_path=1 + #REMOVEME? change_path=1 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 -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 if [ $change_path -eq 1 ] then # 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 - domain="$old_domain" - path_url="$new_path" +#REMOVEME? domain="$old_domain" +#REMOVEME? path="$new_path" # Create a dedicated NGINX config - ynh_add_nginx_config +#REMOVEME? ynh_add_nginx_config fi # Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf +#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" +#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # 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 #================================================= @@ -110,16 +112,16 @@ fi #================================================= 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" -# Change the path in the nginx config file +#REMOVEME? # Change the path in the nginx config file if [ $change_path -eq 1 ] then ynh_replace_string --match_string="URL_PREFIX = \"${old_path%/}\"" --replace_string="URL_PREFIX = \"${new_path%/}\"" --target_file="$settings" fi -# Change the domain for nginx +#REMOVEME? # Change the domain for nginx if [ $change_domain -eq 1 ] then # replace SERVER_EMAIL @@ -139,7 +141,7 @@ ynh_store_file_checksum --file="$settings" finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" 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 ] then 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 #================================================= -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 diff --git a/scripts/install b/scripts/install index 357b07f..2e9d9ce 100755 --- a/scripts/install +++ b/scripts/install @@ -13,26 +13,26 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # 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 #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC -admin=$YNH_APP_ARG_ADMIN -password=$YNH_APP_ARG_PASSWORD -used_forge=$YNH_APP_ARG_USED_FORGE -forge_username=$YNH_APP_ARG_FORGE_USERNAME -forge_token=$YNH_APP_ARG_FORGE_TOKEN +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +#REMOVEME? path=$YNH_APP_ARG_PATH +#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC +#REMOVEME? admin=$YNH_APP_ARG_ADMIN +#REMOVEME? password=$YNH_APP_ARG_PASSWORD +#REMOVEME? used_forge=$YNH_APP_ARG_USED_FORGE +#REMOVEME? forge_username=$YNH_APP_ARG_FORGE_USERNAME +#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) 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 #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +#REMOVEME? 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" +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" # 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 #================================================= -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 -ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=admin --value=$admin +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path +#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=forge_username --value=$forge_username 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 #================================================= -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 #================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 # 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 #================================================= -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) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) +#REMOVEME? db_user=$db_name +#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name +#REMOVEME? ynh_psql_test_if_first_run +#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 -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 #================================================= ynh_script_progression --message="Setting up source files..." -ynh_app_setting_set --app=$app --key=final_path --value=$final_path -mkdir -p "$final_path" -mkdir -p "$final_path/avatar-cache" -mkdir -p "$final_path/data" +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir +mkdir -p "$install_dir" +mkdir -p "$install_dir/avatar-cache" +mkdir -p "$install_dir/data" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -134,10 +134,10 @@ ynh_secure_remove --file="$tempdir" if [ $used_forge = "GitHub" ] ; then ynh_script_progression --message="Configure hub..." --weight=1 - mkdir "$final_path/.config/" - ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" + mkdir "$install_dir/.config/" + ynh_add_config --template="../conf/hub_config" --destination="$install_dir/.config/hub" - cat < "$final_path/.bashrc" + cat < "$install_dir/.bashrc" eval "$(hub alias -s /bin/bash)" EOF fi @@ -147,26 +147,26 @@ fi #================================================= ynh_script_progression --message="Install weblate using PIP..." --weight=80 -virtualenv --python=python3 "${final_path}/venv" -chown -R $app: "$final_path" +virtualenv --python=python3 "${install_dir}/venv" +chown -R $app: "$install_dir" #run source in a 'sub shell' ( set +o nounset - source "${final_path}/venv/bin/activate" + source "${install_dir}/venv/bin/activate" 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 - 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? - 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 $final_path/venv/bin/pip install psycopg2-binary ruamel.yaml aeidon phply + 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 $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 # 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) ynh_app_setting_set --app=$app --key=redis_db --value="$redis_db" -path_url="${path_url%/}" -settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" +path="${path%/}" +settings="$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" set_forge_variables ynh_add_config --template="../conf/settings.py" --destination="$settings" -ynh_add_config --template="../conf/celery-weblate" --destination="$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" -touch "$final_path/local_settings.py" -ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" +touch "$install_dir/local_settings.py" +ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" # Set permissions to app files -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app: "$final_path" -chown "$app:www-data" "$final_path" -chown -R "$app:www-data" "$final_path/data" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app: "$install_dir" +chown "$app:www-data" "$install_dir" +chown -R "$app:www-data" "$install_dir/data" #================================================= # SPECIFIC SETUP Filling up the database @@ -203,23 +203,23 @@ ynh_script_progression --message="Filling up the database..." --weight=10 ( set +o nounset - source "${final_path}/venv/bin/activate" + source "${install_dir}/venv/bin/activate" set -o nounset export DJANGO_SETTINGS_MODULE="weblate.settings" - cd "${final_path}" + cd "${install_dir}" # 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 - ynh_exec_warn_less sudo --user=$app $final_path/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 collectstatic --noinput + ynh_exec_warn_less sudo --user=$app $install_dir/venv/bin/weblate createadmin --no-color \ --password "$password" \ --username "$admin" \ --email "$admin_mail" # Check the configuration # This may fail in some cases with errors, etc., but the app works and the user can fix issues later. - ynh_exec_warn_less sudo --user=$app $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 #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary -if [ $is_public -eq 1 ] +#REMOVEME? if [ $is_public -eq 1 ] then # Everyone can access the app. # 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 #================================================= # 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" diff --git a/scripts/remove b/scripts/remove index 40bb765..b899e7f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers #================================================= # 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) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # STANDARD REMOVE @@ -61,18 +61,18 @@ ynh_remove_logrotate #================================================= # 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 -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 #================================================= -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 -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE NGINX CONFIGURATION @@ -85,10 +85,10 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=10 +#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=10 # Remove metapackage and its dependencies -ynh_exec_warn_less ynh_remove_app_dependencies +#REMOVEME? ynh_exec_warn_less ynh_remove_app_dependencies #================================================= # REMOVE XXHASH @@ -121,10 +121,10 @@ ynh_redis_remove_db #================================================= # 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 -ynh_system_user_delete --username=$app +#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 79712aa..f23e067 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,68 +14,68 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # 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) -path_url=$(ynh_app_setting_get --app=$app --key=path) -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 +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name #================================================= # 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 \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS #================================================= # 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) -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 #================================================= 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" -ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" +touch "$install_dir/local_settings.py" +ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app: "$final_path" -chown $app:www-data "$final_path" -chown -R $app:www-data "$final_path/data" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app: "$install_dir" +chown $app:www-data "$install_dir" +chown -R $app:www-data "$install_dir/data" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=40 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=40 # 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 @@ -87,11 +87,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # 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) -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? ynh_psql_test_if_first_run +#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_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql diff --git a/scripts/upgrade b/scripts/upgrade index 253c470..3457486 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,21 +12,21 @@ source /usr/share/yunohost/helpers #================================================= # 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) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) -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 -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -used_forge=$(ynh_app_setting_get --app=$app --key=used_forge) -forge_username=$(ynh_app_setting_get --app=$app --key=forge_username) -forge_token=$(ynh_app_setting_get --app=$app --key=forge_token) -redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? db_user=$db_name +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? used_forge=$(ynh_app_setting_get --app=$app --key=used_forge) +#REMOVEME? forge_username=$(ynh_app_setting_get --app=$app --key=forge_username) +#REMOVEME? forge_token=$(ynh_app_setting_get --app=$app --key=forge_token) +#REMOVEME? redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) admin_mail=$(ynh_user_get_info --username="$admin" --key=mail) key=$(ynh_string_random --length=50) @@ -40,17 +40,17 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # 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 -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # 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 -if ynh_legacy_permissions_exists +#REMOVEME? if ynh_legacy_permissions_exists then - ynh_legacy_permissions_delete_all +#REMOVEME? ynh_legacy_permissions_delete_all ynh_app_setting_delete --app=$app --key=is_public fi -if [[ -d "$final_path/bin/" ]] +if [[ -d "$install_dir/bin/" ]] then - ynh_secure_remove --file="$final_path/bin/" +#REMOVEME? ynh_secure_remove --file="$install_dir/bin/" fi # (<3.8) log cleanups @@ -91,8 +91,8 @@ fi # If used_forge, forge_username, forge_token don't exist, create them if [ -z "$used_forge" ]; then used_forge="GitHub" - forge_username=$(ynh_app_setting_get --app=$app --key=github_account) - forge_token=$(ynh_app_setting_get --app=$app --key=github_token) +#REMOVEME? forge_username=$(ynh_app_setting_get --app=$app --key=github_account) +#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=forge_username --value=$forge_username ynh_app_setting_set --app=$app --key=forge_token --value=$forge_token @@ -101,17 +101,17 @@ fi #================================================= # 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) -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 #================================================= -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 @@ -143,10 +143,10 @@ ynh_secure_remove --file="$tempdir" if [ $used_forge = "GitHub" ] ; then ynh_script_progression --message="Configure hub..." --weight=1 - #mkdir "$final_path/.config/" - ynh_add_config --template="../conf/hub_config" --destination="$final_path/.config/hub" + #mkdir "$install_dir/.config/" + ynh_add_config --template="../conf/hub_config" --destination="$install_dir/.config/hub" - cat < "$final_path/.bashrc" + cat < "$install_dir/.bashrc" eval "$(hub alias -s /bin/bash)" EOF 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/celery-weblate" --destination="$final_path/celery-weblate" +ynh_add_config --template="../conf/celery-weblate" --destination="$install_dir/celery-weblate" #================================================= # SETUP SYSTEMD @@ -180,27 +180,27 @@ upgrade() { #================================================= ynh_script_progression --message="Install weblate using PIP..." --weight=15 - ynh_secure_remove --file="${final_path}/venv" - virtualenv --python=python3 "${final_path}/venv" - chown -R $app: "$final_path" + ynh_secure_remove --file="${install_dir}/venv" + virtualenv --python=python3 "${install_dir}/venv" + chown -R $app: "$install_dir" #run source in a 'sub shell' ( set +o nounset - source "${final_path}/venv/bin/activate" + source "${install_dir}/venv/bin/activate" 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 - 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? - sudo --user=$app $final_path/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 --upgrade Weblate=="$new_version" + 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 # 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 # save old settings file - settings="$final_path/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" - path_url="${path_url%/}" + settings="$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/settings.py" + path="${path%/}" set_forge_variables @@ -220,8 +220,8 @@ upgrade() { # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$settings" - touch "$final_path/local_settings.py" - ln -sf "$final_path/local_settings.py" "$final_path/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" + touch "$install_dir/local_settings.py" + ln -sf "$install_dir/local_settings.py" "$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/local_settings.py" #================================================= # MIGRATE WEBLATE @@ -232,34 +232,34 @@ upgrade() { ( set +o nounset - source "${final_path}/venv/bin/activate" + source "${install_dir}/venv/bin/activate" set -o nounset 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 $final_path/venv/bin/weblate collectstatic --noinput - sudo --user=$app $final_path/venv/bin/weblate setuplang - sudo --user=$app $final_path/venv/bin/weblate setupgroups - sudo --user=$app $final_path/venv/bin/weblate compilemessages + sudo --user=$app $install_dir/venv/bin/weblate migrate --noinput + sudo --user=$app $install_dir/venv/bin/weblate collectstatic --noinput + sudo --user=$app $install_dir/venv/bin/weblate setuplang + sudo --user=$app $install_dir/venv/bin/weblate setupgroups + sudo --user=$app $install_dir/venv/bin/weblate compilemessages # Check the configuration # 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 - sudo --user=$app $final_path/venv/bin/weblate check --deploy || true + sudo --user=$app $install_dir/venv/bin/weblate check --deploy || true fi ) 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 ] then current_version=$(cat $file_version | grep "^VERSION = " | grep -o "[0-9].[0-9]" | head -n1 | cut -d"." -f1) if [ -z "$current_version" ] 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) fi else @@ -276,13 +276,13 @@ fi upgrade $(ynh_app_upstream_version) "../conf/settings.py" # Set right permissions for curl installation -mkdir -p "$final_path/avatar-cache" -chown -R $app: "$final_path" -chown "$app:www-data" "$final_path" -chown -R "$app:www-data" "$final_path/data" +mkdir -p "$install_dir/avatar-cache" +chown -R $app: "$install_dir" +chown "$app:www-data" "$install_dir" +chown -R "$app:www-data" "$install_dir/data" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" #================================================= # GENERIC FINALIZATION @@ -313,9 +313,9 @@ ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/va #================================================= # 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 diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..82dcc43 --- /dev/null +++ b/tests.toml @@ -0,0 +1,19 @@ +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ + + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + \ No newline at end of file diff --git a/weblate_v2.zip b/weblate_v2.zip deleted file mode 100644 index c78a46a..0000000 Binary files a/weblate_v2.zip and /dev/null differ