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