diff options
| author | Joe Mou <dev@mou.fo> | 2024-04-26 23:51:10 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2024-04-26 23:54:59 -0400 |
| commit | 07a7baeb6bf21ce2018fc558fb849ba17669fb89 (patch) | |
| tree | 0c45464e5ddada029cfc980705773e28e9cc8133 /hostnix/elmo/system.nix | |
| parent | cb908f1341fdbfffb45c40b9f83ee540312b076e (diff) | |
elmo: E-mail on certain systemd failures
Diffstat (limited to 'hostnix/elmo/system.nix')
| -rw-r--r-- | hostnix/elmo/system.nix | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/hostnix/elmo/system.nix b/hostnix/elmo/system.nix index 4f6ddb7..407ca42 100644 --- a/hostnix/elmo/system.nix +++ b/hostnix/elmo/system.nix @@ -34,11 +34,30 @@ # https://nixos.wiki/wiki/Hardware/Apple#Auto_Restart systemd.services.enable-autorestart = { description = "Boot after power failure (server mode)"; - wantedBy = [ "default.target" ]; + wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "oneshot"; }; # https://superuser.com/a/1051137 script = "${pkgs.pciutils}/bin/setpci -s 00:1f.0 0xa4.b=0"; }; + + # https://wiki.archlinux.org/index.php/Systemd/Timers#MAILTO + systemd.services."status-email@" = { + description = "Status email for %i"; + serviceConfig = { + Type = "oneshot"; + }; + scriptArgs = "%i"; + script = '' + ${pkgs.mailutils}/bin/mail -s "$1 status" root <<EOF + From: systemd <root> + Subject: $1 status + Content-Transfer-Encoding: 8bit + Content-Type: text/plain; charset=UTF-8 + + $(systemctl status --full "$1") + EOF + ''; + }; } |
