From 50d942960e2525bdee04f3f146c5f40503517ca5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 22 Sep 2013 16:44:41 +0200 Subject: [PATCH] Write a reboot record to /var/log/wtmp --- modules/system/boot/systemd.nix | 9 +++++++++ tests/misc.nix | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix index 5ad8cdbcb18b..c1ca0ca4ca78 100644 --- a/modules/system/boot/systemd.nix +++ b/modules/system/boot/systemd.nix @@ -608,5 +608,14 @@ in users.extraGroups.systemd-journal.gid = config.ids.gids.systemd-journal; + # FIXME: This should no longer be needed with systemd >= 204. + systemd.services."systemd-update-utmp-reboot.service" = + { description = "Update UTMP about System Reboot"; + wantedBy = [ "sysinit.target" ]; + unitConfig.DefaultDependencies = false; + serviceConfig.Type = "oneshot"; + serviceConfig.ExecStart = "${systemd}/lib/systemd/systemd-update-utmp reboot"; + }; + }; } diff --git a/tests/misc.nix b/tests/misc.nix index 41bd2a8686db..47775ce2a1ed 100644 --- a/tests/misc.nix +++ b/tests/misc.nix @@ -47,6 +47,11 @@ subtest "blkio-cgroup", sub { $machine->succeed("[ -n \"\$(cat /sys/fs/cgroup/blkio/blkio.sectors)\" ]") }; + + # Test whether we have a reboot record in wtmp. + subtest "reboot-wtmp", sub { + $machine->succeed("last | grep reboot >&2"); + }; ''; }