mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-22 13:08:39 +03:00
nixos/spamassassin: Handle return codes correctly
For sa-update we care about two successful codes: * 1 -> no updates available: exit successfully * 0 -> updates have been installed: run sa-compile and pass through its return code
This commit is contained in:
parent
c86b339491
commit
8854b82511
@ -136,19 +136,26 @@ in
|
|||||||
Group = "spamd";
|
Group = "spamd";
|
||||||
StateDirectory = "spamassassin";
|
StateDirectory = "spamassassin";
|
||||||
ExecStartPost = "+${pkgs.systemd}/bin/systemctl -q --no-block try-reload-or-restart spamd.service";
|
ExecStartPost = "+${pkgs.systemd}/bin/systemctl -q --no-block try-reload-or-restart spamd.service";
|
||||||
SuccessExitStatus = "1";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
set +e
|
set +e
|
||||||
${pkgs.spamassassin}/bin/sa-update --verbose --gpghomedir=%S/spamassassin/sa-update-keys/
|
${pkgs.spamassassin}/bin/sa-update --verbose --gpghomedir=/var/lib/spamassassin/sa-update-keys/
|
||||||
rc=$?
|
rc=$?
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [[ $rc -eq 0 ]]; then
|
if [[ $rc -gt 1 ]]; then
|
||||||
# An update was available and installed.
|
# sa-update failed.
|
||||||
${pkgs.spamassassin}/bin/sa-compile
|
exit $rc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $rc -eq 1 ]]; then
|
||||||
|
# No update was available, exit successfully.
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# An update was available and installed. Compile the rules.
|
||||||
|
${pkgs.spamassassin}/bin/sa-compile
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user