From 0d5ca5cca128b80321023ce663515ab5b4e063c4 Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Sat, 27 Apr 2024 20:56:49 -0400 Subject: E-mail on reboot mailutils (but not sendmail) addresses from the unqualified hostname --- hostnix/elmo/system.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hostnix/elmo/system.nix b/hostnix/elmo/system.nix index 407ca42..23a6aa6 100644 --- a/hostnix/elmo/system.nix +++ b/hostnix/elmo/system.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ config, pkgs, ... }: { boot.loader.systemd-boot.enable = true; @@ -42,6 +42,17 @@ script = "${pkgs.pciutils}/bin/setpci -s 00:1f.0 0xa4.b=0"; }; + systemd.services.boot-email = { + description = "Boot email"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + }; + script = '' + echo -e "Subject: ${config.networking.fqdn} restarted\n\n$(date)" | /run/wrappers/bin/sendmail root + ''; + }; + # https://wiki.archlinux.org/index.php/Systemd/Timers#MAILTO systemd.services."status-email@" = { description = "Status email for %i"; @@ -50,7 +61,7 @@ }; scriptArgs = "%i"; script = '' - ${pkgs.mailutils}/bin/mail -s "$1 status" root < Subject: $1 status Content-Transfer-Encoding: 8bit -- cgit v1.3.1