Merge branch 'dovecot-migration-compat-fixup' into 'master'
dovecot: fix check for dovecot systemd unit name See merge request simple-nixos-mailserver/nixos-mailserver!425
This commit is contained in:
commit
6004878dc6
2 changed files with 32 additions and 26 deletions
|
@ -16,7 +16,6 @@
|
|||
|
||||
{
|
||||
config,
|
||||
options,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
|
@ -27,7 +26,11 @@ with (import ./common.nix { inherit config pkgs lib; });
|
|||
let
|
||||
cfg = config.mailserver;
|
||||
|
||||
dovecotUnitName = if lib.hasAttr "dovecot" options.systemd.services then "dovecot" else "dovecot2";
|
||||
dovecotPreStart =
|
||||
''
|
||||
${genPasswdScript}
|
||||
''
|
||||
+ (lib.optionalString cfg.ldap.enable setPwdInLdapConfFile);
|
||||
|
||||
passwdDir = "/run/dovecot2";
|
||||
passwdFile = "${passwdDir}/passwd";
|
||||
|
@ -442,11 +445,10 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
systemd.services.${dovecotUnitName}.preStart =
|
||||
''
|
||||
${genPasswdScript}
|
||||
''
|
||||
+ (lib.optionalString cfg.ldap.enable setPwdInLdapConfFile);
|
||||
systemd.services.dovecot.preStart = lib.mkIf (config.systemd.services ? "dovecot") dovecotPreStart;
|
||||
systemd.services.dovecot2.preStart = lib.mkIf (
|
||||
config.systemd.services ? "dovecot2"
|
||||
) dovecotPreStart;
|
||||
|
||||
systemd.services.postfix.restartTriggers = [
|
||||
genPasswdScript
|
||||
|
|
|
@ -30,6 +30,26 @@ let
|
|||
[ "mailserver-selfsigned-certificate.service" ]
|
||||
else
|
||||
[ "acme-finished-${cfg.fqdn}.target" ];
|
||||
|
||||
dovecotUnitSettings = {
|
||||
wants = certificatesDeps;
|
||||
after = certificatesDeps;
|
||||
preStart =
|
||||
let
|
||||
directories = lib.strings.escapeShellArgs (
|
||||
[ cfg.mailDirectory ] ++ lib.optional (cfg.indexDir != null) cfg.indexDir
|
||||
);
|
||||
in
|
||||
''
|
||||
# Create mail directory and set permissions. See
|
||||
# <https://doc.dovecot.org/main/core/config/shared_mailboxes.html#filesystem-permissions-1>.
|
||||
# Prevent world-readable paths, even temporarily.
|
||||
umask 007
|
||||
mkdir -p ${directories}
|
||||
chgrp "${cfg.vmailGroupName}" ${directories}
|
||||
chmod 02770 ${directories}
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
@ -60,25 +80,9 @@ in
|
|||
};
|
||||
|
||||
# Create maildir folder before dovecot startup
|
||||
systemd.services.dovecot2 = {
|
||||
wants = certificatesDeps;
|
||||
after = certificatesDeps;
|
||||
preStart =
|
||||
let
|
||||
directories = lib.strings.escapeShellArgs (
|
||||
[ cfg.mailDirectory ] ++ lib.optional (cfg.indexDir != null) cfg.indexDir
|
||||
);
|
||||
in
|
||||
''
|
||||
# Create mail directory and set permissions. See
|
||||
# <https://doc.dovecot.org/main/core/config/shared_mailboxes.html#filesystem-permissions-1>.
|
||||
# Prevent world-readable paths, even temporarily.
|
||||
umask 007
|
||||
mkdir -p ${directories}
|
||||
chgrp "${cfg.vmailGroupName}" ${directories}
|
||||
chmod 02770 ${directories}
|
||||
'';
|
||||
};
|
||||
systemd.services.dovecot = dovecotUnitSettings;
|
||||
# TODO: remove after 25.11 release
|
||||
systemd.services.dovecot2 = dovecotUnitSettings;
|
||||
|
||||
# Postfix requires dovecot lmtp socket, dovecot auth socket and certificate to work
|
||||
systemd.services.postfix = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue