summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2017-07-30 18:22:55 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2017-07-30 18:22:55 +0200
commit999c3b78be5d427234dfeaa26136e2882ed690e1 (patch)
treeb2e613c4d1459f53f6f42fbeea953f1995d41d96
parenta95db4f237f8a774733472ed9fc905b0e8133d06 (diff)
downloadnixos-999c3b78be5d427234dfeaa26136e2882ed690e1.tar
nixos-999c3b78be5d427234dfeaa26136e2882ed690e1.tar.gz
nixos-999c3b78be5d427234dfeaa26136e2882ed690e1.tar.bz2
nixos-999c3b78be5d427234dfeaa26136e2882ed690e1.tar.xz
nixos-999c3b78be5d427234dfeaa26136e2882ed690e1.zip
Send mail when nixos-upgrade failed
-rw-r--r--ymir.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/ymir.nix b/ymir.nix
index 3c0db516..9a9dc7d8 100644
--- a/ymir.nix
+++ b/ymir.nix
@@ -898,4 +898,33 @@ in rec {
898 git -C /etc/nixos pull 898 git -C /etc/nixos pull
899 git -C /etc/nixos submodule update 899 git -C /etc/nixos submodule update
900 ''; 900 '';
901 systemd.services."nixos-upgrade".onFailure = "unit-status-mail@%n.service";
902
903 systemd.services."unit-status-mail@" = {
904 scriptArgs = "%I %H %m %b";
905 script = ''
906 #!${stdenv.shell}
907 MAILTO="root"
908 MAILFROM="unit-status-mailer"
909 UNIT=$1
910
911 EXTRA=""
912 for e in "${@:2}"; do
913 EXTRA+="$e"$'\n'
914 done
915
916 UNITSTATUS=$(systemctl status $UNIT)
917
918 sendmail $MAILTO <<EOF
919 From:$MAILFROM
920 To:$MAILTO
921 Subject:Status mail for unit: $UNIT
922
923 Status report for unit: $UNIT
924 $EXTRA
925
926 $UNITSTATUS
927 EOF
928 '';
929 };
901} 930}