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,
|
config,
|
||||||
options,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
|
@ -27,7 +26,11 @@ with (import ./common.nix { inherit config pkgs lib; });
|
||||||
let
|
let
|
||||||
cfg = config.mailserver;
|
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";
|
passwdDir = "/run/dovecot2";
|
||||||
passwdFile = "${passwdDir}/passwd";
|
passwdFile = "${passwdDir}/passwd";
|
||||||
|
@ -442,11 +445,10 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.${dovecotUnitName}.preStart =
|
systemd.services.dovecot.preStart = lib.mkIf (config.systemd.services ? "dovecot") dovecotPreStart;
|
||||||
''
|
systemd.services.dovecot2.preStart = lib.mkIf (
|
||||||
${genPasswdScript}
|
config.systemd.services ? "dovecot2"
|
||||||
''
|
) dovecotPreStart;
|
||||||
+ (lib.optionalString cfg.ldap.enable setPwdInLdapConfFile);
|
|
||||||
|
|
||||||
systemd.services.postfix.restartTriggers = [
|
systemd.services.postfix.restartTriggers = [
|
||||||
genPasswdScript
|
genPasswdScript
|
||||||
|
|
|
@ -30,6 +30,26 @@ let
|
||||||
[ "mailserver-selfsigned-certificate.service" ]
|
[ "mailserver-selfsigned-certificate.service" ]
|
||||||
else
|
else
|
||||||
[ "acme-finished-${cfg.fqdn}.target" ];
|
[ "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
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
@ -60,25 +80,9 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
# Create maildir folder before dovecot startup
|
# Create maildir folder before dovecot startup
|
||||||
systemd.services.dovecot2 = {
|
systemd.services.dovecot = dovecotUnitSettings;
|
||||||
wants = certificatesDeps;
|
# TODO: remove after 25.11 release
|
||||||
after = certificatesDeps;
|
systemd.services.dovecot2 = dovecotUnitSettings;
|
||||||
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}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# Postfix requires dovecot lmtp socket, dovecot auth socket and certificate to work
|
# Postfix requires dovecot lmtp socket, dovecot auth socket and certificate to work
|
||||||
systemd.services.postfix = {
|
systemd.services.postfix = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue