mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 12:28:06 +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",
|
"chatmail-metadata",
|
||||||
"lastlogin",
|
"lastlogin",
|
||||||
"turnserver",
|
"turnserver",
|
||||||
|
"chatmail-expire",
|
||||||
|
"chatmail-expire.timer",
|
||||||
):
|
):
|
||||||
execpath = fn if fn != "filtermail-incoming" else "filtermail"
|
execpath = fn if fn != "filtermail-incoming" else "filtermail"
|
||||||
params = dict(
|
params = dict(
|
||||||
@@ -137,20 +139,21 @@ def _install_remote_venv_with_chatmaild(config) -> None:
|
|||||||
remote_venv_dir=remote_venv_dir,
|
remote_venv_dir=remote_venv_dir,
|
||||||
mail_domain=config.mail_domain,
|
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()
|
content = source_path.read_text().format(**params).encode()
|
||||||
|
|
||||||
files.put(
|
files.put(
|
||||||
name=f"Upload {fn}.service",
|
name=f"Upload {basename}",
|
||||||
src=io.BytesIO(content),
|
src=io.BytesIO(content),
|
||||||
dest=f"/etc/systemd/system/{fn}.service",
|
dest=f"/etc/systemd/system/{basename}",
|
||||||
**root_owned,
|
**root_owned,
|
||||||
)
|
)
|
||||||
systemd.service(
|
systemd.service(
|
||||||
name=f"Setup {fn} service",
|
name=f"Setup {basename}",
|
||||||
service=f"{fn}.service",
|
service=basename,
|
||||||
running=True,
|
running=True,
|
||||||
enabled=True,
|
enabled=True,
|
||||||
restarted=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:
|
def _configure_opendkim(domain: str, dkim_selector: str = "dkim") -> bool:
|
||||||
"""Configures OpenDKIM"""
|
"""Configures OpenDKIM"""
|
||||||
need_restart = False
|
need_restart = False
|
||||||
@@ -387,13 +391,11 @@ def _configure_dovecot(config: Config, debug: bool = False) -> bool:
|
|||||||
)
|
)
|
||||||
need_restart |= lua_push_notification_script.changed
|
need_restart |= lua_push_notification_script.changed
|
||||||
|
|
||||||
files.template(
|
# remove historic expunge script
|
||||||
src=importlib.resources.files(__package__).joinpath("dovecot/expunge.cron.j2"),
|
# which is now implemented through a systemd chatmail-expire service/timer
|
||||||
dest="/etc/cron.d/expunge",
|
files.file(
|
||||||
user="root",
|
path="/etc/cron.d/expunge",
|
||||||
group="root",
|
present=False,
|
||||||
mode="644",
|
|
||||||
config=config,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# as per https://doc.dovecot.org/configuration_manual/os/
|
# 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