* 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 =
|
script =
|
||||||
''
|
''
|
||||||
case "$RUNLEVEL" in
|
case "$RUNLEVEL" in
|
||||||
0) initctl start shutdown MODE=poweroff;;
|
0) initctl start shutdown --no-wait MODE=poweroff;;
|
||||||
1) initctl start shutdown MODE=maintenance;;
|
1) initctl start shutdown --no-wait MODE=maintenance;;
|
||||||
6) initctl start shutdown MODE=reboot;;
|
6) initctl start shutdown --no-wait MODE=reboot;;
|
||||||
*) echo "Unsupported runlevel: $RUNLEVEL";;
|
*) echo "Unsupported runlevel: $RUNLEVEL";;
|
||||||
esac
|
esac
|
||||||
'';
|
'';
|
||||||
|
@ -9,8 +9,12 @@ with pkgs.lib;
|
|||||||
|
|
||||||
task = true;
|
task = true;
|
||||||
|
|
||||||
|
stopOn = ""; # must override the default ("starting shutdown")
|
||||||
|
|
||||||
environment = { MODE = "poweroff"; };
|
environment = { MODE = "poweroff"; };
|
||||||
|
|
||||||
|
extraConfig = "console owner";
|
||||||
|
|
||||||
script =
|
script =
|
||||||
''
|
''
|
||||||
set +e # continue in case of errors
|
set +e # continue in case of errors
|
||||||
@ -29,24 +33,10 @@ with pkgs.lib;
|
|||||||
export PATH=${pkgs.utillinux}/bin:${pkgs.utillinux}/sbin:$PATH
|
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.
|
# Do an initial sync just in case.
|
||||||
sync
|
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.
|
# Kill all remaining processes except init and this one.
|
||||||
echo "sending the TERM signal to all processes..."
|
echo "sending the TERM signal to all processes..."
|
||||||
kill -TERM -1
|
kill -TERM -1
|
||||||
@ -64,12 +54,17 @@ with pkgs.lib;
|
|||||||
echo ""
|
echo ""
|
||||||
echo "[1;32m<<< Maintenance shell >>>[0m"
|
echo "[1;32m<<< Maintenance shell >>>[0m"
|
||||||
echo ""
|
echo ""
|
||||||
while ! ${pkgs.bash}/bin/bash --login; do true; done
|
${pkgs.pam_login}/bin/login root
|
||||||
initctl emit -n startup
|
initctl emit -n startup
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Set the hardware clock to the system time.
|
||||||
|
echo "setting the hardware clock..."
|
||||||
|
hwclock --systohc --utc
|
||||||
|
|
||||||
|
|
||||||
# Unmount helper functions.
|
# Unmount helper functions.
|
||||||
getMountPoints() {
|
getMountPoints() {
|
||||||
cat /proc/mounts \
|
cat /proc/mounts \
|
||||||
|
@ -75,7 +75,7 @@ let
|
|||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString job.task "task"}
|
${optionalString job.task "task"}
|
||||||
${optionalString job.respawn "respawn"}
|
${optionalString (!job.task && job.respawn) "respawn"}
|
||||||
|
|
||||||
${optionalString (job.preStop != "") ''
|
${optionalString (job.preStop != "") ''
|
||||||
pre-stop script
|
pre-stop script
|
||||||
@ -153,7 +153,7 @@ let
|
|||||||
|
|
||||||
stopOn = mkOption {
|
stopOn = mkOption {
|
||||||
type = types.string;
|
type = types.string;
|
||||||
default = "shutdown";
|
default = "starting shutdown";
|
||||||
description = ''
|
description = ''
|
||||||
The Upstart event that triggers this job to be stopped.
|
The Upstart event that triggers this job to be stopped.
|
||||||
'';
|
'';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user