#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) #================================================= # STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) #REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi if [ -z "$admin" ]; then #REMOVEME? 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 #REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then 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/" fi chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE #================================================= # UPGRADING FRESHRSS #================================================= ynh_script_progression --message="Upgrading FreshRSS..." --weight=1 # reconfigure application with latest parameters 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 #================================================= # CRON SETUP #================================================= ynh_script_progression --message="Setting up cron..." --weight=1 ynh_add_config --template="../conf/freshrss.cron" --destination="/etc/cron.d/$app" chown root: "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app" if [ -f /tmp/FreshRSS.log ]; then ynh_secure_remove --file="/tmp/FreshRSS.log" fi if [ -f /var/www/$app/$app.log ]; then ynh_secure_remove --file="/var/www/$app/$app.log" fi #================================================= # GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 log_path="/var/log/$app" mkdir -p $log_path chown $app:www-data "$log_path" # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last