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

77 lines
2.7 KiB
Text
Raw Normal View History

2021-03-11 00:34:24 +01:00
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
2024-02-28 22:22:42 +01:00
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
2021-03-11 00:34:24 +01:00
2021-08-05 23:28:50 +02:00
#=================================================
2024-02-28 22:22:42 +01:00
# UPGRADE DEPENDENCIES
2021-08-05 23:28:50 +02:00
#=================================================
2024-02-28 22:22:42 +01:00
ynh_script_progression --message="Upgrading NodeJS..." --weight=5
2021-08-05 23:28:50 +02:00
2024-02-28 22:22:42 +01:00
ynh_install_nodejs --nodejs_version="$nodejs_version"
2021-08-05 23:28:50 +02:00
2021-03-11 00:34:24 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-02-28 22:22:42 +01:00
ynh_script_progression --message="Upgrading source files..." --weight=3
2021-03-11 00:34:24 +01:00
2024-02-28 22:22:42 +01:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config/public.js config/private.js"
2021-03-11 00:34:24 +01:00
2024-02-28 22:22:42 +01:00
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
2021-03-11 00:34:24 +01:00
2024-02-28 22:22:42 +01:00
mkdir "$install_dir/dist"
chown -R "$app:$app" "$install_dir/dist" "$install_dir/global" "$install_dir/config"
2022-07-29 01:48:52 +02:00
2021-03-11 00:34:24 +01:00
#=================================================
# SPECIFIC UPGRADE
#=================================================
# BUILD NODE DEPENDENCIES
#=================================================
2024-02-29 18:54:27 +01:00
ynh_script_progression --message="Building node dependencies..." --weight=20
2021-03-11 00:34:24 +01:00
2024-02-28 22:22:42 +01:00
pushd "$install_dir"
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install --loglevel warn
2021-03-11 00:34:24 +01:00
popd
2022-07-29 01:48:52 +02:00
#=================================================
2024-02-28 22:22:42 +01:00
# REAPPLY SYSTEM CONFIGURATIONS
2022-07-29 01:48:52 +02:00
#=================================================
2024-02-28 22:22:42 +01:00
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
2022-07-29 01:48:52 +02:00
2024-02-28 22:22:42 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2021-03-11 00:34:24 +01:00
# Create a dedicated systemd config
2021-08-05 23:28:50 +02:00
ynh_add_systemd_config
2024-02-28 22:22:42 +01:00
yunohost service add "$app" --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
2021-03-11 00:34:24 +01:00
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# START SYSTEMD SERVICE
#=================================================
2024-02-28 22:22:42 +01:00
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
2021-03-11 00:34:24 +01:00
2024-02-28 22:22:42 +01:00
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
2021-03-11 00:34:24 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last