1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/invoiceninja_ynh.git synced 2024-09-03 19:26:22 +02:00
invoiceninja_ynh/scripts/upgrade
2024-01-05 23:51:07 +01:00

92 lines
2.8 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
#=================================================
# 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=".env"
fi
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# INSTALL PHANTOMJS
#=================================================
ynh_script_progression --message="Installing PhantomJS..." --weight=1
_install_phantomjs
#=================================================
# UPDATE A CONFIG FILE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_add_config --template="../conf/.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"
# Put the application into maintenance mode
php$phpversion artisan down
# Optimize the framework for better performance
php$phpversion artisan optimize
# Run the database migrations
php$phpversion artisan migrate --force
php$phpversion artisan db:seed --force
# Bring the application out of maintenance mode
php$phpversion artisan up
popd
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last