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/ 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..cc5f66f 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 = [""] @@ -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/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 diff --git a/scripts/install b/scripts/install index e784878..5daf6f5 100755 --- a/scripts/install +++ b/scripts/install @@ -21,15 +21,12 @@ 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 toml popd #================================================= diff --git a/scripts/restore b/scripts/restore index e279eed..263b8c9 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,6 +10,25 @@ 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,36 +36,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 - -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" -systemctl enable $app.service --quiet +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --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" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +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 diff --git a/scripts/upgrade b/scripts/upgrade index 9ef093e..058706b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,11 +38,12 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Installing LibreTranslate..." --weight=2 -ynh_exec_warn_less python3 -m pip install pipenv +ynh_secure_remove $install_dir/.venv 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 toml popd #================================================= diff --git a/tests.toml b/tests.toml index eb73b8d..cbbeef1 100644 --- a/tests.toml +++ b/tests.toml @@ -1,3 +1,3 @@ test_format = 1.0 -[default] \ No newline at end of file +[default]