From 0293edb691c5369b0cc772ec6690cf53164c91d8 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 30 Jul 2017 19:38:50 +0200 Subject: =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom/unit-status-mail.nix | 60 ++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'custom') diff --git a/custom/unit-status-mail.nix b/custom/unit-status-mail.nix index 58136724..1b87a0b0 100644 --- a/custom/unit-status-mail.nix +++ b/custom/unit-status-mail.nix @@ -5,7 +5,7 @@ with lib; let cfg = config.systemd.status-mail; - serviceCfg = traceValSeq (foldl singleServiceCfg {} cfg.onFailure); + serviceCfg = foldl singleServiceCfg {} cfg.onFailure; singleServiceCfg = attrs: unitName: attrs // (setAttrByPath [unitName "onFailure"] ["unit-status-mail@%n.service"]); in { options = { @@ -29,37 +29,37 @@ in { }; config = mkIf (cfg.onFailure != []) { - systemd.services = config.systemd.services // serviceCfg; + systemd.services = { + "unit-status-mail@" = { + serviceConfig = { + Type = "oneshot"; + }; + scriptArgs = "%I \"Hostname: %H\" \"Machine-ID: %m\" \"Boot-ID: %b\""; + script = '' + #!${pkgs.stdenv.shell} + MAILTO="${cfg.recipient}" + MAILFROM="unit-status-mailer" + UNIT=$1 - systemd.services."unit-status-mail@" = { - serviceConfig = { - Type = "oneshot"; - }; - scriptArgs = "%I \"Hostname: %H\" \"Machine-ID: %m\" \"Boot-ID: %b\""; - script = '' - #!${pkgs.stdenv.shell} - MAILTO="${cfg.recipient}" - MAILFROM="unit-status-mailer" - UNIT=$1 - - EXTRA="" - for e in "''${@:2}"; do - EXTRA+="$e"$'\n' - done - - UNITSTATUS=$(systemctl status $UNIT) - - ${config.security.wrapperDir}/sendmail $MAILTO <