diff --git a/README.md b/README.md index 8d785cb..c781159 100644 --- a/README.md +++ b/README.md @@ -90,20 +90,20 @@ If you have a dynamic IP address, you also might need to update this config auto #### OpenVPN -In case of you have an OpenVPN server you might want than `coturn-synapse` restart when the VPN restart. To do this create a file named `/usr/local/bin/openvpn_up_script.sh` with this content: +In case of you have an OpenVPN server you might want than `synapse-coturn` restart when the VPN restart. To do this create a file named `/usr/local/bin/openvpn_up_script.sh` with this content: ``` #!/bin/bash ( sleep 5 - sudo systemctl restart coturn-synapse.service + sudo systemctl restart synapse-coturn.service ) & exit 0 ``` Add this line in you sudo config file `/etc/sudoers` ``` -openvpn ALL=(ALL) NOPASSWD: /bin/systemctl restart coturn-synapse.service +openvpn ALL=(ALL) NOPASSWD: /bin/systemctl restart synapse-coturn.service ``` And add this line in your OpenVPN config file diff --git a/README_fr.md b/README_fr.md index 2526b4a..4acc11f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -90,20 +90,20 @@ If you have a dynamic IP address, you also might need to update this config auto #### OpenVPN -In case of you have an OpenVPN server you might want than `coturn-synapse` restart when the VPN restart. To do this create a file named `/usr/local/bin/openvpn_up_script.sh` with this content: +In case of you have an OpenVPN server you might want than `synapse-coturn` restart when the VPN restart. To do this create a file named `/usr/local/bin/openvpn_up_script.sh` with this content: ``` #!/bin/bash ( sleep 5 - sudo systemctl restart coturn-synapse.service + sudo systemctl restart synapse-coturn.service ) & exit 0 ``` Add this line in you sudo config file `/etc/sudoers` ``` -openvpn ALL=(ALL) NOPASSWD: /bin/systemctl restart coturn-synapse.service +openvpn ALL=(ALL) NOPASSWD: /bin/systemctl restart synapse-coturn.service ``` And add this line in your OpenVPN config file diff --git a/conf/coturn-synapse.service b/conf/synapse-coturn.service similarity index 100% rename from conf/coturn-synapse.service rename to conf/synapse-coturn.service diff --git a/conf/matrix-synapse.service b/conf/synapse.service similarity index 100% rename from conf/matrix-synapse.service rename to conf/synapse.service diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 2854220..5e096b7 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -39,7 +39,7 @@ https://federationtester.matrix.org/ can be used to easily debug federation issu ### Turnserver For Voip and video conferencing a turnserver is also installed (and configured). The turnserver listens on two UDP and TCP ports. You can get them with these commands: -``` +```bash yunohost app setting synapse port_turnserver_tls yunohost app setting synapse port_turnserver_alt_tls @@ -48,7 +48,7 @@ The turnserver will also choose a port dynamically when a new call starts. The r For some security reason the ports range (49153 - 49193) isn't automatically open by default. If you want to use the synapse server for voip or conferencing you will need to open this port range manually. To do this just run this command: -``` +```bash yunohost firewall allow Both 49153:49193 ``` @@ -64,20 +64,20 @@ If you have a dynamic IP address, you also might need to update this config auto #### OpenVPN -In case of you have an OpenVPN server you might want than `coturn-synapse` restart when the VPN restart. To do this create a file named `/usr/local/bin/openvpn_up_script.sh` with this content: -``` +In case of you have an OpenVPN server you might want than `synapse-coturn` restart when the VPN restart. To do this create a file named `/usr/local/bin/openvpn_up_script.sh` with this content: +```bash #!/bin/bash ( sleep 5 - sudo systemctl restart coturn-synapse.service + sudo systemctl restart synapse-coturn.service ) & exit 0 ``` Add this line in you sudo config file `/etc/sudoers` ``` -openvpn ALL=(ALL) NOPASSWD: /bin/systemctl restart coturn-synapse.service +openvpn ALL=(ALL) NOPASSWD: /bin/systemctl restart synapse-coturn.service ``` And add this line in your OpenVPN config file diff --git a/scripts/backup b/scripts/backup index 7a30a65..39c6e64 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,8 +14,8 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -if [[ ! "$(systemctl status matrix-$app.service)" =~ "Active: inactive (dead)" ]]; then - ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service with this command before to run the backup 'systemctl stop matrix-$app.service'" +if [[ ! "$(systemctl status $app.service)" =~ "Active: inactive (dead)" ]]; then + ynh_print_warn --message="It's hightly recommended to make your backup when the service is stopped. Please stop $app service with this command before to run the backup 'systemctl stop $app.service'" fi #================================================= @@ -71,9 +71,9 @@ ynh_backup --src_path="/etc/matrix-$app" #================================================= ynh_backup --src_path="/etc/default/matrix-$app" -ynh_backup --src_path="/etc/systemd/system/matrix-$app.service" +ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/default/coturn-$app" -ynh_backup --src_path="/etc/systemd/system/coturn-$app.service" +ynh_backup --src_path="/etc/systemd/system/$app-coturn.service" #================================================= # BACKUP SYNAPSE DATA diff --git a/scripts/change_url b/scripts/change_url index 877fdbf..b85f316 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -19,7 +19,7 @@ then fi # We stop the service -ynh_systemd_action --service_name=matrix-$app.service --action=stop +ynh_systemd_action --service_name=$app.service.service --action=stop #================================================= # STANDARD MODIFICATIONS @@ -52,7 +52,7 @@ set_permissions #================================================= ynh_script_progression --message="Restarting Synapse services..." --weight=5 -ynh_systemd_action --service_name=coturn-$app.service --action=restart -ynh_systemd_action --service_name=matrix-$app --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 +ynh_systemd_action --service_name=$app-coturn.service --action=restart +ynh_systemd_action --service_name=$app.service --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 49b00c5..314d355 100644 --- a/scripts/install +++ b/scripts/install @@ -201,10 +201,10 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=2 # Create systemd service for synapse and turnserver cp ../conf/default_matrix-synapse /etc/default/matrix-$app -ynh_add_systemd_config --service=matrix-$app --template=matrix-synapse.service +ynh_add_systemd_config --service=matrix-$app --template=synapse.service cp ../conf/default_coturn /etc/default/coturn-$app -ynh_add_systemd_config --service=coturn-$app --template=coturn-synapse.service +ynh_add_systemd_config --service=$app-coturn --template=synapse-coturn.service #================================================= # NGINX CONFIGURATION @@ -287,16 +287,16 @@ set_permissions # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add matrix-$app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $port_synapse_tls -yunohost service add coturn-$app --needs_exposed_ports $port_turnserver_tls +yunohost service add $app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $port_synapse_tls +yunohost service add $app-coturn --needs_exposed_ports $port_turnserver_tls #================================================= # RELOAD SERVICES #================================================= ynh_script_progression --message="Restarting Synapse services..." --weight=11 -ynh_systemd_action --service_name=coturn-$app.service --action=restart -ynh_systemd_action --service_name=matrix-$app --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 +ynh_systemd_action --service_name=$app-coturn.service --action=restart +ynh_systemd_action --service_name=$app.service --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 #================================================= # SETUP FAIL2BAN diff --git a/scripts/remove b/scripts/remove index 2d2fad5..4250073 100755 --- a/scripts/remove +++ b/scripts/remove @@ -17,14 +17,14 @@ source /usr/share/yunohost/helpers #================================================= # Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status matrix-$app >/dev/null 2>&1 +if yunohost service status $app >/dev/null 2>&1 then - yunohost service remove matrix-$app + yunohost service remove $app fi -if yunohost service status coturn-$app >/dev/null 2>&1 +if yunohost service status $app-coturn >/dev/null 2>&1 then - yunohost service remove coturn-$app + yunohost service remove $app-coturn fi #================================================= @@ -32,8 +32,8 @@ fi #================================================= ynh_script_progression --message="Stopping and removing the systemd service" --weight=2 -ynh_remove_systemd_config --service=matrix-$app -ynh_remove_systemd_config --service=coturn-$app +ynh_remove_systemd_config --service=$app +ynh_remove_systemd_config --service=$app-coturn #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/restore b/scripts/restore index b3865e7..5582145 100644 --- a/scripts/restore +++ b/scripts/restore @@ -67,15 +67,15 @@ ynh_psql_execute_file_as_root --file="${YNH_CWD}/dump.sql" --database="$synapse_ ynh_script_progression --message="Enable systemd services" --weight=2 # systemctl daemon-reload -systemctl enable matrix-$app.service --quiet -systemctl enable coturn-$app.service --quiet +systemctl enable $app.service --quiet +systemctl enable $app-coturn.service --quiet #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add matrix-$app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $port_synapse_tls -yunohost service add coturn-$app --needs_exposed_ports $port_turnserver_tls +yunohost service add $app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $port_synapse_tls +yunohost service add $app-coturn --needs_exposed_ports $port_turnserver_tls #================================================= # CREATE A DH FILE @@ -121,8 +121,8 @@ set_permissions #================================================= ynh_script_progression --message="Restarting Synapse services..." --weight=7 -ynh_systemd_action --service_name=coturn-$app.service --action=restart -ynh_systemd_action --service_name=matrix-$app --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 +ynh_systemd_action --service_name=$app-coturn.service --action=restart +ynh_systemd_action --service_name=$app.service --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index af19ef8..51605e8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -220,8 +220,32 @@ if [ -z $synapse_user_app_pwd ]; then yunohost user create $app -F "Synapse Application" -d $domain -p "$synapse_user_app_pwd" fi +#================================================= +# MIGRATION 7 : STANDARDIZE SYSTEMD UNIT +#================================================= + +if [ ! -e /etc/systemd/system/matrix-$app.service ] +then + ynh_script_progression --message="Migrating systemd unit to standard name..." + + systemctl stop matrix-$app.service + systemctl stop synapse-coturn.service + + yunohost service remove matrix-$app + yunohost service remove coturn-$app + + ynh_secure_remove --file=/etc/systemd/system/matrix-$app.service + ynh_secure_remove --file=/etc/systemd/system/coturn-$app.service + + touch /etc/systemd/system/$app.service +fi + +#================================================= +# STOP SERVICES +#================================================= + # We stop the service -ynh_systemd_action --service_name=matrix-$app.service --action=stop +ynh_systemd_action --service_name=$app.service --action=stop #================================================= # MIGRATION 6 : Migrate data directory @@ -410,8 +434,8 @@ fi # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add matrix-$app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $port_synapse_tls -yunohost service add coturn-$app --needs_exposed_ports $port_turnserver_tls +yunohost service add $app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $port_synapse_tls +yunohost service add $app-coturn --needs_exposed_ports $port_turnserver_tls #================================================= # UPDATE SYSTEMD @@ -420,10 +444,10 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=3 # Create systemd service for synapse and turnserver cp ../conf/default_matrix-synapse /etc/default/matrix-$app -ynh_add_systemd_config --service=matrix-$app --template=matrix-synapse.service +ynh_add_systemd_config --service=$app --template=synapse.service cp ../conf/default_coturn /etc/default/coturn-$app -ynh_add_systemd_config --service=coturn-$app --template=coturn-synapse.service +ynh_add_systemd_config --service=$app-coturn --template=synapse-coturn.service #================================================= # UPGRADE FAIL2BAN @@ -474,8 +498,8 @@ ynh_replace_string __DOMAIN__ $domain ../hooks/post_cert_update #================================================= ynh_script_progression --message="Restarting Synapse services..." --weight=5 -ynh_systemd_action --service_name=coturn-$app.service --action=restart -ynh_systemd_action --service_name=matrix-$app --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 +ynh_systemd_action --service_name=$app-coturn.service --action=restart +ynh_systemd_action --service_name=$app.service --action=restart --line_match="Synapse now listening on TCP port $port_synapse_tls" --log_path="/var/log/matrix-$app/homeserver.log" --timeout=300 #================================================= # END OF SCRIPT diff --git a/sources/Coturn_config_rotate.sh b/sources/Coturn_config_rotate.sh index 4cfa5e2..bc3945e 100644 --- a/sources/Coturn_config_rotate.sh +++ b/sources/Coturn_config_rotate.sh @@ -27,7 +27,7 @@ setfacl -R -m user:turnserver:rX /etc/matrix-$app_instance if [ "$old_config_line" != "$new_config_line" ] then - systemctl restart coturn-$app_instance.service + systemctl restart $app_instance-coturn.service fi exit 0 diff --git a/sources/update_synapse_for_appservice.sh b/sources/update_synapse_for_appservice.sh index 072c3dd..428e843 100644 --- a/sources/update_synapse_for_appservice.sh +++ b/sources/update_synapse_for_appservice.sh @@ -21,7 +21,7 @@ chown matrix-$app /etc/matrix-$app/app-service/* chmod 600 $service_config_file chmod 600 /etc/matrix-$app/app-service/* -systemctl restart matrix-$app +systemctl restart $app.service if [ $? -eq 0 ]; then rm /tmp/app_service_backup.yaml