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

100 lines
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
source /usr/share/yunohost/helpers
2017-08-28 16:34:15 +02:00
#=================================================
# LOAD SETTINGS
#=================================================
2019-03-04 16:24:27 +01:00
ynh_print_info "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
2017-08-28 16:34:15 +02:00
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
port=$(ynh_app_setting_get $app port)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2019-03-04 16:24:27 +01:00
ynh_print_info "Ensuring downward compatibility..."
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
ynh_app_setting_set $app port $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-03-04 16:24:27 +01:00
ynh_print_info "Backing up the app before upgrading (may take a while)..."
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
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# NGINX CONFIGURATION
#=================================================
2019-03-04 16:24:27 +01:00
ynh_print_info "Upgrading nginx web server configuration..."
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
#=================================================
# CONFIGURE SHELLINABOX
#=================================================
2019-03-04 16:24:27 +01:00
ynh_print_info "Upgrading shellinabox configuration..."
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "/etc/default/shellinabox"
cp ../conf/shellinabox /etc/default/shellinabox
ynh_replace_string "__PORT__" "$port" "/etc/default/shellinabox"
# Allow the service to log in syslog
ynh_replace_string " -- -q --background" " -- --background" "/etc/init.d/shellinabox"
systemctl daemon-reload
systemctl restart shellinabox
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "/etc/default/shellinabox"
2019-03-04 16:23:36 +01:00
#=================================================
# RELOAD NGINX
#=================================================
2019-03-04 16:24:27 +01:00
ynh_print_info "Reloading nginx web server..."
2019-03-04 16:23:36 +01:00
systemctl reload nginx
2019-03-04 16:24:27 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"