diff --git a/conf/homeserver.yaml b/conf/homeserver.yaml index 83afbad..0084bf7 100644 --- a/conf/homeserver.yaml +++ b/conf/homeserver.yaml @@ -1017,8 +1017,8 @@ report_stats: __REPORT_STATS__ # A list of application service config files to use # #app_service_config_files: -# - app_service_1.yaml -# - app_service_2.yaml +# +## Managed by a specific config file in /etc/matrix-synapse/conf.d/app_service.yaml # Uncomment to enable tracking of application service IP addresses. Implicitly # enables MAU tracking for application service users. diff --git a/scripts/install b/scripts/install index 8a6949b..db835d9 100644 --- a/scripts/install +++ b/scripts/install @@ -381,14 +381,16 @@ ynh_script_progression --message="Configuring log rotation..." --weight=2 ynh_use_logrotate --logfile "/var/log/matrix-$app" #================================================= -# ADD SCRIPT FOR COTURN CRON +# ADD SCRIPT FOR COTURN CRON AND APP SERVICE #================================================= # WARNING : theses command are used in INSTALL, UPGRADE # For any update do it in all files cp ../sources/Coturn_config_rotate.sh $final_path/ +cp ../sources/update_synapse_for_appservice.sh $final_path/ ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$final_path/Coturn_config_rotate.sh" +ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$final_path/update_synapse_for_appservice.sh" #================================================= # GENERIC FINALIZATION @@ -419,6 +421,7 @@ ynh_replace_string __DOMAIN__ $domain ../hooks/post_cert_update # For any update do it in all files chown $synapse_user:root -R $final_path chmod 770 $final_path/Coturn_config_rotate.sh +chmod 700 $final_path/update_synapse_for_appservice.sh chown $synapse_user:root -R /var/lib/matrix-$app chown $synapse_user:root -R /var/log/matrix-$app chown $synapse_user:root -R /etc/matrix-$app diff --git a/scripts/restore b/scripts/restore index 3d01fba..c0d4616 100644 --- a/scripts/restore +++ b/scripts/restore @@ -230,6 +230,7 @@ ynh_use_logrotate --logfile /var/log/matrix-$app # For any update do it in all files chown $synapse_user:root -R $final_path chmod 770 $final_path/Coturn_config_rotate.sh +chmod 700 $final_path/update_synapse_for_appservice.sh chown $synapse_user:root -R /var/lib/matrix-$app chown $synapse_user:root -R /var/log/matrix-$app chown $synapse_user:root -R /etc/matrix-$app diff --git a/scripts/upgrade b/scripts/upgrade index dc96e06..27c86b8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -415,14 +415,16 @@ fi ynh_store_file_checksum --file="$coturn_config_path" #================================================= -# ADD SCRIPT FOR COTURN CRON +# ADD SCRIPT FOR COTURN CRON AND APP SERVICE #================================================= # WARNING : theses command are used in INSTALL, UPGRADE # For any update do it in all files cp ../sources/Coturn_config_rotate.sh $final_path/ +cp ../sources/update_synapse_for_appservice.sh $final_path/ ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$final_path/Coturn_config_rotate.sh" +ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$final_path/update_synapse_for_appservice.sh" #================================================= # ADVERTISE SERVICE IN ADMIN PANEL @@ -473,6 +475,7 @@ ynh_permission_url --permission main --url $domain/_matrix/cas_server.php/login # For any update do it in all files chown $synapse_user:root -R $final_path chmod 770 $final_path/Coturn_config_rotate.sh +chmod 700 $final_path/update_synapse_for_appservice.sh chown $synapse_user:root -R /var/lib/matrix-$app chown $synapse_user:root -R /var/log/matrix-$app chown $synapse_user:root -R /etc/matrix-$app diff --git a/sources/update_synapse_for_appservice.sh b/sources/update_synapse_for_appservice.sh new file mode 100644 index 0000000..17bbca3 --- /dev/null +++ b/sources/update_synapse_for_appservice.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +app=__APP__ +service_config_file=/etc/matrix-$app/conf.d/app_service.yaml + +# Backup the previous config file +cp $service_config_file /tmp/app_service_backup.yaml + +echo "app_service_config_files:" > $service_config_file +for f in $(ls /etc/matrix-$app/app-service/); do + echo " - /etc/matrix-synapse/$app" >> $service_config_file +done + +# Set permissions +chown matrix-$app $service_config_file +chmod 600 $service_config_file + +systemctl restart matrix-$app + +if [ $? -eq 0 ]; then + rm /tmp/app_service_backup.yaml + exit 0 +else + echo "Failed to restart synapse with the new config file. Restore the old config file !!" + cp /tmp/app_service_backup.yaml $service_config_file +fi