1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/headphones_ynh.git synced 2024-09-03 19:26:02 +02:00
headphones_ynh/scripts/upgrade

109 lines
3.6 KiB
Text
Raw Normal View History

2015-08-23 17:57:27 +02:00
#!/bin/bash
2022-03-24 00:32:11 +01:00
#=================================================
# 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..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" --line_match="Headphones is shutting down"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2015-09-05 17:52:58 +02:00
2022-03-24 00:32:11 +01:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
2015-09-05 17:52:58 +02:00
then
2022-03-24 00:32:11 +01:00
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
2023-05-25 13:10:35 +02:00
ynh_setup_source --dest_dir="$install_dir"
2015-09-05 17:52:58 +02:00
fi
2023-05-25 13:10:35 +02:00
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
chmod +x "$install_dir/Headphones.py"
2022-03-24 00:32:11 +01:00
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# INSTALL PYTHON DEPENDENCIES
#=================================================
2023-05-25 13:10:35 +02:00
#REMOVEME? ynh_script_progression --message="Installing Python dependencies..."
2022-03-24 00:32:11 +01:00
2023-05-25 13:16:24 +02:00
ynh_secure_remove --file="$install_dir/venv"
2023-05-25 13:10:35 +02:00
python3 -m venv $install_dir/venv
2022-03-24 00:32:11 +01:00
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
mkdir -p "/etc/$app"
ynh_add_config --template="../conf/headphones.ini" --destination="/etc/$app/$app.ini"
chmod 600 "/etc/$app/$app.ini"
chown $app:$app "/etc/$app/$app.ini"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Starting Headphones web server"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"