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 # https://northernlightlabs.se/2014-07-05/systemd-status-mail-on-unit-failure.html
"unit-status-mail@" = { "unit-status-mail@" = let
description = "Send an email on unit failure"; script = pkgs.writeShellScript "unit-status-mail" ''
serviceConfig = {
Type = "simple";
ExecStart = pkgs.writeShellScript "unit-status-mail" ''
MAILTO="motiejus+alerts@jakstys.lt" MAILTO="motiejus+alerts@jakstys.lt"
UNIT=$1 UNIT=$1
EXTRA="" EXTRA=""
@ -429,12 +426,17 @@ in {
echo -e "Status mail sent to: $MAILTO for unit: $UNIT" 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: { } // lib.mapAttrs' (name: value: {
name = "borgbackup-job-${name}"; name = "borgbackup-job-${name}";
value = { value = {
serviceConfig.OnFailure = "unit-status-mail@${name}.service"; unitConfig.OnFailure = "unit-status-mail@borgbackup-job-${name}.service";
}; };
}) backup_paths; }) backup_paths;