1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/libretranslate_ynh.git synced 2024-09-03 19:36:00 +02:00
libretranslate_ynh/scripts/upgrade
2024-03-07 21:30:56 +01:00

76 lines
2.5 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC SETUP
#=================================================
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=="$(ynh_app_upstream_version)" toml
popd
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
yunohost service add $app --description="Machine Translation API" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last