Skip to content

Commit 918ea29

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

File tree

3 files changed

+569
-1
lines changed

3 files changed

+569
-1
lines changed

cmdeploy/src/cmdeploy/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,22 @@ 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(
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+
485501
def check_config(config):
486502
mail_domain = config.mail_domain
487503
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:
731747
packages=["fcgiwrap"],
732748
)
733749

750+
apt.packages(
751+
name="Install coturn STUN and TURN server",
752+
packages=["coturn"],
753+
)
754+
734755
www_path = importlib.resources.files(__package__).joinpath("../../../www").resolve()
735756

736757
build_dir = www_path.joinpath("build")
@@ -743,6 +764,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
743764
dovecot_need_restart = _configure_dovecot(config, debug=debug)
744765
postfix_need_restart = _configure_postfix(config, debug=debug)
745766
nginx_need_restart = _configure_nginx(config)
767+
coturn_need_restart = _configure_coturn(config)
746768
_uninstall_mta_sts_daemon()
747769

748770
_remove_rspamd()
@@ -784,6 +806,14 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
784806
restarted=nginx_need_restart,
785807
)
786808

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

0 commit comments

Comments
 (0)