2023-10-05 15:34:34 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression -m "Stopping a systemd service..." -w 1
|
|
|
|
|
|
|
|
ynh_systemd_action -a stop
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
|
|
|
ynh_script_progression -m "Upgrading source files..." -w 1
|
|
|
|
|
|
|
|
ynh_setup_source -d "$install_dir"
|
|
|
|
fi
|
|
|
|
|
|
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
|
|
|
|
ynh_use_nodejs
|
|
|
|
npm --prefix "$install_dir" install
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression -m "Upgrading system configurations related to $app..." -w 1
|
|
|
|
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
|
|
|
#=================================================
|
|
|
|
# CONFIGURATION FOR SUBPATH
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression -m "Updating the configuration..." -w 1
|
|
|
|
|
2023-10-05 16:56:32 +02:00
|
|
|
if [ "$path" = "/" ]; then
|
|
|
|
conf_path=""
|
|
|
|
else
|
|
|
|
conf_path=$path
|
|
|
|
fi
|
|
|
|
|
2023-10-05 15:34:34 +02:00
|
|
|
ynh_add_config -t default.json -d "$install_dir/config/default.json"
|
|
|
|
|
|
|
|
yunohost service add $app --description="Web frontend for Urban Dictionary" --log="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression -m "Starting the systemd service..." -w 1
|
|
|
|
|
|
|
|
ynh_systemd_action -a start
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression -m "Upgrade of $app completed" -l
|