mirror of
https://github.com/chatmail/relay.git
synced 2026-05-20 12:58:04 +00:00
wip expunge timer
This commit is contained in:
@@ -371,6 +371,23 @@ def _configure_dovecot(config: Config, debug: bool = False) -> bool:
|
|||||||
commands=["/usr/bin/sievec /etc/dovecot/default.sieve"],
|
commands=["/usr/bin/sievec /etc/dovecot/default.sieve"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
files.template(
|
||||||
|
src=importlib.resources.files(__package__).joinpath("service/expunge.service.j2"),
|
||||||
|
dest="/etc/systemd/system/expunge.service",
|
||||||
|
config={
|
||||||
|
"mail_domain": config.mail_domain,
|
||||||
|
"delete_mails_after": config.delete_mails_after,
|
||||||
|
},
|
||||||
|
**root_owned,
|
||||||
|
)
|
||||||
|
|
||||||
|
files.put(
|
||||||
|
name="Upload expunge.timer",
|
||||||
|
src=importlib.resources.files(__package__).joinpath("service/expunge.timer"),
|
||||||
|
dest=f"/etc/systemd/system/metrics.timer",
|
||||||
|
**root_owned,
|
||||||
|
)
|
||||||
|
|
||||||
files.template(
|
files.template(
|
||||||
src=importlib.resources.files(__package__).joinpath("dovecot/expunge.cron.j2"),
|
src=importlib.resources.files(__package__).joinpath("dovecot/expunge.cron.j2"),
|
||||||
dest="/etc/cron.d/expunge",
|
dest="/etc/cron.d/expunge",
|
||||||
@@ -542,6 +559,7 @@ def deploy_chatmail(config_path: Path) -> None:
|
|||||||
"systemctl reset-failed unbound.service",
|
"systemctl reset-failed unbound.service",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
systemd.service(
|
systemd.service(
|
||||||
name="Start and enable unbound",
|
name="Start and enable unbound",
|
||||||
service="unbound.service",
|
service="unbound.service",
|
||||||
|
|||||||
15
cmdeploy/src/cmdeploy/service/expunge.service.j2
Normal file
15
cmdeploy/src/cmdeploy/service/expunge.service.j2
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Expunge old mails after {{ config.delete_mails_after }} days
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
# delete all mails after {{ config.delete_mails_after }} days, in the Inbox
|
||||||
|
ExecStart={{ config.execpath }} /home/vmail/mail/{{ config.mail_domain }} > /var/www/html/metrics
|
||||||
|
# or in any IMAP subfolder
|
||||||
|
ExecStart=vmail find /home/vmail/mail/{{ config.mail_domain }} -path '*/.*/cur/*' -mtime +{{ config.delete_mails_after }} -type f -delete
|
||||||
|
# even if they are unseen
|
||||||
|
ExecStart=vmail find /home/vmail/mail/{{ config.mail_domain }} -path '*/new/*' -mtime +{{ config.delete_mails_after }} -type f -delete
|
||||||
|
ExecStart=vmail find /home/vmail/mail/{{ config.mail_domain }} -path '*/new/*' -mtime +{{ config.delete_mails_after }} -type f -delete
|
||||||
|
# or only temporary (but then they shouldn't be around after {{ config.delete_mails_after }} days anyway).
|
||||||
|
ExecStart=vmail find /home/vmail/mail/{{ config.mail_domain }} -path '*/tmp/*' -mtime +{{ config.delete_mails_after }} -type f -delete
|
||||||
|
ExecStart=vmail find /home/vmail/mail/{{ config.mail_domain }} -path '*/.*/tmp/*' -mtime +{{ config.delete_mails_after }} -type f -delete
|
||||||
|
ExecStart=vmail find /home/vmail/mail/{{ config.mail_domain }} -name 'maildirsize' -type f -delete
|
||||||
9
cmdeploy/src/cmdeploy/service/expunge.timer
Normal file
9
cmdeploy/src/cmdeploy/service/expunge.timer
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Run expunge.service daily
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=weekly
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Generate metrics in /var/www/html/metrics every 5 minutes
|
Description=Generate metrics in /var/www/html/metrics
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart={{ config.execpath }} /home/vmail/mail/{{ config.mail_domain }} > /var/www/html/metrics
|
ExecStart={{ config.execpath }} /home/vmail/mail/{{ config.mail_domain }} > /var/www/html/metrics
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Generate metrics in /var/www/html/metrics every 5 minutes
|
Description=Run metrics.service every 5 minutes
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnBootSec=5min
|
OnBootSec=5min
|
||||||
|
|||||||
Reference in New Issue
Block a user