1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/libretranslate_ynh.git synced 2024-09-03 19:36:00 +02:00

Merge pull request #14 from Thovi98/ditch-pipenv-+-bookworm

Ditch pipenv + bookworm
This commit is contained in:
Éric Gaspar 2023-08-03 14:29:35 +02:00 committed by GitHub
commit fdbfec0254
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 39 deletions

View file

@ -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

View file

@ -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 = [""]

View file

@ -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

View file

@ -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 toml
popd
#=================================================
# SYSTEM CONFIGURATION
#=================================================

View file

@ -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,36 +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
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

View file

@ -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
#=================================================

View file

@ -1,3 +1,3 @@
test_format = 1.0
[default]
[default]