2017-04-26 19:01:53 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
2020-05-16 09:15:15 +02:00
|
|
|
# GENERIC START
|
2017-04-26 19:01:53 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2020-05-16 09:15:15 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
|
|
|
2017-04-26 19:01:53 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2020-05-16 09:15:15 +02:00
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
2020-10-04 17:09:09 +02:00
|
|
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
2017-04-26 19:01:53 +02:00
|
|
|
|
2020-05-16 09:15:15 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
2017-04-26 19:01:53 +02:00
|
|
|
|
2021-02-26 08:57:55 +01:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
|
|
|
|
# Cleaning legacy permissions
|
|
|
|
if ynh_legacy_permissions_exists; then
|
|
|
|
ynh_legacy_permissions_delete_all
|
|
|
|
|
|
|
|
ynh_app_setting_delete --app=$app --key=is_public
|
|
|
|
fi
|
|
|
|
|
2017-04-26 19:01:53 +02:00
|
|
|
#=================================================
|
2020-05-16 09:15:15 +02:00
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
2017-04-26 19:01:53 +02:00
|
|
|
#=================================================
|
2020-05-16 09:15:15 +02:00
|
|
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
|
2017-04-26 19:01:53 +02:00
|
|
|
|
2020-05-16 09:15:15 +02:00
|
|
|
# Backup the current version of the app
|
|
|
|
ynh_backup_before_upgrade
|
2017-04-26 19:01:53 +02:00
|
|
|
ynh_clean_setup () {
|
2020-05-16 09:15:15 +02:00
|
|
|
# restore it if the upgrade fails
|
|
|
|
ynh_restore_upgradebackup
|
2017-04-26 19:01:53 +02:00
|
|
|
}
|
2020-05-16 09:15:15 +02:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2021-06-27 20:02:50 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated user (if not existing)
|
|
|
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
|
|
|
2017-04-26 19:01:53 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
2020-05-16 09:15:15 +02:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=2
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source --dest_dir="$final_path"
|
|
|
|
fi
|
2017-04-26 19:01:53 +02:00
|
|
|
|
2021-06-27 20:02:50 +02:00
|
|
|
chmod 750 "$final_path"
|
|
|
|
chmod -R o-rwx "$final_path"
|
|
|
|
chown -R $app:www-data "$final_path"
|
|
|
|
|
2017-04-26 19:01:53 +02:00
|
|
|
#=================================================
|
2020-05-16 09:15:15 +02:00
|
|
|
# NGINX CONFIGURATION
|
2017-04-26 19:01:53 +02:00
|
|
|
#=================================================
|
2020-10-04 17:09:09 +02:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
2017-04-26 19:01:53 +02:00
|
|
|
|
2020-10-04 17:09:09 +02:00
|
|
|
# Create a dedicated NGINX config
|
2020-05-16 09:15:15 +02:00
|
|
|
ynh_add_nginx_config
|
2017-04-26 19:01:53 +02:00
|
|
|
|
2020-05-16 09:15:15 +02:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2020-10-04 17:09:09 +02:00
|
|
|
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=3
|
2017-04-26 19:01:53 +02:00
|
|
|
|
2020-10-04 17:09:09 +02:00
|
|
|
# Create a dedicated PHP-FPM config
|
2021-04-05 19:25:42 +02:00
|
|
|
ynh_add_fpm_config
|
2017-04-26 19:01:53 +02:00
|
|
|
|
2020-05-16 09:15:15 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
|
2020-10-04 17:09:09 +02:00
|
|
|
ynh_script_progression --message="Configuring RSS-Bridge..." --weight=2
|
2017-04-26 19:01:53 +02:00
|
|
|
# Enable every bridge
|
|
|
|
for i in $final_path/bridges/*.php ; do
|
2020-03-31 05:07:19 +02:00
|
|
|
echo $(basename $i) | sed "s|Bridge.php$||g" | tee -a $final_path/whitelist.txt
|
2017-04-26 19:01:53 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2020-10-04 17:09:09 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
2020-05-16 09:15:15 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-10-04 17:09:09 +02:00
|
|
|
ynh_script_progression --message="Upgrade of RSS-Bridge completed" --last
|