diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-07-30 18:22:55 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-07-30 18:22:55 +0200 |
commit | 999c3b78be5d427234dfeaa26136e2882ed690e1 (patch) | |
tree | b2e613c4d1459f53f6f42fbeea953f1995d41d96 /ymir.nix | |
parent | a95db4f237f8a774733472ed9fc905b0e8133d06 (diff) | |
download | nixos-999c3b78be5d427234dfeaa26136e2882ed690e1.tar nixos-999c3b78be5d427234dfeaa26136e2882ed690e1.tar.gz nixos-999c3b78be5d427234dfeaa26136e2882ed690e1.tar.bz2 nixos-999c3b78be5d427234dfeaa26136e2882ed690e1.tar.xz nixos-999c3b78be5d427234dfeaa26136e2882ed690e1.zip |
Send mail when nixos-upgrade failed
Diffstat (limited to 'ymir.nix')
-rw-r--r-- | ymir.nix | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -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 | } |