2021-05-10 15:15:42 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
2022-01-24 23:05:47 +01:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
|
2024-01-07 20:58:17 +01:00
|
|
|
if ynh_compare_current_package_version --comparison le --version 0.8.3~ynh2; then
|
|
|
|
ynh_die --message="Upgrade from version 0.8.3 is not possible. You must uninstall and reinstall Synapse-admin package manually"
|
2022-01-24 23:05:47 +01:00
|
|
|
fi
|
|
|
|
|
2022-02-26 23:03:46 +01:00
|
|
|
# If synapse_app doesn't exist, create it and assume it is `synapse`
|
|
|
|
if [ -z "$synapse_app" ]; then
|
2024-01-07 20:58:17 +01:00
|
|
|
synapse_app="synapse"
|
|
|
|
ynh_app_setting_set --app=$app --key=synapse_app --value=$synapse_app
|
2022-02-26 23:03:46 +01:00
|
|
|
fi
|
|
|
|
|
2023-04-10 17:39:53 +02:00
|
|
|
# Delete service and nodejs dependencies
|
2024-01-07 20:58:17 +01:00
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.8.7~ynh1; then
|
|
|
|
yunohost service remove $app
|
|
|
|
ynh_remove_systemd_config
|
2023-04-10 17:39:53 +02:00
|
|
|
|
2024-01-07 20:58:17 +01:00
|
|
|
ynh_remove_nodejs
|
|
|
|
ynh_remove_logrotate
|
2022-02-26 22:44:20 +01:00
|
|
|
|
2024-01-07 20:58:17 +01:00
|
|
|
ynh_app_setting_delete --app=$app --key=synapse_port
|
|
|
|
ynh_app_setting_delete --app=$app --key=port
|
|
|
|
fi
|
2021-08-06 20:11:14 +02:00
|
|
|
|
2024-01-07 20:58:17 +01:00
|
|
|
if ynh_compare_current_package_version --comparison lt --version 0.8.7~ynh3; then
|
|
|
|
ynh_app_setting_delete --app=$app --key=synapse_domain
|
|
|
|
ynh_app_setting_delete --app=$app --key=synapse_port
|
|
|
|
fi
|
2021-08-06 20:11:14 +02:00
|
|
|
|
2021-05-10 15:15:42 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
2024-01-07 20:58:17 +01:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
|
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=2
|
2021-05-10 15:15:42 +02:00
|
|
|
|
2024-01-07 20:58:17 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2021-05-10 15:15:42 +02:00
|
|
|
fi
|
|
|
|
|
2024-01-07 20:58:17 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2021-08-06 20:11:14 +02:00
|
|
|
|
2021-05-10 15:15:42 +02:00
|
|
|
#=================================================
|
2024-01-07 20:58:17 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2021-05-10 15:15:42 +02:00
|
|
|
#=================================================
|
2024-01-07 20:58:17 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
2021-05-10 15:15:42 +02:00
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2022-02-26 22:44:20 +01:00
|
|
|
# Create NGINX config to access /_synapse/admin endpoint
|
2024-01-07 20:58:17 +01:00
|
|
|
synapse_domain=$(ynh_app_setting_get --app=$synapse_app --key=domain)
|
|
|
|
synapse_port=$(ynh_app_setting_get --app=$synapse_app --key=synapse_port)
|
2022-03-01 11:39:34 +01:00
|
|
|
ynh_add_config --template="endpoint.nginx.conf" --destination="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf"
|
2022-02-26 22:44:20 +01:00
|
|
|
|
2021-05-10 15:15:42 +02:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|