@@ -482,6 +482,22 @@ def _remove_rspamd() -> None:
482
482
apt .packages (name = "Remove rspamd" , packages = "rspamd" , present = False )
483
483
484
484
485
+ def _configure_coturn (config ) -> bool :
486
+ """Configures coturn STUN and TURN server."""
487
+ coturn_config = files .template (
488
+ src = importlib .resources .files (__package__ ).joinpath (
489
+ "coturn/turnserver.conf.j2"
490
+ ),
491
+ dest = "/etc/turnserver.conf" ,
492
+ user = "root" ,
493
+ group = "root" ,
494
+ mode = "640" ,
495
+ config = config ,
496
+ )
497
+ need_restart = coturn_config .changed
498
+ return need_restart
499
+
500
+
485
501
def check_config (config ):
486
502
mail_domain = config .mail_domain
487
503
if mail_domain != "testrun.org" and not mail_domain .endswith (".testrun.org" ):
@@ -731,6 +747,11 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
731
747
packages = ["fcgiwrap" ],
732
748
)
733
749
750
+ apt .packages (
751
+ name = "Install coturn STUN and TURN server" ,
752
+ packages = ["coturn" ],
753
+ )
754
+
734
755
www_path = importlib .resources .files (__package__ ).joinpath ("../../../www" ).resolve ()
735
756
736
757
build_dir = www_path .joinpath ("build" )
@@ -743,6 +764,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
743
764
dovecot_need_restart = _configure_dovecot (config , debug = debug )
744
765
postfix_need_restart = _configure_postfix (config , debug = debug )
745
766
nginx_need_restart = _configure_nginx (config )
767
+ coturn_need_restart = _configure_coturn (config )
746
768
_uninstall_mta_sts_daemon ()
747
769
748
770
_remove_rspamd ()
@@ -784,6 +806,14 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
784
806
restarted = nginx_need_restart ,
785
807
)
786
808
809
+ systemd .service (
810
+ name = "Start and enable coturn" ,
811
+ service = "coturn.service" ,
812
+ running = True ,
813
+ enabled = True ,
814
+ restarted = coturn_need_restart ,
815
+ )
816
+
787
817
# This file is used by auth proxy.
788
818
# https://wiki.debian.org/EtcMailName
789
819
server .shell (
0 commit comments