Skip to content

Commit

Permalink
nixos/spamassassin: Only run sa-compile when updates have been installed
Browse files Browse the repository at this point in the history
  • Loading branch information
pkern committed Feb 11, 2021
1 parent cc625c9 commit c86b339
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions nixos/modules/services/mail/spamassassin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,21 @@ in
User = "spamd";
Group = "spamd";
StateDirectory = "spamassassin";
ExecStart = [
"${pkgs.spamassassin}/bin/sa-update --verbose --gpghomedir=%S/spamassassin/sa-update-keys/"
"${pkgs.spamassassin}/bin/sa-compile"
];
ExecStartPost = "+${pkgs.systemd}/bin/systemctl -q --no-block try-reload-or-restart spamd.service";
SuccessExitStatus = "1";
};

script = ''
set +e
${pkgs.spamassassin}/bin/sa-update --verbose --gpghomedir=%S/spamassassin/sa-update-keys/
rc=$?
set -e
if [[ $rc -eq 0 ]]; then
# An update was available and installed.
${pkgs.spamassassin}/bin/sa-compile
fi
'';
};

systemd.timers.sa-update = {
Expand Down

0 comments on commit c86b339

Please sign in to comment.