diff --git a/containers/dovecot.nix b/containers/dovecot.nix index 6ad5980..bdae9fa 100644 --- a/containers/dovecot.nix +++ b/containers/dovecot.nix @@ -30,16 +30,7 @@ nglib.makeSystem { }; plugin."" = { - sieve = pkgs.writeText "filter.sieve" '' - require "variables"; - require "fileinto"; - - if header :matches "X-MAILBOX" "*" { - set "DESIRED_MAILBOX" "''${0}"; - } - - fileinto "''${DESIRED_MAILBOX}"; - ''; + sieve = "/mail-configuration/entry.sieve"; }; mail_plugin_dir = pkgs.symlinkJoin { diff --git a/containers/getmail/default.nix b/containers/getmail/default.nix index 3eee631..92a4e99 100644 --- a/containers/getmail/default.nix +++ b/containers/getmail/default.nix @@ -68,11 +68,10 @@ nglib.makeSystem { set -m - for rcfile in /getmail.d/getmail.*.rc + for rcfile in /mail-configuration/getmail.d/*.rc do - foo="$(basename "''${rcfile}")" - bar="''${foo#"getmail."}" - email="''${bar%".rc"}" + filename="$(basename "''${rcfile}")" + email="''${filename%".rc"}" mkdir -p "/getmail.d/''${email}" chown vmail:vmail -R "/getmail.d/''${email}" @@ -80,7 +79,7 @@ nglib.makeSystem { ( while true do - chpst -u vmail:vmail getmail -i INBOX -n -r "/getmail.d/getmail.''${email}.rc" --getmaildir "/getmail.d/''${email}" + chpst -u vmail:vmail getmail -i INBOX -n -r "$rcfile" --getmaildir "/mail-configuration/getmail.d/''${email}" sleep 10 done ) & diff --git a/nomad/regions/homelab-1/email.tf b/nomad/regions/homelab-1/email.tf index 38befdb..6a71bef 100644 --- a/nomad/regions/homelab-1/email.tf +++ b/nomad/regions/homelab-1/email.tf @@ -41,12 +41,12 @@ resource "nomad_volume" "dovecot_maildir" { } } -resource "nomad_volume" "getmail_getmail-d" { +resource "nomad_volume" "mail-configuration" { type = "csi" plugin_id = "org.democratic-csi.nfs" - volume_id = "getmail_getmail-d" - name = "getmail_getmail-d" - external_id = "getmail_getmail-d" + volume_id = "mail-configuration" + name = "mail-configuration" + external_id = "mail-configuration" capability { access_mode = "single-node-writer" @@ -55,7 +55,7 @@ resource "nomad_volume" "getmail_getmail-d" { context = { server = "blowhole.hosts.in.redalder.org" - share = "/var/nfs/getmail/getmail.d" + share = "/var/nfs/mail-configuration" node_attach_driver = "nfs" provisioner_driver = "node-manual" } diff --git a/nomad/regions/homelab-1/job/email.hcl b/nomad/regions/homelab-1/job/email.hcl index 6399ba7..026181f 100644 --- a/nomad/regions/homelab-1/job/email.hcl +++ b/nomad/regions/homelab-1/job/email.hcl @@ -18,24 +18,15 @@ job "email" { group "getmail" { count = 1 - volume "dovecot_maildir" { + volume "mail-configuration" { type = "csi" - source = "dovecot_maildir" + source = "mail-configuration" read_only = false attachment_mode = "file-system" access_mode = "multi-node-multi-writer" } - volume "getmail_getmail-d" { - type = "csi" - source = "getmail_getmail-d" - read_only = false - - attachment_mode = "file-system" - access_mode = "single-node-writer" - } - restart { attempts = 5 delay = "5s" @@ -66,14 +57,8 @@ job "email" { driver = "docker" volume_mount { - volume = "dovecot_maildir" - destination = "/maildir" - read_only = false - } - - volume_mount { - volume = "getmail_getmail-d" - destination = "/getmail.d" + volume = "mail-configuration" + destination = "/mail-configuration" read_only = false } @@ -105,6 +90,15 @@ job "email" { access_mode = "multi-node-multi-writer" } + volume "mail-configuration" { + type = "csi" + source = "mail-configuration" + read_only = false + + attachment_mode = "file-system" + access_mode = "multi-node-multi-writer" + } + restart { attempts = 5 delay = "5s" @@ -141,6 +135,12 @@ job "email" { read_only = false } + volume_mount { + volume = "mail-configuration" + destination = "/mail-configuration" + read_only = false + } + config { nix_flake_ref = "${var.flake_ref}#nixngSystems.dovecot.config.system.build.toplevel" nix_flake_sha = var.flake_sha