94 lines
3.6 KiB
Bash
Executable File
94 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression "Ensuring downward compatibility..."
|
|
|
|
# Delete deprecated `firstname`/`lastname` settings. See upstream https://github.com/YunoHost/yunohost/pull/1516
|
|
ynh_app_setting_delete --key=email_firstname
|
|
ynh_app_setting_delete --key=email_lastname
|
|
ynh_app_setting_delete --key=email # also delete unnecessary duplicate of state storage
|
|
|
|
# Retrieve `$admin` user settings
|
|
default_from_email_address=$(ynh_app_setting_get --key=default_from_email_address)
|
|
if [ -z "$default_from_email_address" ]; then
|
|
default_from_email_address="${app}@${domain}"
|
|
ynh_app_setting_set --key=default_from_email_address --value="$default_from_email_address"
|
|
fi
|
|
|
|
default_from_email_name=$(ynh_app_setting_get --key=default_from_email_name)
|
|
if [ -z "$default_from_email_name" ]; then
|
|
default_from_email_name="${app}@${domain}"
|
|
ynh_app_setting_set --key=default_from_email_name --value="$default_from_email_name"
|
|
fi
|
|
|
|
ynh_app_setting_set_default --key=api_secret --value="$(ynh_string_random --length=32)"
|
|
ynh_app_setting_set_default --key=app_key --value="$(ynh_string_random --length=32)"
|
|
ynh_app_setting_set_default --key=phantomjs_key --value="$(ynh_string_random --length=32)"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression "Upgrading source files..."
|
|
|
|
# Download, check integrity, uncompress and patch the source from manifest.toml
|
|
ynh_setup_source --dest_dir="$install_dir" --full_replace --keep=".env public/storage"
|
|
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression "Updating $app's configuration files..."
|
|
|
|
ynh_config_add --template="default.env" --destination="$install_dir/.env"
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression "Upgrading system configurations related to $app..."
|
|
|
|
ynh_config_add_phpfpm
|
|
|
|
ynh_config_add_nginx
|
|
|
|
ynh_config_add --template="cron" --destination="/etc/cron.d/$app"
|
|
|
|
#=================================================
|
|
# UPGRADE DATABASE
|
|
#=================================================
|
|
ynh_script_progression "Upgrading the database..."
|
|
|
|
pushd "$install_dir"
|
|
# Clear caches
|
|
# https://github.com/invoiceninja/invoiceninja/issues/7397
|
|
#ynh_safe_rm $install_dir/bootstrap/cache/
|
|
#ynh_safe_rm $install_dir/storage/framework/cache/
|
|
#ynh_safe_rm $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)
|
|
mkdir -p $install_dir/storage/framework/cache/data/
|
|
chown -R $app:www-data $install_dir/storage/framework/cache/data/
|
|
php$php_version artisan view:clear
|
|
php$php_version artisan cache:clear
|
|
|
|
# Run the database migrations
|
|
php$php_version artisan migrate --force --no-interaction --verbose
|
|
|
|
# Optimize the framework for better performance
|
|
php$php_version artisan optimize --no-interaction --verbose
|
|
popd
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression "Upgrade of $app completed"
|