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

93 lines
2.8 KiB
Text
Raw Normal View History

2020-05-02 10:17:12 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
2021-05-16 15:47:40 +02:00
#=================================================
# STANDARD UPGRADE STEPS
2020-05-02 10:17:12 +02:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2022-09-01 02:13:26 +02:00
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
2020-05-02 10:17:12 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-01-05 23:51:07 +01:00
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
ynh_script_progression --message="Upgrading source files..." --weight=1
2020-05-02 10:17:12 +02:00
2024-01-05 23:51:07 +01:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --keep=".env"
2020-05-02 10:17:12 +02:00
fi
2024-01-05 23:51:07 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2020-05-02 10:17:12 +02:00
#=================================================
2022-09-01 02:13:26 +02:00
# SPECIFIC UPGRADE
#=================================================
# INSTALL PHANTOMJS
2020-05-02 10:17:12 +02:00
#=================================================
2022-09-01 02:13:26 +02:00
ynh_script_progression --message="Installing PhantomJS..." --weight=1
2020-05-02 10:17:12 +02:00
2024-01-05 23:51:07 +01:00
_install_phantomjs
2020-05-02 10:17:12 +02:00
#=================================================
2021-05-16 15:47:40 +02:00
# UPDATE A CONFIG FILE
2020-05-02 10:17:12 +02:00
#=================================================
2024-01-05 23:51:07 +01:00
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
ynh_script_progression --message="Updating a configuration file..." --weight=1
2020-05-02 17:16:41 +02:00
2024-01-05 23:51:07 +01:00
ynh_add_config --template="../conf/.env" --destination="$install_dir/.env"
2020-05-02 17:16:41 +02:00
2024-01-05 23:51:07 +01:00
chmod 400 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
fi
2020-05-02 10:17:12 +02:00
#=================================================
# UPGRADE DATABASE
#=================================================
2022-09-01 02:13:26 +02:00
ynh_script_progression --message="Upgrading the database..." --weight=1
2020-05-02 10:17:12 +02:00
2024-01-05 23:51:07 +01:00
pushd "$install_dir"
# Put the application into maintenance mode
php$phpversion artisan down
2024-01-05 23:51:07 +01:00
# Optimize the framework for better performance
php$phpversion artisan optimize
2024-01-05 23:51:07 +01:00
# Run the database migrations
php$phpversion artisan migrate --force
php$phpversion artisan db:seed --force
2020-05-02 10:17:12 +02:00
2024-01-05 23:51:07 +01:00
# Bring the application out of maintenance mode
php$phpversion artisan up
popd
2020-05-02 10:17:12 +02:00
#=================================================
2024-01-05 23:51:07 +01:00
# REAPPLY SYSTEM CONFIGURATIONS
2020-05-02 10:17:12 +02:00
#=================================================
2024-01-05 23:51:07 +01:00
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
2020-05-02 10:17:12 +02:00
2024-01-05 23:51:07 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
2020-05-02 10:17:12 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2022-09-01 02:13:26 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last