2017-07-12 01:45:37 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2022-01-22 20:55:44 +01:00
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
2017-07-12 01:45:37 +02:00
|
|
|
|
2022-03-22 23:38:41 +01:00
|
|
|
# If secret doesn't exist, create it
|
|
|
|
if [ -z "$secret" ]; then
|
|
|
|
secret=""
|
|
|
|
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
|
|
|
fi
|
|
|
|
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
|
|
|
|
2022-01-22 20:55:44 +01:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Upgrading source files..."
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-10-30 09:43:36 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir" --keep="configuration.php"
|
2022-01-22 20:55:44 +01:00
|
|
|
fi
|
2017-07-12 01:45:37 +02:00
|
|
|
|
2023-10-30 09:29:45 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2017-07-12 01:45:37 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
# PHP-FPM CONFIGURATION
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
|
2017-07-12 01:45:37 +02:00
|
|
|
|
2022-01-22 20:55:44 +01:00
|
|
|
# Create a dedicated PHP-FPM config
|
|
|
|
ynh_add_fpm_config
|
|
|
|
|
2022-08-27 21:52:03 +02:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2022-03-22 21:51:49 +01:00
|
|
|
mkdir -p "/var/log/$app"
|
|
|
|
chmod 750 "/var/log/$app"
|
|
|
|
chmod -R o-rwx "/var/log/$app"
|
|
|
|
chown -R $app:www-data "/var/log/$app"
|
|
|
|
|
2022-01-22 20:55:44 +01:00
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
|
|
ynh_use_logrotate --non-append
|
2017-07-12 01:45:37 +02:00
|
|
|
|
|
|
|
#=================================================
|
2023-10-30 09:43:36 +01:00
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# RESTORE A CONFIG FILE
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
2023-10-30 09:43:36 +01:00
|
|
|
ynh_script_progression --message="Restoring configuration file..."
|
2022-01-22 20:55:44 +01:00
|
|
|
|
2023-10-30 09:43:36 +01:00
|
|
|
ynh_add_config --template="configuration.php" --destination="$install_dir/configuration.php"
|
|
|
|
|
|
|
|
chmod 400 "$install_dir/configuration.php"
|
|
|
|
chown $app:$app "$install_dir/configuration.php"
|
2022-01-22 20:55:44 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2017-07-12 01:45:37 +02:00
|
|
|
|
2022-01-22 20:55:44 +01:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|