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

86 lines
2.7 KiB
Text
Raw Normal View History

2021-04-01 12:47:58 +02: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
#=================================================
2021-04-01 13:08:30 +02:00
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
2021-04-01 12:47:58 +02:00
2023-10-02 22:14:31 +02:00
# If maintenance_mode doesn't exist, create it
if [ -z "${maintenance_mode:-}" ]; then
maintenance_mode=0
ynh_app_setting_set --app=$app --key=maintenance_mode --value=$maintenance_mode
fi
# If fpm_footprint doesn't exist, create it
if [ -z "${fpm_footprint:-}" ]; then
fpm_footprint=high
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
fi
# If fpm_free_footprint doesn't exist, create it
if [ -z "${fpm_free_footprint:-}" ]; then
fpm_free_footprint=0
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
fi
# If fpm_usage doesn't exist, create it
if [ -z "${fpm_usage:-}" ]; then
fpm_usage=medium
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
2021-04-01 12:47:58 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2023-10-02 22:06:16 +02:00
ynh_script_progression --message="Upgrading source files..." --weight=1
2021-04-01 12:47:58 +02:00
2023-10-02 22:06:16 +02:00
# Create a temporary directory
tmpdir="$(mktemp -d)"
cp -a "$install_dir/configuration.ini" "$tmpdir/configuration.ini"
2021-06-08 11:06:12 +02:00
2023-10-02 22:06:16 +02:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" #--keep="configuration.ini"
2021-06-08 11:06:12 +02:00
2023-10-02 22:06:16 +02:00
# Copy the admin saved settings from tmp directory to final config path
cp -a "$tmpdir/configuration.ini" "$install_dir/configuration.ini"
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
2021-04-01 12:47:58 +02:00
fi
2023-10-02 22:06:16 +02:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
2023-10-03 13:52:00 +02:00
chown -R "$app:www-data" "$install_dir"
2021-06-07 17:44:58 +02:00
2021-04-01 12:47:58 +02:00
#=================================================
2023-10-03 13:52:00 +02:00
# REAPPLY SYSTEM CONFIGURATIONS
2021-04-01 12:47:58 +02:00
#=================================================
2023-10-03 13:52:00 +02:00
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
2021-04-01 12:47:58 +02:00
2023-01-10 11:48:07 +01:00
ynh_add_nginx_config
2021-04-01 12:47:58 +02:00
2023-10-03 13:52:00 +02:00
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
2021-04-01 12:47:58 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2021-04-01 13:08:30 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last