mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-15 10:12:58 +00:00
* Make all Upstart jobs shut down on the `starting shutdown' event.
This ensures that they're gone by the time the shutdown job runs, so it doesn't have to stop them itself. * Don't respawn tasks, as it doesn't seem useful (if they fail they're likely to fail again if they're restarted). svn path=/nixos/trunk/; revision=22099
This commit is contained in:
parent
b135e38bea
commit
ad93acc295
@ -14,9 +14,9 @@ with pkgs.lib;
|
||||
script =
|
||||
''
|
||||
case "$RUNLEVEL" in
|
||||
0) initctl start shutdown MODE=poweroff;;
|
||||
1) initctl start shutdown MODE=maintenance;;
|
||||
6) initctl start shutdown MODE=reboot;;
|
||||
0) initctl start shutdown --no-wait MODE=poweroff;;
|
||||
1) initctl start shutdown --no-wait MODE=maintenance;;
|
||||
6) initctl start shutdown --no-wait MODE=reboot;;
|
||||
*) echo "Unsupported runlevel: $RUNLEVEL";;
|
||||
esac
|
||||
'';
|
||||
|
@ -9,8 +9,12 @@ with pkgs.lib;
|
||||
|
||||
task = true;
|
||||
|
||||
stopOn = ""; # must override the default ("starting shutdown")
|
||||
|
||||
environment = { MODE = "poweroff"; };
|
||||
|
||||
extraConfig = "console owner";
|
||||
|
||||
script =
|
||||
''
|
||||
set +e # continue in case of errors
|
||||
@ -29,24 +33,10 @@ with pkgs.lib;
|
||||
export PATH=${pkgs.utillinux}/bin:${pkgs.utillinux}/sbin:$PATH
|
||||
|
||||
|
||||
# Set the hardware clock to the system time.
|
||||
echo "setting the hardware clock..."
|
||||
hwclock --systohc --utc
|
||||
|
||||
|
||||
# Do an initial sync just in case.
|
||||
sync
|
||||
|
||||
|
||||
# Stop all Upstart jobs.
|
||||
initctl list | while IFS=", " read jobName status rest; do
|
||||
if test "$jobName" != shutdown -a "$status" != "stop/waiting"; then
|
||||
echo "stopping $jobName..."
|
||||
stop "$jobName"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Kill all remaining processes except init and this one.
|
||||
echo "sending the TERM signal to all processes..."
|
||||
kill -TERM -1
|
||||
@ -64,12 +54,17 @@ with pkgs.lib;
|
||||
echo ""
|
||||
echo "[1;32m<<< Maintenance shell >>>[0m"
|
||||
echo ""
|
||||
while ! ${pkgs.bash}/bin/bash --login; do true; done
|
||||
${pkgs.pam_login}/bin/login root
|
||||
initctl emit -n startup
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# Set the hardware clock to the system time.
|
||||
echo "setting the hardware clock..."
|
||||
hwclock --systohc --utc
|
||||
|
||||
|
||||
# Unmount helper functions.
|
||||
getMountPoints() {
|
||||
cat /proc/mounts \
|
||||
|
@ -75,7 +75,7 @@ let
|
||||
''}
|
||||
|
||||
${optionalString job.task "task"}
|
||||
${optionalString job.respawn "respawn"}
|
||||
${optionalString (!job.task && job.respawn) "respawn"}
|
||||
|
||||
${optionalString (job.preStop != "") ''
|
||||
pre-stop script
|
||||
@ -153,7 +153,7 @@ let
|
||||
|
||||
stopOn = mkOption {
|
||||
type = types.string;
|
||||
default = "shutdown";
|
||||
default = "starting shutdown";
|
||||
description = ''
|
||||
The Upstart event that triggers this job to be stopped.
|
||||
'';
|
||||
|
Loading…
Reference in New Issue
Block a user