2014-09-21 12:12:55 +02:00
|
|
|
#!/bin/bash
|
2016-08-31 08:44:08 +02:00
|
|
|
|
2019-02-23 11:48:57 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2022-10-02 23:03:44 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
2018-10-21 17:55:39 +02:00
|
|
|
#=================================================
|
2019-02-23 11:48:57 +01:00
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
2018-10-21 17:55:39 +02:00
|
|
|
#=================================================
|
2022-10-02 23:03:44 +02:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
2019-02-23 11:48:57 +01:00
|
|
|
|
2019-07-02 00:38:57 +02:00
|
|
|
if [ -z "$admin" ]; then
|
2023-11-01 16:57:59 +01:00
|
|
|
admin=$(ynh_app_setting_get --app="$app" --key=admin_user)
|
|
|
|
if [ -z "$admin" ]; then
|
2019-05-23 12:48:48 +02:00
|
|
|
ynh_die --message="no admin user found"
|
|
|
|
fi;
|
2023-11-01 16:57:59 +01:00
|
|
|
ynh_app_setting_delete --app="$app" --key=admin_user
|
|
|
|
ynh_app_setting_set --app="$app" --key=admin --value="$admin"
|
2019-05-23 12:48:48 +02:00
|
|
|
fi
|
|
|
|
|
2021-04-17 18:39:02 +02:00
|
|
|
#=================================================
|
2022-10-02 23:03:44 +02:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2021-04-17 18:39:02 +02:00
|
|
|
#=================================================
|
2024-06-09 22:14:14 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
2021-04-17 18:39:02 +02:00
|
|
|
|
2024-06-09 22:14:14 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source --dest_dir="$install_dir" --keep="data/config.php data/users/ extensions/" #--full_replace=1
|
2017-03-12 18:38:14 +01:00
|
|
|
|
2023-06-29 19:08:38 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
2023-11-01 16:57:59 +01:00
|
|
|
chown -R "$app":www-data "$install_dir"
|
2017-03-05 20:56:16 +01:00
|
|
|
|
2019-02-23 11:48:57 +01:00
|
|
|
#=================================================
|
2024-05-12 22:39:06 +02:00
|
|
|
# UPDATE A CONFIG FILE
|
2019-02-23 11:48:57 +01:00
|
|
|
#=================================================
|
2024-05-12 22:39:06 +02:00
|
|
|
ynh_script_progression --message="Updating $app's configuration files..." --weight=1
|
2023-11-01 16:57:59 +01:00
|
|
|
|
2020-09-04 22:39:46 +02:00
|
|
|
# Create a dedicated PHP-FPM config
|
2023-09-29 18:53:41 +02:00
|
|
|
ynh_add_fpm_config
|
2019-02-23 11:48:57 +01:00
|
|
|
|
2022-10-02 23:03:44 +02:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2021-06-28 22:23:04 +02:00
|
|
|
|
2023-11-01 16:57:59 +01:00
|
|
|
#=================================================
|
|
|
|
# CRON CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading Cron configuration..."
|
|
|
|
|
2024-05-12 22:39:06 +02:00
|
|
|
ynh_add_config --template="freshrss.cron" --destination="/etc/cron.d/$app"
|
2021-08-28 10:54:58 +02:00
|
|
|
chown root: "/etc/cron.d/$app"
|
2021-06-28 22:23:04 +02:00
|
|
|
chmod 644 "/etc/cron.d/$app"
|
2019-05-27 12:44:46 +02:00
|
|
|
|
2023-11-01 16:57:59 +01:00
|
|
|
#=================================================
|
|
|
|
# LOG FILES
|
|
|
|
#=================================================
|
|
|
|
|
2019-11-17 11:00:54 +01:00
|
|
|
if [ -f /tmp/FreshRSS.log ]; then
|
2022-10-03 00:00:06 +02:00
|
|
|
ynh_secure_remove --file="/tmp/FreshRSS.log"
|
|
|
|
fi
|
|
|
|
|
2023-11-01 16:57:59 +01:00
|
|
|
if [ -f "$install_dir/$app.log" ]; then
|
2022-10-03 00:00:06 +02:00
|
|
|
ynh_secure_remove --file="/var/www/$app/$app.log"
|
2019-11-17 11:00:54 +01:00
|
|
|
fi
|
|
|
|
|
2022-10-31 22:24:46 +01:00
|
|
|
log_path="/var/log/$app"
|
2023-11-01 16:57:59 +01:00
|
|
|
mkdir -p "$log_path"
|
|
|
|
chown "$app":www-data "$log_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading logrotate configuration..."
|
|
|
|
|
2022-10-03 00:00:06 +02:00
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
2023-11-01 16:57:59 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP FAIL2BAN
|
|
|
|
#=================================================
|
2024-05-12 22:39:06 +02:00
|
|
|
ynh_script_progression --message="Upgrading Fail2Ban configuration..."
|
2023-11-01 16:57:59 +01:00
|
|
|
|
|
|
|
# If it doesn't exist, create the logfile, required before configuring fail2ban
|
|
|
|
if [ ! -f "/var/log/${domain}-access.log" ]; then
|
|
|
|
touch "/var/log/${domain}-access.log"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create a dedicated Fail2Ban config
|
|
|
|
ynh_add_fail2ban_config --logpath="/var/log/${domain}-access.log" --failregex="<HOST> .* \"GET /api/.*\" 401" --max_retry=5
|
|
|
|
|
2019-02-23 11:48:57 +01:00
|
|
|
#=================================================
|
2023-06-29 19:08:38 +02:00
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# UPGRADING FRESHRSS
|
2019-02-23 11:48:57 +01:00
|
|
|
#=================================================
|
2024-05-12 22:39:06 +02:00
|
|
|
ynh_script_progression --message="Upgrading $app..." --weight=1
|
2019-02-23 11:48:57 +01:00
|
|
|
|
2023-06-29 19:08:38 +02:00
|
|
|
# reconfigure application with latest parameters
|
2023-11-01 16:57:59 +01:00
|
|
|
ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/cli/reconfigure.php" --default_user "$admin" --auth_type http_auth --environment production --base_url "https://$domain$path" --title FreshRSS --api_enabled --db-type mysql --db-host localhost --db-user "$db_name" --db-password "$db_pwd" --db-base "$db_name"
|
2019-02-23 11:48:57 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-10-02 23:03:44 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|