From 6719574ed46b43cf015c55fe138049a6dcbfce86 Mon Sep 17 00:00:00 2001 From: lotigara <105482918+lotigara@users.noreply.github.com> Date: Fri, 19 Jul 2024 21:57:00 +0300 Subject: [PATCH 1/6] Add installation of additional languages --- scripts/install | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/install b/scripts/install index 753481e..b5fd383 100755 --- a/scripts/install +++ b/scripts/install @@ -27,6 +27,13 @@ pushd $install_dir python3 -m venv $install_dir/venv source $install_dir/venv/bin/activate ynh_exec_warn_less pip install libretranslate=="$(ynh_app_upstream_version)" toml + + # Install additional languages (FIXME!!!) + venv/bin/libretranslate --update-models & + export LT-PID="$!" + if [ ss -tulpen | grep '127.0.0.1:5000' ] ; then + kill -INT "$!" + fi popd #================================================= From dc05a95e32d5e86f577aa31b472c80202761438a Mon Sep 17 00:00:00 2001 From: lotigara <105482918+lotigara@users.noreply.github.com> Date: Fri, 19 Jul 2024 23:26:56 +0300 Subject: [PATCH 2/6] Add a setting for installing additional languages and comments with warnings. --- manifest.toml | 7 +++++++ scripts/install | 20 ++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/manifest.toml b/manifest.toml index 3b85f74..21249fd 100644 --- a/manifest.toml +++ b/manifest.toml @@ -34,6 +34,13 @@ ram.runtime = "50M" type = "group" default = "visitors" + [install.additional_languages] + ask.en = "Do install additional language models? WARNING: It will take ~6 GB of your free space." + help.en = "By default, installed models are English->French and French->English." + yes = "true" + no = "false" + type = "boolean" + [resources] [resources.sources] diff --git a/scripts/install b/scripts/install index b5fd383..c0c5421 100755 --- a/scripts/install +++ b/scripts/install @@ -28,12 +28,20 @@ pushd $install_dir source $install_dir/venv/bin/activate ynh_exec_warn_less pip install libretranslate=="$(ynh_app_upstream_version)" toml - # Install additional languages (FIXME!!!) - venv/bin/libretranslate --update-models & - export LT-PID="$!" - if [ ss -tulpen | grep '127.0.0.1:5000' ] ; then - kill -INT "$!" - fi + # WARNING!!! CODE BELOW WASN'T TESTED!!! RUN IN DEBUG MODE FROM SHELL!!! + # Checking if additional_languages was enabled... + if [ "$additional_languages" = true ] ; then + + # ...if yes, download models... + venv/bin/libretranslate --update-models & + + # ...and then kill the libretranslate process + # because it was started after downloading models! + export LT-PID="$!" + if ss -tulpen | grep '127.0.0.1:5000' ; then + kill -INT "$LT_PID" + fi + fi popd #================================================= From 31d66a34aeabe0c4abd0fc71371545c2ee1397ab Mon Sep 17 00:00:00 2001 From: lotigara <105482918+lotigara@users.noreply.github.com> Date: Sat, 20 Jul 2024 13:00:04 +0300 Subject: [PATCH 3/6] Fix exporting LT PID and add message about progression. --- scripts/install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index c0c5421..3b597ae 100755 --- a/scripts/install +++ b/scripts/install @@ -31,13 +31,14 @@ pushd $install_dir # WARNING!!! CODE BELOW WASN'T TESTED!!! RUN IN DEBUG MODE FROM SHELL!!! # Checking if additional_languages was enabled... if [ "$additional_languages" = true ] ; then + ynh_script_progression --message="Installing additional models..." --weight=5 # ...if yes, download models... venv/bin/libretranslate --update-models & # ...and then kill the libretranslate process # because it was started after downloading models! - export LT-PID="$!" + export LT_PID="$!" if ss -tulpen | grep '127.0.0.1:5000' ; then kill -INT "$LT_PID" fi From ee4fd3203aa606979045a0938b1d6b464517374e Mon Sep 17 00:00:00 2001 From: lotigara <105482918+lotigara@users.noreply.github.com> Date: Sat, 20 Jul 2024 13:02:29 +0300 Subject: [PATCH 4/6] Remove a dot in question about downloading additional models. --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 21249fd..f4e7387 100644 --- a/manifest.toml +++ b/manifest.toml @@ -35,7 +35,7 @@ ram.runtime = "50M" default = "visitors" [install.additional_languages] - ask.en = "Do install additional language models? WARNING: It will take ~6 GB of your free space." + ask.en = "Do install additional language models? WARNING: It will take ~6 GB of your free space" help.en = "By default, installed models are English->French and French->English." yes = "true" no = "false" From 593426f6b66ec65cf59e0dbdfd56a9cfc71ad316 Mon Sep 17 00:00:00 2001 From: lotigara <105482918+lotigara@users.noreply.github.com> Date: Sat, 20 Jul 2024 13:58:09 +0300 Subject: [PATCH 5/6] Change port --- scripts/install | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/install b/scripts/install index 3b597ae..102e0cb 100755 --- a/scripts/install +++ b/scripts/install @@ -10,9 +10,9 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +# SETUP PERMISSIONS #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression --message="Setting up permissions..." --weight=1 chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" @@ -34,12 +34,12 @@ pushd $install_dir ynh_script_progression --message="Installing additional models..." --weight=5 # ...if yes, download models... - venv/bin/libretranslate --update-models & - - # ...and then kill the libretranslate process - # because it was started after downloading models! + venv/bin/libretranslate --update-models --port 50005 & export LT_PID="$!" - if ss -tulpen | grep '127.0.0.1:5000' ; then + + # ...and then kill the libretranslate WebUI / API + # because it was started after downloading models! + if ss -tulpen | grep '127.0.0.1:50005' ; then kill -INT "$LT_PID" fi fi From a179628519ed5a84d4d4f1d3564dd64b982decf3 Mon Sep 17 00:00:00 2001 From: lotigara <105482918+lotigara@users.noreply.github.com> Date: Sat, 20 Jul 2024 14:45:19 +0300 Subject: [PATCH 6/6] Replace if with until --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 102e0cb..d6e3202 100755 --- a/scripts/install +++ b/scripts/install @@ -39,9 +39,9 @@ pushd $install_dir # ...and then kill the libretranslate WebUI / API # because it was started after downloading models! - if ss -tulpen | grep '127.0.0.1:50005' ; then + until ss -tulpen | grep '127.0.0.1:50005' ; do kill -INT "$LT_PID" - fi + done fi popd