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

96 lines
3.8 KiB
Bash

#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICES
#=================================================
ynh_script_progression --message="Stopping $app's systemd services..." --weight=1
ynh_systemd_action --service_name="$app.socket" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="/var/log/$app/$app.log"
systemctl disable "$app.socket" --quiet
systemctl disable "$app" --quiet
systemctl disable "$app-beat" --quiet
systemctl disable "$app-celery" --quiet
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
if [ -n "${data_path:-}" ]; then
ynh_app_setting_delete --app="$app" --key=data_path
ynh_app_setting_delete --app="$app" --key=db_pwd
ynh_app_setting_delete --app="$app" --key=admin_email
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
set_permissions
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE VIRTUALENV
#=================================================
ynh_script_progression --message="Upgrading Python virtualenv..." --weight=2
set_up_virtualenv
#=================================================
# PERFORM DATABASE MIGRATIONS
#=================================================
ynh_script_progression --message="Performing database migrations..." --weight=2
upgrade_db
#=================================================
# 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
ynh_add_systemd_config --service="$app-socket" --template systemd.socket
ynh_add_systemd_config --service="$app-celery" --template systemd-celery.service
ynh_add_systemd_config --service="$app-beat" --template systemd-beat.service
systemctl disable "$app-socket.service" --quiet
mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket"
systemctl daemon-reload --quiet
yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last