Skip to content

Commit 0de0a5b

Browse files
committed
feat: setup coturn STUN/TURN server
1 parent 2de8b15 commit 0de0a5b

File tree

3 files changed

+567
-1
lines changed

3 files changed

+567
-1
lines changed

cmdeploy/src/cmdeploy/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,20 @@ def _remove_rspamd() -> None:
482482
apt.packages(name="Remove rspamd", packages="rspamd", present=False)
483483

484484

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+
485499
def check_config(config):
486500
mail_domain = config.mail_domain
487501
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:
731745
packages=["fcgiwrap"],
732746
)
733747

748+
apt.packages(
749+
name="Install coturn STUN and TURN server",
750+
packages=["coturn"],
751+
)
752+
734753
www_path = importlib.resources.files(__package__).joinpath("../../../www").resolve()
735754

736755
build_dir = www_path.joinpath("build")
@@ -743,6 +762,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
743762
dovecot_need_restart = _configure_dovecot(config, debug=debug)
744763
postfix_need_restart = _configure_postfix(config, debug=debug)
745764
nginx_need_restart = _configure_nginx(config)
765+
coturn_need_restart = _configure_coturn(config)
746766
_uninstall_mta_sts_daemon()
747767

748768
_remove_rspamd()
@@ -784,6 +804,14 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
784804
restarted=nginx_need_restart,
785805
)
786806

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+
787815
# This file is used by auth proxy.
788816
# https://wiki.debian.org/EtcMailName
789817
server.shell(

0 commit comments

Comments
 (0)