2020-12-16 19:56:57 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
|
2021-12-09 11:50:09 +01:00
|
|
|
# If fpm_footprint doesn't exist, create it
|
2023-03-23 15:26:20 +01:00
|
|
|
if [ -z "${fpm_footprint:-}" ]; then
|
2023-01-12 09:28:16 +01:00
|
|
|
fpm_footprint=low
|
|
|
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If fpm_free_footprint doesn't exist, create it
|
2023-03-23 15:26:20 +01:00
|
|
|
if [ -z "${fpm_free_footprint:-}" ]; then
|
2023-01-12 09:28:16 +01:00
|
|
|
fpm_free_footprint=0
|
|
|
|
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
|
2021-12-09 11:50:09 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# If fpm_usage doesn't exist, create it
|
2023-03-23 15:26:20 +01:00
|
|
|
if [ -z "${fpm_usage:-}" ]; then
|
2023-01-12 09:28:16 +01:00
|
|
|
fpm_usage=low
|
|
|
|
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
2021-12-09 11:50:09 +01:00
|
|
|
fi
|
|
|
|
|
2020-12-16 19:56:57 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=5
|
|
|
|
|
2022-10-17 08:33:09 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-03-23 15:26:20 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir" --keep="data"
|
2023-09-02 19:12:37 +02:00
|
|
|
ynh_secure_remove --file="$install_dir/data/viewcache/*"
|
2020-12-16 19:56:57 +01:00
|
|
|
fi
|
|
|
|
|
2023-03-23 15:26:20 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-05-27 13:19:07 +02:00
|
|
|
|
2020-12-16 19:56:57 +01:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
|
|
|
|
2022-05-03 22:54:55 +02:00
|
|
|
# Create a dedicated NGINX config
|
2020-12-16 19:56:57 +01:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated php-fpm config
|
2021-12-09 11:50:09 +01:00
|
|
|
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
|
2023-01-12 09:28:16 +01:00
|
|
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
2020-12-16 19:56:57 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MODIFY A CONFIG FILE
|
|
|
|
#=================================================
|
|
|
|
|
2023-03-23 15:26:20 +01:00
|
|
|
#ynh_add_config --template="../conf/config-dist.php" --destination="$install_dir/data/config.php"
|
2020-12-16 19:56:57 +01:00
|
|
|
|
2023-03-23 15:26:20 +01:00
|
|
|
#chmod 400 "$install_dir/data/config.php"
|
|
|
|
#chown $app "$install_dir/data/config.php"
|
2020-12-16 19:56:57 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|