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
2024-02-28 22:46:32 +01:00

81 lines
3 KiB
Bash

#!/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
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
# ynh_script_progression --message="Ensuring downward compatibility..."
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading NodeJS..." --weight=5
ynh_install_nodejs --nodejs_version="$nodejs_version"
#=================================================
# 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="config/public.js config/private.js"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
mkdir "$install_dir/dist"
chown -R "$app:$app" "$install_dir/dist" "$install_dir/global" "$install_dir/config"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# BUILD NODE DEPENDENCIES
#=================================================
#REMOVEME? ynh_script_progression --message="Building node dependencies..." --weight=90
pushd "$install_dir"
ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install --loglevel warn
popd
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
yunohost service add "$app" --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last