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

158 lines
5.8 KiB
Text
Raw Normal View History

2018-02-06 14:33:23 +01:00
#!/bin/bash
2018-02-11 00:32:26 +01:00
#=================================================
# GENERIC START
#=================================================
2018-02-06 14:33:23 +01:00
# IMPORT GENERIC HELPERS
2022-03-09 00:27:32 +01:00
#=================================================
source _common.sh
2018-02-06 14:33:23 +01:00
source /usr/share/yunohost/helpers
2022-03-09 00:27:32 +01:00
#=================================================
# LOAD SETTINGS
#=================================================
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
2018-02-06 14:33:23 +01:00
2023-11-02 22:33:38 +01:00
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
2018-02-06 14:33:23 +01:00
2023-11-02 22:33:38 +01:00
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
#REMOVEME? service_autodiscovery=$(ynh_app_setting_get --app=$app --key=service_autodiscovery)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? db_user=$db_name
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#REMOVEME? gollem_data_dir=$(ynh_app_setting_get --app=$app --key=gollem_data_dir)
2022-03-09 00:27:32 +01:00
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
2018-02-06 14:33:23 +01:00
# Backup the current version of the app
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
2022-03-09 00:27:32 +01:00
# Restore it if the upgrade fails
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_restore_upgradebackup
2018-02-06 14:33:23 +01:00
}
# Exit if an error occurs during the execution of the script
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_abort_if_errors
2018-02-06 14:33:23 +01:00
2018-02-11 00:32:26 +01:00
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
2022-03-09 00:27:32 +01:00
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2022-08-31 00:06:07 +02:00
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
2022-03-09 00:27:32 +01:00
# Cleaning legacy permissions
2023-11-02 22:33:38 +01:00
#REMOVEME? if ynh_legacy_permissions_exists; then
#REMOVEME? ynh_legacy_permissions_delete_all
2022-03-09 00:27:32 +01:00
ynh_app_setting_delete --app=$app --key=is_public
fi
2023-11-02 22:33:38 +01:00
# If install_dir doesn't exist, create it
2022-03-10 21:04:07 +01:00
if [ -z "$gollem_data_dir" ]; then
gollem_data_dir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=gollem_data_dir --value=$gollem_data_dir
fi
2022-08-31 00:06:07 +02:00
2022-03-09 00:27:32 +01:00
#=================================================
# CREATE DEDICATED USER
#=================================================
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
2022-03-09 00:27:32 +01:00
# Create a dedicated user (if not existing)
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
2022-03-09 00:27:32 +01:00
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
2022-03-09 00:27:32 +01:00
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
2018-02-06 14:33:23 +01:00
2022-03-09 00:27:32 +01:00
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
2022-08-31 00:06:07 +02:00
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
2022-03-09 00:27:32 +01:00
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
2022-08-31 00:06:07 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
config_nginx
2022-03-09 00:27:32 +01:00
#=================================================
# SPECIFIC UPGRADE
#=================================================
2022-08-31 00:06:07 +02:00
# UPGRADE SOURCE FILE
2022-03-09 00:27:32 +01:00
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=6
2022-08-31 00:06:07 +02:00
2023-11-02 22:33:38 +01:00
pear_cmd="$install_dir/pear/pear -c $install_dir/pear.conf"
2018-02-06 14:33:23 +01:00
$pear_cmd channel-update pear.horde.org
2023-11-02 22:33:38 +01:00
$pear_cmd upgrade -R $install_dir -a -B -c pear.horde.org || true
2018-02-06 14:33:23 +01:00
2022-08-31 00:06:07 +02:00
#=================================================
# PATCH APPLICATION
#=================================================
ynh_script_progression --message="Patching application..." --weight=7
2022-08-31 00:06:07 +02:00
2018-02-06 14:33:23 +01:00
patch_app
2022-08-31 00:06:07 +02:00
#=================================================
# CONFIGURE HORDE
#=================================================
ynh_script_progression --message="Configuring application..." --weight=3
2022-08-31 00:06:07 +02:00
2018-02-06 14:33:23 +01:00
config_horde
2022-08-31 00:06:07 +02:00
#=================================================
2018-02-06 14:33:23 +01:00
# SECURE FILES AND DIRECTORIES
2022-08-31 00:06:07 +02:00
#=================================================
ynh_script_progression --message="Protecting directory..."
2022-08-31 00:06:07 +02:00
2018-07-31 17:04:14 +02:00
set_permission
2022-03-09 00:27:32 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
2018-07-31 17:04:14 +02:00
# SETUP LOGROTATE
2022-03-09 00:27:32 +01:00
#=================================================
2022-08-31 00:06:07 +02:00
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
2022-03-09 00:27:32 +01:00
2023-11-02 22:33:38 +01:00
ynh_use_logrotate --logfile="$install_dir/horde" --nonappend --specific_user www-data/horde
ynh_use_logrotate --logfile="$install_dir/horde/services" --specific_user www-data/horde
ynh_use_logrotate --logfile="$install_dir/horde/services/portal" --specific_user www-data/horde
2022-03-09 00:27:32 +01:00
#=================================================
# RELOAD NGINX
#=================================================
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
2022-03-09 00:27:32 +01:00
2023-11-02 22:33:38 +01:00
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
2022-03-09 00:27:32 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2022-08-31 00:06:07 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last