From 43b5ced96c230a92cdeddbddd364e1c053dd5268 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 23 Mar 2012 13:37:22 +0000 Subject: [PATCH] * Ignore SIGHUP and write errors on stderr to ensure that switch-to-configuration runs to completion (e.g. if the tty we're on got killed). svn path=/nixos/trunk/; revision=33382 --- .../system/activation/switch-to-configuration.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/system/activation/switch-to-configuration.sh b/modules/system/activation/switch-to-configuration.sh index 781972882fdf..a7d25a6c80c2 100644 --- a/modules/system/activation/switch-to-configuration.sh +++ b/modules/system/activation/switch-to-configuration.sh @@ -76,6 +76,10 @@ EOF exit 1 fi +# Ignore SIGHUP so that we're not killed if we're running on (say) +# virtual console 1 and we restart the "tty1" job. +trap "" SIGHUP + jobsDir=$(readlink -f @out@/etc/init) # Stop all currently running jobs that are not in the new Upstart @@ -113,6 +117,10 @@ start_() { fi } +log() { + echo "$@" >&2 || true +} + # Restart all running jobs that have changed. (Here "running" means # all jobs that don't have a "stop" goal.) We use the symlinks in # /var/run/upstart-jobs (created by each job's pre-start script) to @@ -122,10 +130,10 @@ for job in @jobs@; do if ! [[ "$status" =~ start/ ]]; then continue; fi if [ "$(readlink -f "$jobsDir/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ]; then continue; fi if [ -n "${noRestartIfChanged[$job]}" ]; then - echo "not restarting changed service ‘$job’" + log "not restarting changed service ‘$job’" continue fi - echo "restarting changed service ‘$job’..." + log "restarting changed service ‘$job’..." # Note: can't use "restart" here, since that only restarts the # job's main process. stop --quiet "$job" || true @@ -147,11 +155,11 @@ for job in @jobs@; do "$(readlink -f "$jobsDir/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ]; then continue; fi if [ -n "${noRestartIfChanged[$job]}" ]; then continue; fi - echo "starting task ‘$job’..." + log "starting task ‘$job’..." start --quiet "$job" || true else if ! grep -q "^start on" "$jobsDir/$job.conf"; then continue; fi - echo "starting service ‘$job’..." + log "starting service ‘$job’..." start_ "$job" || true fi