mirror of
https://github.com/YunoHost-Apps/synapse_ynh.git
synced 2024-09-03 20:26:38 +02:00
Standardize unit name
This is in prevision for multiple services linked to the same app, so we can have something like $app-coturn, $app-slide-proxy, ...
This commit is contained in:
parent
60324a8f59
commit
b2e2341ff1
13 changed files with 70 additions and 46 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue