2021-11-25 17:59:02 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2023-10-27 15:17:28 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
2021-11-25 17:59:02 +01:00
|
|
|
|
|
|
|
detect_and_read_radarr_and_sonarr_settings
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=2
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-04-07 15:32:46 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="$install_dir/data"
|
2021-11-25 17:59:02 +01:00
|
|
|
fi
|
|
|
|
|
2024-05-11 12:23:06 +02:00
|
|
|
mkdir -p "$install_dir/data/config"
|
|
|
|
|
2023-10-27 15:10:20 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app: "$install_dir"
|
2021-11-25 17:59:02 +01:00
|
|
|
|
|
|
|
# Prepare log path
|
|
|
|
log_path="/var/log/$app"
|
|
|
|
mkdir -p "$log_path"
|
|
|
|
chmod 750 "$log_path"
|
|
|
|
chmod -R o-rwx "$log_path"
|
|
|
|
chown -R $app: "$log_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2023-10-27 15:17:28 +02:00
|
|
|
env_path="$install_dir/venv/bin:$PATH"
|
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2021-11-25 17:59:02 +01:00
|
|
|
|
2023-10-27 15:17:28 +02:00
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
|
|
|
yunohost service add $app --description="Subtitle downloader for Radarr and Sonarr" --log="/var/log/$app/$app.log"
|
2021-11-25 17:59:02 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# UPGRADING BAZARR
|
|
|
|
#=================================================
|
2023-10-27 15:10:20 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Upgrading Bazarr and its dependencies..." --weight=5
|
2021-11-25 17:59:02 +01:00
|
|
|
|
2023-10-27 15:10:20 +02:00
|
|
|
pushd $install_dir
|
2024-04-07 16:09:04 +02:00
|
|
|
# Initialize virtual environment
|
|
|
|
ynh_exec_as $app python${python_major_version} -m venv venv
|
2021-11-25 17:59:02 +01:00
|
|
|
|
2024-04-07 16:09:04 +02:00
|
|
|
ynh_exec_as $app $install_dir/venv/bin/pip install -r "$install_dir/requirements.txt"
|
2021-11-25 17:59:02 +01:00
|
|
|
popd
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
2022-02-06 13:04:16 +01:00
|
|
|
#FIXME: Find a way not to override all settings while upgrading the config file.
|
2024-04-07 16:09:04 +02:00
|
|
|
#FIXME: This is done once after v1.4.0 that changed the config file from .ini to .yaml format
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version 1.4.0~ynh1
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
|
|
|
ynh_add_config --template="config.yaml" --destination="$install_dir/data/config/config.yaml"
|
|
|
|
fi
|
2021-11-25 17:59:02 +01:00
|
|
|
|
2024-04-07 16:09:04 +02:00
|
|
|
chmod 660 "$install_dir/data/config/config.yaml"
|
|
|
|
chown $app: "$install_dir/data/config/config.yaml"
|
2021-11-25 17:59:02 +01:00
|
|
|
|
2022-01-16 19:19:07 +01:00
|
|
|
#=================================================
|
|
|
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Adding multimedia directories..." --weight=1
|
|
|
|
|
|
|
|
# Build YunoHost multimedia directories
|
|
|
|
ynh_multimedia_build_main_dir
|
|
|
|
# Enable writing into these directories
|
|
|
|
ynh_multimedia_addaccess $app
|
|
|
|
|
2021-11-25 17:59:02 +01:00
|
|
|
#=================================================
|
|
|
|
# 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
|