Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chatmaild/src/chatmaild/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, inipath, params):
self.privacy_mail = params.get("privacy_mail")
self.privacy_pdo = params.get("privacy_pdo")
self.privacy_supervisor = params.get("privacy_supervisor")
self.tmpfs_cache = params.get("tmpfs_cache", "false").lower() == "true"

# deprecated option
mbdir = params.get("mailboxes_dir", f"/home/vmail/mail/{self.mail_domain}")
Expand Down
2 changes: 2 additions & 0 deletions chatmaild/src/chatmaild/doveauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def lookup_passdb(self, addr, cleartext_password):

user.set_password(encrypt_password(cleartext_password))
print(f"Created address: {addr}", file=sys.stderr)
if self.config.tmpfs_cache:
os.symlink(f"{user.maildir}/dovecot.index.cache", f"/tmp{user.maildir}/")
return user.get_userdb_dict()


Expand Down
3 changes: 3 additions & 0 deletions chatmaild/src/chatmaild/ini/chatmail.ini.f
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
# (space-separated, item may start with "@" to whitelist whole recipient domains)
passthrough_recipients = echo@{mail_domain}

# store cache files in tmpfs (good for disk size, bad for ram)
tmpfs_cache = false

# path to www directory - documented here: https://github.com/chatmail/relay/#custom-web-pages
#www_folder = www

Expand Down
3 changes: 3 additions & 0 deletions chatmaild/src/chatmaild/ini/override-testrun.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[params]

tmpfs_cache = true

[privacy]

Expand Down
22 changes: 18 additions & 4 deletions cmdeploy/src/cmdeploy/deployers.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ class ChatmailDeployer(Deployer):
("iroh", None, None),
]

def __init__(self, mail_domain):
self.mail_domain = mail_domain
def __init__(self, config):
self.config = config

def install(self):
apt.update(name="apt update", cache_time=24 * 3600)
Expand All @@ -471,9 +471,23 @@ def configure(self):
server.shell(
name="Setup /etc/mailname",
commands=[
f"echo {self.mail_domain} >/etc/mailname; chmod 644 /etc/mailname"
f"echo {self.config.mail_domain} >/etc/mailname; chmod 644 /etc/mailname"
],
)
if config.tmpfs_cache:
files.put(
src=get_resource("service/tmp.mount"),
dest="/etc/systemd/system/tmp.mount",
)

def activate(self):
if config.tmpfs_cache:
systemd.service(
name="Start and enable tmpfs mount",
service="tmp.mount",
running=True,
enabled=True,
)


class FcgiwrapDeployer(Deployer):
Expand Down Expand Up @@ -556,7 +570,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
tls_domains = [mail_domain, f"mta-sts.{mail_domain}", f"www.{mail_domain}"]

all_deployers = [
ChatmailDeployer(mail_domain),
ChatmailDeployer(config),
LegacyRemoveDeployer(),
JournaldDeployer(),
UnboundDeployer(),
Expand Down
16 changes: 16 additions & 0 deletions cmdeploy/src/cmdeploy/service/tmp.mount
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Temporary Directory /tmp
Documentation=https://systemd.io/TEMPORARY_DIRECTORIES
Documentation=man:file-hierarchy(7)
Documentation=https://systemd.io/API_FILE_SYSTEMS
ConditionPathIsSymbolicLink=!/tmp
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target

[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime,nosuid,nodev,size=50%%,nr_inodes=1m,x-systemd.graceful-option=usrquota
Loading