From 49b2a218b54f4eefb7ac4ef50acc14d4ae2908ca Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 20 Nov 2006 20:50:52 +0000 Subject: [PATCH] * Support entering maintenance mode ("shutdown now") and powering off the system ("halt"). svn path=/nixu/trunk/; revision=7083 --- test/boot-environment.nix | 10 ++++++++++ test/upstart-jobs/halt.nix | 23 +++++++++++++++++++++++ test/upstart-jobs/maintenance-shell.nix | 19 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 test/upstart-jobs/halt.nix create mode 100644 test/upstart-jobs/maintenance-shell.nix diff --git a/test/boot-environment.nix b/test/boot-environment.nix index b70906b13f66..887e8feb978a 100644 --- a/test/boot-environment.nix +++ b/test/boot-environment.nix @@ -101,6 +101,16 @@ rec { (import ./upstart-jobs/dhclient.nix { dhcp = pkgs.dhcpWrapper; }) + + # Handles the maintenance/stalled event (single-user shell). + (import ./upstart-jobs/maintenance-shell.nix { + inherit (pkgs) bash; + }) + + # Handles the reboot/halt events. + (import ./upstart-jobs/halt.nix { + inherit (pkgs) bash; + }) ] # The terminals on ttyX. diff --git a/test/upstart-jobs/halt.nix b/test/upstart-jobs/halt.nix new file mode 100644 index 000000000000..f259ea77cc9d --- /dev/null +++ b/test/upstart-jobs/halt.nix @@ -0,0 +1,23 @@ +{bash}: + +{ + name = "sys-halt"; + + job = " +start on reboot +start on halt +start on system-halt +start on power-off + +script + exec < /dev/tty1 > /dev/tty1 2>&1 + echo \"\" + echo \"<<< SYSTEM SHUTDOWN >>>\" + echo \"\" + + # Right now all events above power off the system. + exec halt -f -p +end script + "; + +} diff --git a/test/upstart-jobs/maintenance-shell.nix b/test/upstart-jobs/maintenance-shell.nix new file mode 100644 index 000000000000..9e2acdaa0f5f --- /dev/null +++ b/test/upstart-jobs/maintenance-shell.nix @@ -0,0 +1,19 @@ +{bash}: + +{ + name = "maintenance-shell"; + + job = " +start on maintenance +start on stalled + +script + exec < /dev/tty1 > /dev/tty1 2>&1 + echo \"\" + echo \"<<< MAINTENANCE SHELL >>>\" + echo \"\" + exec ${bash}/bin/sh +end script + "; + +}