add deploy configs

This commit is contained in:
Balakrishnan Balasubramanian 2023-06-20 21:45:14 -04:00
parent f407c8b395
commit 32d5d3d557
4 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,3 @@
# See sysusers.d(5) for details.
u mail4one - "Personal Mail server"

View File

@ -0,0 +1,22 @@
# mail4one.service
[Unit]
Description=Personal Mail server
Documentation=https://gitea.balki.me/balki/mail4one
After=network.target network-online.target
Requires=network-online.target
[Service]
User=mail4one
ExecStart=/usr/local/bin/mail4one --config /etc/mail4one/config.json
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
StateDirectory=mail4one
LogsDirectory=mail4one
WorkingDirectory=/var/lib/mail4one
ProtectHome=yes
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,18 @@
#!/bin/sh
# certbot deploy hook to copy certificates to mail4one when renewed.
# This file is supposed to be copied to /etc/letsencrypt/renewal-hooks/deploy/
# Change the mail domain to the one on MX record
set -x
if [ "$RENEWED_DOMAINS" = "mail.mydomain.com" ]
then
mkdir -p /var/lib/mail4one/certs
chmod 500 /var/lib/mail4one/certs
chown mail4one:mail4one /var/lib/mail4one/certs
cp "$RENEWED_LINEAGE/fullchain.pem" /var/lib/mail4one/certs/
cp "$RENEWED_LINEAGE/privkey.pem" /var/lib/mail4one/certs/
systemctl restart mail4one.service
fi

View File

@ -41,7 +41,7 @@ class MyHandler(AsyncMessage):
async def handle_message(self, m: Message): # type: ignore[override]
all_mboxes: set[str] = set()
for addr in self.rcpt_tos:
for mbox in self.mbox_finder(addr):
for mbox in self.mbox_finder(addr.lower()):
all_mboxes.add(mbox)
if not all_mboxes:
logger.warning(f"dropping message from: {self.peer}")