2023-04-30 12:33:38 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
|
# GENERIC START
|
|
|
|
|
#=================================================
|
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
2024-01-21 14:20:26 +01:00
|
|
|
|
#=================================================
|
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
|
#=================================================
|
|
|
|
|
ynh_script_progression --message="Stopping a systemd service..."
|
|
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
|
|
|
|
|
|
2023-04-30 12:33:38 +02:00
|
|
|
|
#=================================================
|
|
|
|
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
|
|
|
|
#=================================================
|
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
|
then
|
|
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
|
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
|
|
2024-01-21 14:20:26 +01:00
|
|
|
|
=================================================
|
|
|
|
|
# Building the release
|
2023-04-30 12:33:38 +02:00
|
|
|
|
#=================================================
|
2024-01-21 14:20:26 +01:00
|
|
|
|
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"
|
2023-04-30 12:33:38 +02:00
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
|
|
|
|
#=================================================
|
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
|
#=================================================
|
2024-01-21 14:20:26 +01:00
|
|
|
|
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=".env" --destination="$install_dir/.env"
|
|
|
|
|
|
|
|
|
|
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"
|
2023-04-30 12:33:38 +02:00
|
|
|
|
|
2024-01-21 14:20:26 +01:00
|
|
|
|
ynh_script_progression --message="Starting Bonfire daemon service..." --weight=1
|
2023-04-30 12:33:38 +02:00
|
|
|
|
|
2024-01-21 14:20:26 +01:00
|
|
|
|
# Start a systemd service
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
2023-04-30 12:33:38 +02:00
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
|
# END OF SCRIPT
|
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|