#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME 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 #================================================= ynh_print_info "Ensuring downward compatibility..." # If port doesn't exist, create it if [ -z "$port" ]; then port=4200 ynh_app_setting_set $app port $port fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { # restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # CHECK THE PATH #================================================= # Normalize the URL path syntax path_url=$(ynh_normalize_url_path $path_url) #================================================= # STANDARD UPGRADE STEPS #================================================= # NGINX CONFIGURATION #================================================= ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config #================================================= # CONFIGURE SHELLINABOX #================================================= 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" #================================================= # RELOAD NGINX #================================================= ynh_print_info "Reloading nginx web server..." systemctl reload nginx #================================================= # END OF SCRIPT #================================================= ynh_print_info "Upgrade of $app completed"