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

123 lines
4.3 KiB
Text
Raw Normal View History

2015-05-08 12:03:12 +02:00
#!/bin/bash
2017-08-28 16:34:15 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2017-04-20 19:34:26 +02:00
2021-02-13 19:19:24 +01:00
source _common.sh
2017-04-20 19:34:26 +02:00
source /usr/share/yunohost/helpers
2017-08-28 16:34:15 +02:00
#=================================================
# LOAD SETTINGS
#=================================================
2023-06-04 21:04:12 +02:00
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
2017-08-28 16:34:15 +02:00
2023-06-04 21:04:12 +02:00
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
2015-05-08 12:03:12 +02:00
2023-06-04 21:04:12 +02:00
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
2017-08-28 16:34:15 +02:00
#=================================================
2022-06-29 03:45:27 +02:00
# CHECK VERSION
2017-08-28 16:34:15 +02:00
#=================================================
2022-06-29 03:45:27 +02:00
ynh_script_progression --message="Checking version..."
2015-05-08 12:03:12 +02:00
2022-06-29 03:45:27 +02:00
upgrade_type=$(ynh_check_app_version_changed)
2015-05-08 12:03:12 +02:00
2017-08-28 16:34:15 +02:00
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
2023-06-04 21:04:12 +02:00
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5
2017-08-28 16:34:15 +02:00
2019-03-04 16:23:36 +01:00
# Backup the current version of the app
2023-06-04 21:04:12 +02:00
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
2022-06-29 03:45:27 +02:00
ynh_clean_check_starting
# Restore it if the upgrade fails
2023-06-04 21:04:12 +02:00
#REMOVEME? ynh_restore_upgradebackup
2017-08-28 16:34:15 +02:00
}
2019-03-04 16:23:36 +01:00
# Exit if an error occurs during the execution of the script
2023-06-04 21:04:12 +02:00
#REMOVEME? ynh_abort_if_errors
2017-08-28 16:34:15 +02:00
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
2022-06-29 03:45:27 +02:00
# STOP SYSTEMD SERVICE
2017-08-28 16:34:15 +02:00
#=================================================
2022-06-29 03:45:27 +02:00
ynh_script_progression --message="Stopping a systemd service..."
2017-08-28 16:34:15 +02:00
2022-06-29 03:45:27 +02:00
ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
# If port doesn't exist, create it
if [ -z "$port" ]; then
port=4200
2023-06-04 21:04:12 +02:00
#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
2022-06-29 03:45:27 +02:00
fi
2015-05-08 12:03:12 +02:00
2021-02-13 19:19:24 +01:00
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
2023-06-04 21:04:12 +02:00
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
2021-02-13 19:19:24 +01:00
2023-06-04 21:04:12 +02:00
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
2021-02-13 19:19:24 +01:00
#=================================================
2022-06-29 03:45:27 +02:00
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
2022-06-29 03:45:27 +02:00
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=4
2022-01-04 23:32:01 +01:00
ynh_add_config --template="../conf/shellinabox" --destination="/etc/default/shellinabox"
2022-06-29 03:45:27 +02:00
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
2019-05-20 17:03:46 +02:00
ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox"
systemctl daemon-reload
2021-02-13 19:19:24 +01:00
#=================================================
2022-06-29 03:45:27 +02:00
# INTEGRATE SERVICE IN YUNOHOST
2021-02-13 19:19:24 +01:00
#=================================================
2022-01-04 23:32:01 +01:00
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
2021-02-13 19:19:24 +01:00
2022-01-04 23:32:01 +01:00
yunohost service add $app --description="Web based AJAX terminal emulator"
2021-02-13 19:19:24 +01:00
2022-06-29 03:45:27 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=shellinabox --action=restart
2019-03-04 16:23:36 +01:00
#=================================================
# RELOAD NGINX
#=================================================
2023-06-04 21:04:12 +02:00
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
2019-03-04 16:23:36 +01:00
2023-06-04 21:04:12 +02:00
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
2019-03-04 16:23:36 +01:00
2019-03-04 16:24:27 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2019-05-20 17:03:46 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last