1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/2FAuth_ynh.git synced 2024-09-03 20:36:18 +02:00
2fauth_ynh/scripts/upgrade
2024-06-17 14:57:31 +02:00

83 lines
2.7 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if [ -z "${key:-}" ]; then
key=$(ynh_string_random --length=45 | base64)
ynh_app_setting_set --app=$app --key=key --value=$key
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=3
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="public/storage storage .env"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
ynh_add_fpm_config
ynh_add_nginx_config
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading a configuration file..." --weight=1
# Setup application config
ynh_add_config --template=".env" --destination="$install_dir/.env"
chmod 640 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
#=================================================
# INSTALL 2FAUTH WITH COMPOSER
#=================================================
ynh_script_progression --message="Installing $app with Composer..." --weight=15
ynh_secure_remove --file=$install_dir/package-lock.json
ynh_install_composer --install_args="--ignore-platform-reqs --prefer-dist --no-scripts --no-dev"
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building..." --weight=10
ynh_exec_warn_less ynh_composer_exec --commands="update"
# Setup application config
pushd $install_dir
php$phpversion artisan cache:clear
php$phpversion artisan config:clear
php$phpversion artisan migrate -n
php$phpversion artisan passport:install -n
php$phpversion artisan config:cache -n
php$phpversion artisan route:cache
popd
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last