From af47664bbd6e9dc745e8bbeee957fbaeb59f4e47 Mon Sep 17 00:00:00 2001 From: lapineige Date: Sun, 21 Jan 2024 14:20:26 +0100 Subject: [PATCH] build again on upgrade --- scripts/upgrade | 55 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index e31fa34..53e1d3d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,6 +11,13 @@ source /usr/share/yunohost/helpers upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + #================================================= # "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) #================================================= @@ -27,24 +34,54 @@ fi chown -R $app:www-data "$install_dir" +================================================= +# Building the release #================================================= -# REAPPLY SYSTEM CONFIGURATIONS -#================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 - -ynh_add_nginx_config +ynh_script_progression --message="Building Bonfire release... (This will take a long time)" --weight=1 +export TERM=linux # why is that not defined ? +export TERMINFO=/etc/terminfo +### DONT USE GLOBAL NPM INSTALL +ynh_replace_string --match_string="npm install --global" --replace_string="npm install" --target_file="$install_dir/justfile" +ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no $ynh_node_load_PATH just rel-build" #================================================= # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) #================================================= # UPDATE A CONFIG FILE #================================================= -#ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression --message="Updating a configuration file... (this will remove any manual change you could have made before)" --weight=1 -#ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file" +ynh_add_config --template=".env" --destination="$install_dir/.env" -#chmod 400 "$install_dir/some_config_file" -#chown $app:$app "$install_dir/some_config_file" +chmod 400 "$install_dir/.env" +chown $app:$app "$install_dir/.env" + +#================================================= +# REAPPLY SYSTEM CONFIGURATIONS + Run the service +#================================================= +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 + +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +# Create a dedicated systemd config +ynh_add_systemd_config + +yunohost service add $app --description="Bonfire daemon" --log="/var/log/$app/$app.log" + +ynh_script_progression --message="Starting Bonfire daemon service..." --weight=1 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT