mirror of
https://github.com/YunoHost-Apps/invoiceninja5_ynh.git
synced 2024-09-03 19:26:23 +02:00
119 lines
4.3 KiB
Bash
Executable file
119 lines
4.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# CHECK VERSION
|
|
#=================================================
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# 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" --full_replace=1 --keep=".env public/storage"
|
|
fi
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
ynh_add_fpm_config
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
|
chown root: "/etc/cron.d/$app"
|
|
chmod 644 "/etc/cron.d/$app"
|
|
|
|
#=================================================
|
|
# ENSURE BACKWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring backward compatibility..." --weight=1
|
|
|
|
# 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
|
|
ynh_app_setting_delete --app=$app --key=email # also delete unnecessary duplicate of state storage
|
|
|
|
# Retrieve `$admin` user settings
|
|
email_fullname="$(ynh_user_get_info --username=$admin --key=fullname)"
|
|
email="$(ynh_user_get_info --username=$admin --key=mail)"
|
|
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
|
|
|
ynh_add_config --template="default.env" --destination="$install_dir/.env"
|
|
|
|
chmod 400 "$install_dir/.env"
|
|
chown $app:$app "$install_dir/.env"
|
|
fi
|
|
|
|
#=================================================
|
|
# UPGRADE DATABASE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading the database..." --weight=1
|
|
|
|
pushd "$install_dir"
|
|
# Clear caches
|
|
# https://github.com/invoiceninja/invoiceninja/issues/7397
|
|
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/
|
|
|
|
mkdir -p $install_dir/bootstrap/cache/ $install_dir/storage/framework/cache/ $install_dir/storage/framework/sessions/
|
|
|
|
# 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
|
|
|
|
# Run the database migrations
|
|
php$phpversion artisan migrate --force --no-interaction --verbose
|
|
|
|
# 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)
|
|
php$phpversion artisan view:clear
|
|
php$phpversion artisan cache:clear
|
|
|
|
# install snappdf, since it isn't included by default anymore since
|
|
# 5.5.12: https://invoiceninja.github.io/docs/self-host-troubleshooting/#pdf-conversion-issues
|
|
php$phpversion vendor/bin/snappdf download
|
|
# see: https://forum.cloudron.io/topic/11932/invoice-ninja-server-500-internal-error/29
|
|
find vendor/beganovich/snappdf/versions/*-Linux_x64/chrome-linux/ -type f -name chrome* ! -name "*.*" -print -exec chmod 755 {} \;
|
|
popd
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|