1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/linuxdash_ynh.git synced 2024-09-03 19:36:07 +02:00
linuxdash_ynh/scripts/upgrade

122 lines
4 KiB
Text
Raw Normal View History

2014-06-02 13:38:03 +02:00
#!/bin/bash
2018-01-29 00:55:27 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Loading installation settings..."
2018-01-29 00:55:27 +01:00
app=$YNH_APP_INSTANCE_NAME
2022-03-25 01:09:30 +01:00
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# CHECK VERSION
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Checking version..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
upgrade_type=$(ynh_check_app_version_changed)
2018-01-29 00:55:27 +01:00
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
2018-01-29 00:55:27 +01:00
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
2022-03-25 01:09:30 +01:00
# Restore it if the upgrade fails
2018-01-29 00:55:27 +01:00
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
2022-03-25 01:09:30 +01:00
# STANDARD UPGRADE STEPS
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# ENSURE DOWNWARD COMPATIBILITY
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Ensuring downward compatibility..."
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# CREATE DEDICATED USER
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Making sure dedicated system user exists..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# DOWNLOAD, CHECK AND UNPACK SOURCE
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
2018-01-29 00:55:27 +01:00
then
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
2018-01-29 00:55:27 +01:00
fi
2022-03-25 01:09:30 +01:00
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# NGINX CONFIGURATION
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Upgrading NGINX web server configuration..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2018-01-29 00:55:27 +01:00
2022-03-25 08:30:34 +01:00
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
2018-01-29 00:55:27 +01:00
#=================================================
# SPECIFIC UPGRADE
#=================================================
# REMOVE GOOGLE !!!
#=================================================
sed --in-place "/googlecode\|googleapis/d" "$final_path/index.html"
#=================================================
2022-03-25 01:09:30 +01:00
# SETUP SUPERVISOR
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Configuring supervisor..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
ynh_add_config --template="../conf/supervisor.conf" --destination="/etc/supervisor/conf.d/$app.conf"
supervisorctl update
supervisorctl restart $app
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Reloading NGINX web server..."
2018-01-29 00:55:27 +01:00
2022-03-25 01:09:30 +01:00
ynh_systemd_action --service_name=nginx --action=reload
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
# END OF SCRIPT
2018-01-29 00:55:27 +01:00
#=================================================
2022-03-25 01:09:30 +01:00
ynh_script_progression --message="Upgrade of $app completed"