summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2024-04-27 20:56:49 -0400
committerJoe Mou <dev@mou.fo>2024-04-27 20:56:49 -0400
commit0d5ca5cca128b80321023ce663515ab5b4e063c4 (patch)
tree525a494e68b87eda3901e95a7bb08bd889c483eb
parentf9c27964706773a7a30cb636b2b17ceab2446c53 (diff)
E-mail on reboot
mailutils (but not sendmail) addresses from the unqualified hostname
-rw-r--r--hostnix/elmo/system.nix15
1 files 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 <<EOF
+ /run/wrappers/bin/sendmail root <<EOF
From: systemd <root>
Subject: $1 status
Content-Transfer-Encoding: 8bit