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
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
2017-08-28 16:34:15 +02:00
|
|
|
|
2017-04-20 19:34:26 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
|
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
# If port doesn't exist, create it
|
2019-03-04 16:23:36 +01:00
|
|
|
if [ -z "$port" ]; then
|
2017-08-28 16:34:15 +02:00
|
|
|
port=4200
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
2015-05-08 12:03:12 +02:00
|
|
|
fi
|
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
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
|
|
|
|
ynh_backup_before_upgrade
|
2017-08-28 16:34:15 +02:00
|
|
|
ynh_clean_setup () {
|
2019-03-04 16:23:36 +01:00
|
|
|
# restore it if the upgrade fails
|
|
|
|
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
|
|
|
|
ynh_abort_if_errors
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2021-02-13 19:34:25 +01:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
2015-05-08 12:03:12 +02:00
|
|
|
|
2021-02-13 19:19:24 +01:00
|
|
|
#=================================================
|
|
|
|
# UPGRADE DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
|
|
|
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
2018-04-17 17:30:44 +02:00
|
|
|
#=================================================
|
2018-06-23 15:23:51 +02:00
|
|
|
# CONFIGURE SHELLINABOX
|
2018-04-17 17:30:44 +02:00
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Upgrading shellinabox configuration..." --weight=4
|
2018-04-17 17:30:44 +02:00
|
|
|
|
2018-06-23 15:23:51 +02:00
|
|
|
# Verify the checksum and backup the file if it's different
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_backup_if_checksum_is_different --file="/etc/default/shellinabox"
|
2018-06-23 15:23:51 +02:00
|
|
|
|
|
|
|
cp ../conf/shellinabox /etc/default/shellinabox
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="/etc/default/shellinabox"
|
2018-06-23 15:23:51 +02:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox"
|
2018-04-17 17:30:44 +02:00
|
|
|
systemctl daemon-reload
|
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_systemd_action --service_name=shellinabox --action=restart
|
2018-06-23 15:23:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE THE CHECKSUM OF THE CONFIG FILE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_store_file_checksum --file="/etc/default/shellinabox"
|
2019-03-04 16:23:36 +01:00
|
|
|
|
2021-02-13 19:19:24 +01:00
|
|
|
#=================================================
|
|
|
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
yunohost service add $app
|
|
|
|
|
2019-03-04 16:23:36 +01:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2021-02-13 19:34:25 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..."
|
2019-03-04 16:23:36 +01:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
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
|