2020-11-15 21:54:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2024-08-04 19:44:26 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2024-08-04 19:44:26 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep=".env public/storage"
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2023-06-05 10:48:49 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2021-08-29 19:34:44 +02:00
|
|
|
#=================================================
|
2023-06-05 11:03:43 +02:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2021-08-29 19:34:44 +02:00
|
|
|
#=================================================
|
2023-06-05 11:03:43 +02:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2021-12-22 08:30:36 +01:00
|
|
|
# Create a dedicated PHP-FPM config
|
2023-11-16 16:43:53 +01:00
|
|
|
ynh_add_fpm_config
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2023-11-16 16:45:02 +01:00
|
|
|
# Create a dedicated NGINX config
|
2023-06-05 10:48:49 +02:00
|
|
|
ynh_add_nginx_config
|
2023-06-05 11:03:43 +02:00
|
|
|
|
2023-11-16 16:45:02 +01:00
|
|
|
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
2023-06-05 11:03:43 +02:00
|
|
|
chown root: "/etc/cron.d/$app"
|
|
|
|
chmod 644 "/etc/cron.d/$app"
|
|
|
|
|
2021-09-19 20:18:54 +02:00
|
|
|
#=================================================
|
2023-11-16 18:34:04 +01:00
|
|
|
# ENSURE BACKWARD COMPATIBILITY
|
2023-11-16 15:06:03 +01:00
|
|
|
#=================================================
|
2023-11-16 18:34:04 +01:00
|
|
|
ynh_script_progression --message="Ensuring backward compatibility..." --weight=1
|
2023-11-16 15:06:03 +01:00
|
|
|
|
2023-11-16 18:34:04 +01:00
|
|
|
# Delete deprecated `firstname`/`lastname` settings. See upstream https://github.com/YunoHost/yunohost/pull/1516
|
|
|
|
ynh_app_setting_delete --app=$app --key=email_firstname
|
|
|
|
ynh_app_setting_delete --app=$app --key=email_lastname
|
2023-11-16 20:25:15 +01:00
|
|
|
ynh_app_setting_delete --app=$app --key=email # also delete unnecessary duplicate of state storage
|
2023-11-16 15:06:03 +01:00
|
|
|
|
2023-11-16 18:34:04 +01:00
|
|
|
# Retrieve `$admin` user settings
|
|
|
|
email_fullname="$(ynh_user_get_info --username=$admin --key=fullname)"
|
2023-11-16 20:25:15 +01:00
|
|
|
email="$(ynh_user_get_info --username=$admin --key=mail)"
|
2023-11-16 15:06:03 +01:00
|
|
|
|
|
|
|
#=================================================
|
2021-09-19 20:18:54 +02:00
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
2024-08-04 19:44:26 +02:00
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
2021-09-19 20:18:54 +02:00
|
|
|
|
2024-08-04 19:44:26 +02:00
|
|
|
ynh_add_config --template="default.env" --destination="$install_dir/.env"
|
2021-09-19 20:18:54 +02:00
|
|
|
|
2024-08-04 19:44:26 +02:00
|
|
|
chmod 600 "$install_dir/.env"
|
|
|
|
chown $app:$app "$install_dir/.env"
|
2021-09-19 20:18:54 +02:00
|
|
|
|
2020-11-15 21:54:22 +01:00
|
|
|
#=================================================
|
|
|
|
# UPGRADE DATABASE
|
|
|
|
#=================================================
|
2023-06-05 11:03:43 +02:00
|
|
|
ynh_script_progression --message="Upgrading the database..." --weight=1
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2023-06-05 10:48:49 +02:00
|
|
|
pushd "$install_dir"
|
2022-07-23 14:11:45 +02:00
|
|
|
# Clear caches
|
|
|
|
# https://github.com/invoiceninja/invoiceninja/issues/7397
|
2024-08-04 19:53:02 +02:00
|
|
|
#ynh_secure_remove --file=$install_dir/bootstrap/cache/
|
|
|
|
#ynh_secure_remove --file=$install_dir/storage/framework/cache/
|
|
|
|
#ynh_secure_remove --file=$install_dir/storage/framework/sessions/
|
2022-07-26 21:13:04 +02:00
|
|
|
|
2024-08-04 19:53:02 +02:00
|
|
|
#mkdir -p $install_dir/bootstrap/cache/ $install_dir/storage/framework/cache/ $install_dir/storage/framework/sessions/
|
2022-07-26 21:13:04 +02:00
|
|
|
|
|
|
|
# clear cached stuff under /app/data/storage/framework (https://github.com/laravel/framework/issues/17377)
|
|
|
|
php$phpversion artisan view:clear
|
|
|
|
php$phpversion artisan cache:clear
|
2020-11-15 21:54:22 +01:00
|
|
|
|
|
|
|
# Run the database migrations
|
2021-08-29 19:34:44 +02:00
|
|
|
php$phpversion artisan migrate --force --no-interaction --verbose
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2022-07-23 14:11:45 +02:00
|
|
|
# Optimize the framework for better performance
|
|
|
|
php$phpversion artisan optimize --no-interaction --verbose
|
|
|
|
|
|
|
|
# clear cached stuff under /app/data/storage/framework (https://github.com/laravel/framework/issues/17377)
|
2024-08-04 19:53:02 +02:00
|
|
|
#php$phpversion artisan view:clear
|
|
|
|
#php$phpversion artisan cache:clear
|
2020-11-15 21:54:22 +01:00
|
|
|
popd
|
|
|
|
|
2023-06-05 10:48:49 +02:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2020-11-15 21:54:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|