2014-06-02 13:38:03 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-29 00:55:27 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2022-03-25 01:09:30 +01:00
|
|
|
# CHECK VERSION
|
2018-01-29 00:55:27 +01:00
|
|
|
#=================================================
|
|
|
|
|
2022-03-25 01:09:30 +01:00
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
2018-01-29 00:55:27 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-03-25 01:09:30 +01:00
|
|
|
# STANDARD UPGRADE STEPS
|
2022-05-05 02:45:58 +02:00
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Stopping a systemd service..."
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
2018-01-29 00:55:27 +01:00
|
|
|
#=================================================
|
2022-03-25 01:09:30 +01:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2018-01-29 00:55:27 +01:00
|
|
|
#=================================================
|
|
|
|
|
2022-03-25 01:09:30 +01:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
2018-01-29 00:55:27 +01:00
|
|
|
then
|
2022-03-25 01:09:30 +01:00
|
|
|
ynh_script_progression --message="Upgrading source files..."
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-06-11 18:30:58 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2018-01-29 00:55:27 +01:00
|
|
|
fi
|
2022-03-25 01:09:30 +01:00
|
|
|
|
2023-06-11 18:30:58 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2018-01-29 00:55:27 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-03-25 01:09:30 +01:00
|
|
|
# NGINX CONFIGURATION
|
2018-01-29 00:55:27 +01:00
|
|
|
#=================================================
|
2022-03-25 01:09:30 +01:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
2018-01-29 00:55:27 +01:00
|
|
|
|
2022-03-25 01:09:30 +01:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2018-01-29 00:55:27 +01:00
|
|
|
|
2022-03-25 08:30:34 +01:00
|
|
|
#=================================================
|
|
|
|
# UPGRADE DEPENDENCIES
|
|
|
|
#=================================================
|
2023-06-11 18:39:46 +02:00
|
|
|
ynh_script_progression --message="Upgrading dependencies..."
|
2022-03-25 08:30:34 +01:00
|
|
|
|
2022-05-05 02:45:58 +02:00
|
|
|
ynh_install_nodejs --nodejs_version=$nodejs_version
|
2022-03-25 08:30:34 +01:00
|
|
|
|
2018-01-29 00:55:27 +01:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# REMOVE GOOGLE !!!
|
|
|
|
#=================================================
|
|
|
|
|
2023-06-11 18:30:58 +02:00
|
|
|
sed --in-place "/googlecode\|googleapis/d" "$install_dir/index.html"
|
2018-01-29 00:55:27 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-05-05 02:45:58 +02:00
|
|
|
# BUILD APP
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Building app..."
|
|
|
|
|
2023-06-11 18:30:58 +02:00
|
|
|
pushd "$install_dir"
|
2022-05-05 02:45:58 +02:00
|
|
|
ynh_use_nodejs
|
2023-06-11 19:10:07 +02:00
|
|
|
ynh_exec_warn_less ynh_npm install --production
|
2022-05-05 02:45:58 +02:00
|
|
|
popd
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
2018-01-29 00:55:27 +01:00
|
|
|
#=================================================
|
2022-05-05 02:45:58 +02:00
|
|
|
ynh_script_progression --message="Upgrading systemd configuration..."
|
2018-01-29 00:55:27 +01:00
|
|
|
|
2022-05-05 02:45:58 +02:00
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_supervisor_config
|
2018-01-29 00:55:27 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-03-25 01:09:30 +01:00
|
|
|
# GENERIC FINALIZATION
|
2022-05-05 02:45:58 +02:00
|
|
|
#=================================================
|
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
|
|
|
|
|
|
yunohost service add $app --log="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
|
|
|
|
|
|
|
ynh_supervisor_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
2018-01-29 00:55:27 +01:00
|
|
|
#=================================================
|
2022-03-25 01:09:30 +01:00
|
|
|
# END OF SCRIPT
|
2018-01-29 00:55:27 +01:00
|
|
|
#=================================================
|
|
|
|
|
2022-03-25 01:09:30 +01:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|