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

81 lines
2.8 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
#=================================================
2024-05-29 10:15:08 +02:00
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
2021-08-12 13:28:44 +02:00
2024-02-29 11:12:03 +01:00
# Move sources to subdir
if [ ! -d "$install_dir/sources" ]; then
mkdir "$install_dir/sources"
2024-03-05 11:25:41 +01:00
find . -mindepth 1 -maxdepth 1 ! -name "sources" -exec mv -t "$install_dir/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
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-03-03 12:33:18 +01:00
ynh_script_progression --message="Building $app with Composer..." --weight=30
2022-05-17 16:57:46 +02:00
2024-02-29 11:12:03 +01:00
pushd "$install_dir/sources"
2024-03-03 14:53:14 +01:00
ynh_install_composer --workdir="$install_dir/sources" --install_args="--no-dev"
2024-03-03 12:33:18 +01:00
2024-02-29 11:12:03 +01:00
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-03-03 14:53:14 +01:00
ynh_composer_exec --workdir="$install_dir/sources" --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