fix unit-status after actual test

This commit is contained in:
Motiejus Jakštys 2023-02-25 17:20:01 +02:00
parent 065172836c
commit 6e9cdf04ba

View File

@ -406,11 +406,8 @@ in {
};
# https://northernlightlabs.se/2014-07-05/systemd-status-mail-on-unit-failure.html
"unit-status-mail@" = {
description = "Send an email on unit failure";
serviceConfig = {
Type = "simple";
ExecStart = pkgs.writeShellScript "unit-status-mail" ''
"unit-status-mail@" = let
script = pkgs.writeShellScript "unit-status-mail" ''
MAILTO="motiejus+alerts@jakstys.lt"
UNIT=$1
EXTRA=""
@ -429,12 +426,17 @@ in {
echo -e "Status mail sent to: $MAILTO for unit: $UNIT"
'';
in {
description = "Send an email on unit failure";
serviceConfig = {
Type = "simple";
ExecStart = ''${script} "%I" "Hostname: %H" "Machine ID: %m" "Boot ID: %b" '';
};
};
} // lib.mapAttrs' (name: value: {
name = "borgbackup-job-${name}";
value = {
serviceConfig.OnFailure = "unit-status-mail@${name}.service";
unitConfig.OnFailure = "unit-status-mail@borgbackup-job-${name}.service";
};
}) backup_paths;