1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/freshrss_ynh.git synced 2024-09-03 18:36:33 +02:00
freshrss_ynh/scripts/upgrade
eric_G 4a44a04efd
Testing (#185)
* change autoupdate.strategy from "latest_github_tag" to "latest_github_release"

* [autopatch] TEST BEFORE MERGE ynh_setup_source --full_replace=1

* bump minimal required ynh version

* bump package version

* backup & restore logs (#179)

* cleaning

* Auto-update READMEs

* Upgrade to v1.24.0 (#181)

* Upgrade to v1.24.0
https://github.com/FreshRSS/FreshRSS/releases/tag/1.24.0

* Auto-update READMEs

* Update upgrade (#184)

* Update manifest.toml

* Auto-update READMEs

---------

Co-authored-by: OniriCorpe <oniricorpe@disroot.org>
Co-authored-by: Yunohost-Bot <>
Co-authored-by: OniriCorpe <oniricorpe@yunohost.org>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: YunoHost Bot <yunohost-bot@users.noreply.github.com>
2024-06-09 22:14:14 +02:00

110 lines
3.8 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if [ -z "$admin" ]; then
admin=$(ynh_app_setting_get --app="$app" --key=admin_user)
if [ -z "$admin" ]; then
ynh_die --message="no admin user found"
fi;
ynh_app_setting_delete --app="$app" --key=admin_user
ynh_app_setting_set --app="$app" --key=admin --value="$admin"
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=1
# 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
chmod -R o-rwx "$install_dir"
chown -R "$app":www-data "$install_dir"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating $app's configuration files..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CRON CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading Cron configuration..."
ynh_add_config --template="freshrss.cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# LOG FILES
#=================================================
if [ -f /tmp/FreshRSS.log ]; then
ynh_secure_remove --file="/tmp/FreshRSS.log"
fi
if [ -f "$install_dir/$app.log" ]; then
ynh_secure_remove --file="/var/www/$app/$app.log"
fi
log_path="/var/log/$app"
mkdir -p "$log_path"
chown "$app":www-data "$log_path"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression --message="Upgrading Fail2Ban configuration..."
# 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
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPGRADING FRESHRSS
#=================================================
ynh_script_progression --message="Upgrading $app..." --weight=1
# reconfigure application with latest parameters
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"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last