mirror of
https://github.com/chatmail/relay.git
synced 2026-05-13 01:24:36 +00:00
use systemd timer instead of cron-job for expiry (tested by hand on c2)
This commit is contained in:
@@ -129,6 +129,8 @@ def _install_remote_venv_with_chatmaild(config) -> None:
|
||||
"chatmail-metadata",
|
||||
"lastlogin",
|
||||
"turnserver",
|
||||
"chatmail-expire",
|
||||
"chatmail-expire.timer",
|
||||
):
|
||||
execpath = fn if fn != "filtermail-incoming" else "filtermail"
|
||||
params = dict(
|
||||
@@ -137,20 +139,21 @@ def _install_remote_venv_with_chatmaild(config) -> None:
|
||||
remote_venv_dir=remote_venv_dir,
|
||||
mail_domain=config.mail_domain,
|
||||
)
|
||||
source_path = importlib.resources.files(__package__).joinpath(
|
||||
"service", f"{fn}.service.f"
|
||||
)
|
||||
|
||||
basename = fn if "." in fn else f"{fn}.service"
|
||||
|
||||
source_path = importlib.resources.files(__package__).joinpath("service", f"{basename}.f")
|
||||
content = source_path.read_text().format(**params).encode()
|
||||
|
||||
files.put(
|
||||
name=f"Upload {fn}.service",
|
||||
name=f"Upload {basename}",
|
||||
src=io.BytesIO(content),
|
||||
dest=f"/etc/systemd/system/{fn}.service",
|
||||
dest=f"/etc/systemd/system/{basename}",
|
||||
**root_owned,
|
||||
)
|
||||
systemd.service(
|
||||
name=f"Setup {fn} service",
|
||||
service=f"{fn}.service",
|
||||
name=f"Setup {basename}",
|
||||
service=basename,
|
||||
running=True,
|
||||
enabled=True,
|
||||
restarted=True,
|
||||
@@ -158,6 +161,7 @@ def _install_remote_venv_with_chatmaild(config) -> None:
|
||||
)
|
||||
|
||||
|
||||
|
||||
def _configure_opendkim(domain: str, dkim_selector: str = "dkim") -> bool:
|
||||
"""Configures OpenDKIM"""
|
||||
need_restart = False
|
||||
@@ -387,13 +391,11 @@ def _configure_dovecot(config: Config, debug: bool = False) -> bool:
|
||||
)
|
||||
need_restart |= lua_push_notification_script.changed
|
||||
|
||||
files.template(
|
||||
src=importlib.resources.files(__package__).joinpath("dovecot/expunge.cron.j2"),
|
||||
dest="/etc/cron.d/expunge",
|
||||
user="root",
|
||||
group="root",
|
||||
mode="644",
|
||||
config=config,
|
||||
# remove historic expunge script
|
||||
# which is now implemented through a systemd chatmail-expire service/timer
|
||||
files.file(
|
||||
path="/etc/cron.d/expunge",
|
||||
present=False,
|
||||
)
|
||||
|
||||
# as per https://doc.dovecot.org/configuration_manual/os/
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# expire mailboxes, old and large messages
|
||||
2 0 * * * vmail /usr/local/lib/chatmaild/venv/bin/chatmail-expire /usr/local/lib/chatmaild/chatmail.ini {config.mailboxes_dir} --remove
|
||||
9
cmdeploy/src/cmdeploy/service/chatmail-expire.service.f
Normal file
9
cmdeploy/src/cmdeploy/service/chatmail-expire.service.f
Normal file
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=chatmail mail storage expiration job
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=vmail
|
||||
ExecStart=/usr/local/lib/chatmaild/venv/bin/chatmail-expire /usr/local/lib/chatmaild/chatmail.ini --remove
|
||||
|
||||
9
cmdeploy/src/cmdeploy/service/chatmail-expire.timer.f
Normal file
9
cmdeploy/src/cmdeploy/service/chatmail-expire.timer.f
Normal file
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Run Daily chatmail-expire job
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 00:02:00
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
Reference in New Issue
Block a user