From 15cfb34986fb34a1170a124ad0ee220b4c13dcfe Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Sun, 9 Jul 2023 22:21:01 +0200 Subject: [PATCH 1/9] Refactor to harmonize with other apps in catalog --- conf/systemd.service | 7 ++++++- manifest.toml | 2 +- scripts/install | 10 ++++------ scripts/restore | 2 -- scripts/upgrade | 7 +++---- tests.toml | 4 +++- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index a0c4a37..1edfeb7 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,10 +6,15 @@ After=network.target [Service] User=__APP__ Group=__APP__ + +StandardOutput=append:/var/log/__APP__/__APP__.log +StandardError=inherit +SyslogIdentifier=__APP__ + Restart=always Type=simple WorkingDirectory=__INSTALL_DIR__ -ExecStart=/usr/local/bin/pipenv run python3 __INSTALL_DIR__/.venv/bin/libretranslate --host 127.0.0.1 --port __PORT__ --load-only en,fr --frontend-language-target en +ExecStart=__INSTALL_DIR__/venv/bin/libretranslate --host 127.0.0.1 --port __PORT__ --load-only en,fr --frontend-language-target en # Sandboxing options to harden security # Depending on specificities of your service/app, you may need to tweak these diff --git a/manifest.toml b/manifest.toml index c0083c1..f5df886 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "LibreTranslate" description.en = "Open Source Machine Translation API" description.fr = "API de traduction automatique Open Source" -version = "1.3.11~ynh1" +version = "1.3.11~ynh2" maintainers = [""] diff --git a/scripts/install b/scripts/install index e784878..9c6988f 100755 --- a/scripts/install +++ b/scripts/install @@ -21,17 +21,15 @@ chown -R $app:www-data "$install_dir" #================================================= # SPECIFIC SETUP #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=2 - -ynh_exec_warn_less python3 -m pip install pipenv - ynh_script_progression --message="Installing LibreTranslate..." --weight=2 pushd $install_dir - mkdir -p .venv - PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true ynh_exec_warn_less python3 -m pipenv install libretranslate==$libretranslate_version 2>&1 + python3 -m venv $install_dir/venv + source $install_dir/venv/bin/activate + ynh_exec_warn_less pip install libretranslate==$libretranslate_version popd + #================================================= # SYSTEM CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index e279eed..d2b5d13 100755 --- a/scripts/restore +++ b/scripts/restore @@ -28,8 +28,6 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Restoring system configurations related to $app..." --weight=5 -ynh_exec_warn_less python3 -m pip install pipenv - ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" diff --git a/scripts/upgrade b/scripts/upgrade index 9ef093e..17be02c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,11 +38,10 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Installing LibreTranslate..." --weight=2 -ynh_exec_warn_less python3 -m pip install pipenv - pushd $install_dir - mkdir -p .venv - PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true ynh_exec_warn_less python3 -m pipenv install libretranslate==$libretranslate_version 2>&1 + python3 -m venv $install_dir/venv + source $install_dir/venv/bin/activate + ynh_exec_warn_less pip install libretranslate==$libretranslate_version popd #================================================= diff --git a/tests.toml b/tests.toml index eb73b8d..5edd7d9 100644 --- a/tests.toml +++ b/tests.toml @@ -1,3 +1,5 @@ test_format = 1.0 -[default] \ No newline at end of file +[default] + +test_upgrade_from.0fda158.name = "1.3.11~ynh1" \ No newline at end of file From dd1af19293961d6706b60ac22f50d86d4aebc887 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Sun, 9 Jul 2023 22:45:29 +0200 Subject: [PATCH 2/9] fix toml --- scripts/install | 2 +- scripts/upgrade | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 9c6988f..858ccf3 100755 --- a/scripts/install +++ b/scripts/install @@ -26,7 +26,7 @@ ynh_script_progression --message="Installing LibreTranslate..." --weight=2 pushd $install_dir python3 -m venv $install_dir/venv source $install_dir/venv/bin/activate - ynh_exec_warn_less pip install libretranslate==$libretranslate_version + ynh_exec_warn_less pip install libretranslate==$libretranslate_version toml popd diff --git a/scripts/upgrade b/scripts/upgrade index 17be02c..058706b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,10 +38,12 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Installing LibreTranslate..." --weight=2 +ynh_secure_remove $install_dir/.venv + pushd $install_dir python3 -m venv $install_dir/venv source $install_dir/venv/bin/activate - ynh_exec_warn_less pip install libretranslate==$libretranslate_version + ynh_exec_warn_less pip install libretranslate==$libretranslate_version toml popd #================================================= From 8a905103f3719336ab67be3510c3de7a37533bfe Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 10 Jul 2023 08:30:57 +0200 Subject: [PATCH 3/9] Update restore --- scripts/restore | 55 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/scripts/restore b/scripts/restore index d2b5d13..3de4d56 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,6 +10,26 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE LOGROTATE +#================================================= +ynh_script_progression --message="Configuring logrotate to manage application logfiles" --weight=1 + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate --specific_user=$app +touch /var/log/$app/$app.log +chown -R $app:www-data /var/log/$app/ + +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -17,34 +37,37 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R $app: "$install_dir" #================================================= -# RESTORE SYSTEM CONFIGURATIONS +# RESTORE SYSTEMD #================================================= -# RESTORE THE PHP-FPM CONFIGURATION +ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/systemd/system/${app}.service" + +systemctl enable "${app}.service" --quiet + #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=5 +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +yunohost service add "${app}" --description="Fittrackee main service" --log="/var/log/$app/$app.log" -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 -yunohost service add $app --description="Machine Translation API" --log="/var/log/$app/$app.log" - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_systemd_action --service_name="${app}" --action="start" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE +# RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload From a7b279b68f1474ad3fe630db6e7d75b87d03573a Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 10 Jul 2023 08:33:33 +0200 Subject: [PATCH 4/9] Update backup --- scripts/backup | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/scripts/backup b/scripts/backup index 737146f..9ca0f2c 100755 --- a/scripts/backup +++ b/scripts/backup @@ -27,19 +27,11 @@ ynh_backup --src_path="$install_dir" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - -ynh_backup --src_path="/etc/logrotate.d/$app" - #================================================= # BACKUP SYSTEMD #================================================= -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/etc/systemd/system/${app}.service" #================================================= # END OF SCRIPT From f8e060d46f6fed5c8f8e206b05295935d1bcfa0f Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 10 Jul 2023 09:24:49 +0200 Subject: [PATCH 5/9] Update restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 3de4d56..c3638e4 100755 --- a/scripts/restore +++ b/scripts/restore @@ -53,7 +53,7 @@ systemctl enable "${app}.service" --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add "${app}" --description="Fittrackee main service" --log="/var/log/$app/$app.log" +yunohost service add "${app}" --description="Machine Translation API" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE From dc7fd17402ea2b27168b2fcf61248a9406e46af3 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:13:08 +0200 Subject: [PATCH 6/9] Update restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index c3638e4..a90b215 100755 --- a/scripts/restore +++ b/scripts/restore @@ -53,7 +53,7 @@ systemctl enable "${app}.service" --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add "${app}" --description="Machine Translation API" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Machine Translation API" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE From a3f7453438e0a64132a3085f3384437c65b75e55 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 10 Jul 2023 11:54:10 +0200 Subject: [PATCH 7/9] Update tests.toml --- tests.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests.toml b/tests.toml index 5edd7d9..cbbeef1 100644 --- a/tests.toml +++ b/tests.toml @@ -1,5 +1,3 @@ test_format = 1.0 [default] - -test_upgrade_from.0fda158.name = "1.3.11~ynh1" \ No newline at end of file From b4dd1c9ebec9fde2f8b9a1447e6bafc588e816f0 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 3 Aug 2023 12:29:40 +0000 Subject: [PATCH 8/9] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a2ec7f4..1489e90 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Free and Open Source Machine Translation API, entirely self-hosted. Unlike other APIs, it doesn't rely on proprietary providers such as Google or Azure to perform translations. Instead, its translation engine is powered by the open source Argos Translate library. -**Shipped version:** 1.3.11~ynh1 +**Shipped version:** 1.3.11~ynh2 **Demo:** https://libretranslate.com/ diff --git a/README_fr.md b/README_fr.md index 28b2d64..2f27b9f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Free and Open Source Machine Translation API, entirely self-hosted. Unlike other APIs, it doesn't rely on proprietary providers such as Google or Azure to perform translations. Instead, its translation engine is powered by the open source Argos Translate library. -**Version incluse :** 1.3.11~ynh1 +**Version incluse :** 1.3.11~ynh2 **Démo :** https://libretranslate.com/ From e7b2f9660046aa541b91d73a2cb4eee38ae59085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 3 Aug 2023 14:31:36 +0200 Subject: [PATCH 9/9] cleaning --- manifest.toml | 2 +- scripts/install | 1 - scripts/restore | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/manifest.toml b/manifest.toml index f5df886..cc5f66f 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,7 @@ admindoc = "https://libretranslate.com/docs/" code = "https://github.com/LibreTranslate/LibreTranslate" [integration] -yunohost = ">= 11.1.19" +yunohost = ">= 11.2" architectures = "all" multi_instance = true ldap = false diff --git a/scripts/install b/scripts/install index 858ccf3..5daf6f5 100755 --- a/scripts/install +++ b/scripts/install @@ -29,7 +29,6 @@ pushd $install_dir ynh_exec_warn_less pip install libretranslate==$libretranslate_version toml popd - #================================================= # SYSTEM CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index a90b215..263b8c9 100755 --- a/scripts/restore +++ b/scripts/restore @@ -25,7 +25,6 @@ chown -R $app:www-data /var/log/$app/ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= - ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"