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

92 lines
3.1 KiB
Text
Raw Normal View History

2021-12-05 09:05:11 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
2022-05-31 00:12:17 +02:00
# ENSURE DOWNWARD COMPATIBILITY
2021-12-05 09:05:11 +01:00
#=================================================
2022-05-31 00:12:17 +02:00
ynh_script_progression --message="Ensuring downward compatibility..."
2021-12-05 09:05:11 +01:00
2022-05-31 00:12:17 +02:00
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service..." --weight=1
yunohost service remove $app
fi
# Remove the dedicated systemd config
ynh_remove_systemd_config
# Remove the app-specific logrotate config
ynh_remove_logrotate
2021-12-05 09:05:11 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2022-06-07 23:19:35 +02:00
ynh_script_progression --message="Upgrading source files..." --weight=1
2021-12-05 09:05:11 +01:00
2022-06-07 23:19:35 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2023-03-03 19:25:41 +01:00
ynh_setup_source --dest_dir="$install_dir/build"
2021-12-05 09:05:11 +01:00
2023-03-03 19:25:41 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2021-12-05 09:05:11 +01:00
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
2022-03-19 19:08:33 +01:00
# Create a dedicated NGINX config
2021-12-05 09:05:11 +01:00
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
2023-03-03 19:32:32 +01:00
ynh_script_progression --message="Upgrading dependencies..." --weight=18
2021-12-05 09:05:11 +01:00
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# SPECIFIC UPGRADE
#=================================================
2022-03-19 19:08:33 +01:00
# BUILD APP
2021-12-05 09:05:11 +01:00
#=================================================
2022-05-31 00:12:17 +02:00
ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=40
2021-12-05 09:05:11 +01:00
2023-03-03 19:25:41 +01:00
pushd "$install_dir/build"
2022-05-31 00:12:17 +02:00
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --ignore-optional
ynh_exec_warn_less ynh_exec_as $app env NODE_ENV=production $ynh_node_load_PATH yarn build
ynh_exec_warn_less ynh_exec_as $app env NODE_ENV=production $ynh_node_load_PATH yarn cache clean --all
popd
2021-12-05 09:05:11 +01:00
2023-03-03 19:25:41 +01:00
#REMOVEME? ynh_secure_remove --file="$install_dir/live"
ynh_exec_as $app mv "$install_dir/build/build" "$install_dir/live"
#REMOVEME? ynh_secure_remove --file="$install_dir/build"
2021-12-05 09:05:11 +01:00
2023-03-03 19:25:41 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2021-12-05 09:05:11 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last