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

110 lines
3.8 KiB
Text
Raw Normal View History

2019-02-20 12:08:50 +01:00
#!/bin/bash
2020-11-16 19:38:35 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
source _common.sh
2019-02-20 12:08:50 +01:00
source /usr/share/yunohost/helpers
2020-11-16 19:38:35 +01:00
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
app=$YNH_APP_INSTANCE_NAME
2019-02-20 17:56:35 +01:00
2020-11-16 19:38:35 +01:00
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
upgrade_type=$(ynh_check_app_version_changed)
2019-02-20 12:08:50 +01:00
#=================================================
2020-11-16 19:38:35 +01:00
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
2019-02-20 12:08:50 +01:00
#=================================================
2022-03-13 21:51:45 +01:00
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
2022-03-13 21:51:45 +01:00
ynh_clean_check_starting
# Restore it if the upgrade fails
2020-11-16 19:38:35 +01:00
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
#=================================================
# 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="systemd"
2019-02-20 12:08:50 +01:00
#=================================================
2022-03-13 21:51:45 +01:00
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
2019-02-20 12:08:50 +01:00
#=================================================
2022-03-13 21:51:45 +01:00
ynh_script_progression --message="Upgrading dependencies..." --weight=20
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
ynh_install_app_dependencies $pkg_dependencies
2019-02-20 12:08:50 +01:00
2020-11-16 19:38:35 +01:00
#=================================================
2022-03-13 21:51:45 +01:00
# SPECIFIC UPGRADE
2020-11-16 19:38:35 +01:00
#=================================================
2022-03-13 21:51:45 +01:00
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
2019-02-20 12:08:50 +01:00
2022-03-13 21:51:45 +01:00
ynh_replace_string --match_string="ListenStream=.*" --replace_string="ListenStream=$port" --target_file="/lib/systemd/system/cockpit.socket"
systemctl daemon-reload
systemctl restart $app.socket
ynh_add_config --template="../conf/cockpit.conf" --destination="/etc/cockpit/cockpit.conf"
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app
2020-11-16 19:38:35 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
2019-02-20 12:08:50 +01:00
2022-03-13 21:51:45 +01:00
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started"
2019-02-20 17:56:35 +01:00
2020-11-16 19:38:35 +01:00
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2019-02-20 12:08:50 +01:00
2022-03-13 21:51:45 +01:00
ynh_script_progression --message="Upgrade of $app completed" --last