1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/elabftw_ynh.git synced 2024-09-03 18:26:23 +02:00
elabftw_ynh/scripts/upgrade

86 lines
2.9 KiB
Text
Raw Normal View History

2021-08-12 13:28:44 +02:00
#!/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=2
2024-02-29 11:12:03 +01:00
# Move sources to subdir
if [ ! -d "$install_dir/sources" ]; then
mkdir "$install_dir/sources"
find . -mindepth 1 -maxdepth 1 ! -name "sources" -exec mv -t sources "{}" +
2021-08-12 13:28:44 +02:00
fi
#=================================================
2024-02-29 11:12:03 +01:00
# INSTALL DEPENDENCIES
2021-08-12 13:28:44 +02:00
#=================================================
2024-02-29 11:12:03 +01:00
ynh_script_progression --message="Upgrading NodeJS..." --weight=1
2021-08-12 13:28:44 +02:00
2024-02-29 11:12:03 +01:00
ynh_install_nodejs --nodejs_version=$nodejs_version
2021-08-12 13:28:44 +02:00
#=================================================
2024-02-29 11:12:03 +01:00
# INSTALL AND INITIALIZE COMPOSER
2021-08-12 13:28:44 +02:00
#=================================================
2024-02-29 11:12:03 +01:00
ynh_script_progression --message="Upgrading Composer..." --weight=10
2021-08-12 13:28:44 +02:00
2024-02-29 11:12:03 +01:00
ynh_install_composer --install_args="--no-dev"
2021-08-12 13:28:44 +02:00
2021-11-20 09:43:20 +01:00
#=================================================
2024-02-29 11:12:03 +01:00
# DOWNLOAD, CHECK AND UNPACK SOURCE
2021-11-20 09:43:20 +01:00
#=================================================
2024-02-29 11:12:03 +01:00
ynh_script_progression --message="Upgrading source files..." --weight=7
2021-11-20 09:43:20 +01:00
2024-02-29 11:12:03 +01:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir/sources" --full_replace=1 --keep="config.php"
2021-11-20 09:43:20 +01:00
2024-02-29 11:12:03 +01:00
mkdir -p "$install_dir/sources/"{cache,uploads}
2022-05-17 19:05:53 +02:00
2024-02-29 11:12:03 +01:00
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
2021-08-12 13:28:44 +02:00
2022-05-17 16:57:46 +02:00
#=================================================
# INSTALL AND INITIALIZE COMPOSER
#=================================================
2024-02-29 11:12:03 +01:00
ynh_script_progression --message="Building $app..." --weight=30
2022-05-17 16:57:46 +02:00
2024-02-29 11:12:03 +01:00
pushd "$install_dir/sources"
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn install --pure-lockfile --prod
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn run buildall
2022-05-17 16:57:46 +02:00
2024-02-29 11:12:03 +01:00
ynh_composer_exec --commands="install --prefer-dist --no-cache --no-progress --no-dev -a"
2022-05-17 16:57:46 +02:00
2024-02-29 11:12:03 +01:00
ynh_secure_remove node_modules
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn cache clean
2022-05-17 16:57:46 +02:00
2024-02-29 11:12:03 +01:00
ynh_exec_as "$app" "php$phpversion" "bin/console" db:update
2022-05-17 16:57:46 +02:00
popd
2024-02-29 11:12:03 +01:00
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
2022-05-17 16:57:46 +02:00
2021-08-12 13:28:44 +02:00
#=================================================
2024-02-29 11:12:03 +01:00
# REAPPLY SYSTEM CONFIGURATIONS
2021-08-12 13:28:44 +02:00
#=================================================
2024-02-29 11:12:03 +01:00
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
2021-08-12 13:28:44 +02:00
2024-02-29 11:12:03 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
2021-08-12 13:28:44 +02:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last