From 3eac0038003818a5a91a82da9039a5119ae292fa Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 8 Jun 2010 12:48:16 +0000 Subject: [PATCH] * Maintain /var/log/wtmp correctly during boot/shutdown. svn path=/nixos/branches/boot-order/; revision=22182 --- modules/system/boot/stage-2-init.sh | 2 ++ modules/system/upstart-events/runlevel.nix | 9 +++++++++ modules/system/upstart-events/shutdown.nix | 8 ++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/system/boot/stage-2-init.sh b/modules/system/boot/stage-2-init.sh index de9b136d02a..69c67de6e3a 100644 --- a/modules/system/boot/stage-2-init.sh +++ b/modules/system/boot/stage-2-init.sh @@ -134,9 +134,11 @@ export MODULE_DIR=@kernel@/lib/modules/ # Run any user-specified commands. @shell@ @postBootCommands@ + # For debugging Upstart. #@shell@ --login < /dev/console > /dev/console 2>&1 & + # Start Upstart's init. echo "starting Upstart..." PATH=/var/run/current-system/upstart/sbin exec init diff --git a/modules/system/upstart-events/runlevel.nix b/modules/system/upstart-events/runlevel.nix index 96864594509..10d108d9f40 100644 --- a/modules/system/upstart-events/runlevel.nix +++ b/modules/system/upstart-events/runlevel.nix @@ -4,6 +4,15 @@ with pkgs.lib; { + # After booting, go to runlevel 2. (NixOS doesn't really use + # runlevels, but this keeps wtmp happy.) + jobs.boot = + { name = "boot"; + startOn = "startup"; + task = true; + script = "telinit 2"; + }; + jobs.runlevel = { name = "runlevel"; diff --git a/modules/system/upstart-events/shutdown.nix b/modules/system/upstart-events/shutdown.nix index 283782fb4d1..2aad17cd1ac 100644 --- a/modules/system/upstart-events/shutdown.nix +++ b/modules/system/upstart-events/shutdown.nix @@ -58,8 +58,12 @@ with pkgs.lib; initctl emit -n startup exit 0 fi - - + + + # Write a shutdown record to wtmp while /var/log is still writable. + reboot --wtmp-only + + # Set the hardware clock to the system time. echo "setting the hardware clock..." hwclock --systohc --utc