mirror of
https://github.com/YunoHost-Apps/synapse-admin_ynh.git
synced 2024-09-03 20:26:34 +02:00
Simplify messy handling of the synapse endpoint conf thingy
This commit is contained in:
parent
7004724de2
commit
43eb1b4e9d
4 changed files with 21 additions and 56 deletions
|
@ -1,36 +1,24 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# COMMON VARIABLES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# PERSONAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPDATE SYNAPSE ENDPOINT
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
_update_synapse_nginx_config() {
|
|
||||||
# This helper fixes when synapse changes domain, shouldn't happen though...
|
|
||||||
old_synapse_domain="$synapse_domain"
|
|
||||||
synapse_domain=$(ynh_app_setting_get --app="$synapse_app" --key=domain)
|
synapse_domain=$(ynh_app_setting_get --app="$synapse_app" --key=domain)
|
||||||
|
synapse_port=$(ynh_app_setting_get --app="$synapse_app" --key=port_synapse)
|
||||||
|
if [[ -z "$synapse_port" ]]
|
||||||
|
then
|
||||||
|
# The setting was synapse_port in older versions of the app
|
||||||
synapse_port=$(ynh_app_setting_get --app="$synapse_app" --key=synapse_port)
|
synapse_port=$(ynh_app_setting_get --app="$synapse_app" --key=synapse_port)
|
||||||
ynh_app_setting_set --app=$app --key=synapse_domain --value="$synapse_domain"
|
if [[ -z "$synapse_port" ]]
|
||||||
|
ynh_die --message="Unable to find synapse port ?!"
|
||||||
if [[ "${synapse_domain}" != "${old_synapse_domain}" ]]; then
|
|
||||||
ynh_backup_if_checksum_is_different --file="/etc/nginx/conf.d/${old_synapse_domain}.d/$app.endpoint.conf"
|
|
||||||
ynh_delete_file_checksum --file="/etc/nginx/conf.d/${old_synapse_domain}.d/$app.endpoint.conf"
|
|
||||||
ynh_secure_remove --file="/etc/nginx/conf.d/${old_synapse_domain}.d/$app.endpoint.conf"
|
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
_add_synapse_endpoint_nginx_config() {
|
||||||
|
# In case the domain changed for some reason
|
||||||
|
old_endpoint_confs_for_this_app="$(ls /etc/nginx/conf.d/!($synapse_domain).d/$app.endpoint.conf)"
|
||||||
|
for FILE in $old_endpoint_confs_for_this_app
|
||||||
|
do
|
||||||
|
ynh_delete_file_checksum --file="$FILE"
|
||||||
|
ynh_secure_remove --file="$FILE"
|
||||||
|
done
|
||||||
|
|
||||||
ynh_add_config --template="endpoint.nginx.conf" --destination="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf"
|
ynh_add_config --template="endpoint.nginx.conf" --destination="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf"
|
||||||
}
|
}
|
||||||
#=================================================
|
|
||||||
# EXPERIMENTAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# FUTURE OFFICIAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
|
@ -9,19 +9,13 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPDATE SYNAPSE ENDPOINT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration for Synapse..." --weight=2
|
|
||||||
|
|
||||||
_update_synapse_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
ynh_change_url_nginx_config
|
||||||
|
_add_synapse_endpoint_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -14,10 +14,6 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Getting settings from Synapse..." --weight=2
|
ynh_script_progression --message="Getting settings from Synapse..." --weight=2
|
||||||
|
|
||||||
synapse_domain=$(ynh_app_setting_get --app="$synapse_app" --key=domain)
|
|
||||||
synapse_port=$(ynh_app_setting_get --app="$synapse_app" --key=synapse_port)
|
|
||||||
ynh_app_setting_set --app=$app --key=synapse_domain --value="$synapse_domain"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -36,9 +32,7 @@ ynh_script_progression --message="Adding system configurations related to $app..
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
_add_synapse_endpoint_nginx_config
|
||||||
# Create NGINX config to access /_synapse/admin endpoint
|
|
||||||
ynh_add_config --template="endpoint.nginx.conf" --destination="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -21,7 +21,7 @@ if ynh_compare_current_package_version --comparison le --version 0.8.3~ynh2; the
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If synapse_app doesn't exist, create it and assume it is `synapse`
|
# If synapse_app doesn't exist, create it and assume it is `synapse`
|
||||||
if [ -z "$synapse_app" ]; then
|
if [ -z "${synapse_app:-}" ]; then
|
||||||
synapse_app="synapse"
|
synapse_app="synapse"
|
||||||
ynh_app_setting_set --app=$app --key=synapse_app --value=$synapse_app
|
ynh_app_setting_set --app=$app --key=synapse_app --value=$synapse_app
|
||||||
fi
|
fi
|
||||||
|
@ -56,13 +56,6 @@ fi
|
||||||
chmod -R o-rwx "$install_dir"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$install_dir"
|
chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPDATE SYNAPSE ENDPOINT
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration for Synapse..." --weight=2
|
|
||||||
|
|
||||||
_update_synapse_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REAPPLY SYSTEM CONFIGURATIONS
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -70,11 +63,7 @@ ynh_script_progression --message="Upgrading system configurations related to $ap
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
_add_synapse_endpoint_nginx_config
|
||||||
# Create NGINX config to access /_synapse/admin endpoint
|
|
||||||
synapse_domain=$(ynh_app_setting_get --app=$synapse_app --key=domain)
|
|
||||||
synapse_port=$(ynh_app_setting_get --app=$synapse_app --key=synapse_port)
|
|
||||||
ynh_add_config --template="endpoint.nginx.conf" --destination="/etc/nginx/conf.d/${synapse_domain}.d/$app.endpoint.conf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
Loading…
Add table
Reference in a new issue