/etc/event.d/rcS does not set RUNLEVEL properly

Bug #76304 reported by Luis Mondesi
6
Affects Status Importance Assigned to Milestone
upstart (Ubuntu)
Fix Released
Low
Scott James Remnant (Canonical)

Bug Description

Binary package hint: upstart-compat-sysv

Steps to reproduce:

1. put a script in /etc/init.d/foo and symlink it to /etc/rcS.d/S99foo
2. in said script, execute runlevel > /tmp/foo.log

To fix this bug all you need is:

--- /etc/event.d/rcS 2006-09-13 18:47:27.000000000 -0400
+++ rcS 2006-12-18 13:12:42.000000000 -0500
@@ -14,6 +14,12 @@
 # information (we enter rc1 not rcS for maintenance). Run /etc/init.d/rc
 # without information so that it defaults to previous=N runlevel=S.
 script
- runlevel --set S >/dev/null || true
+ set $(runlevel --set S || true)
+ if [ "$1" != "unknown" ]; then
+ PREVLEVEL=$1
+ RUNLEVEL=$2
+ export PREVLEVEL RUNLEVEL
+ fi
+
        exec /etc/init.d/rcS
 end script

Revision history for this message
Luis Mondesi (lemsx1) wrote :
Changed in upstart:
importance: Undecided → Low
status: Unconfirmed → Confirmed
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

It can't set it this way since /var/run isn't mounted at this point, so we're pretty likely to have a bogus "previous" runlevel in there.

Changed in upstart:
status: Confirmed → In Progress
assignee: nobody → keybuk
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

This was fixed by force-setting RUNLEVEL=S and PREVLEVEL=N in rcS

Changed in upstart:
status: In Progress → Fix Released
Revision history for this message
islet8 (islet8) wrote :

I've done the modification, but it still does not work on my ubuntu.
my /etc/event.d/rcS is as follows:

# rcS - runlevel compatibility
#
# This task runs the old sysv-rc startup scripts.

start on startup

stop on runlevel

# Note: there can be no previous runlevel here, if we have one it's bad
# information (we enter rc1 not rcS for maintenance).
console output
script
#runlevel --set S >/dev/null || true
#PREVLEVEL=N
#RUNLEVEL=S
#export PREVLEVEL RUNLEVEL

set $(runlevel --set S || true)
if [ "$1" != "unknown" ]; then
PREVLEVEL=$1
RUNLEVEL=$2
export PREVLEVEL RUNLEVEL
fi

exec /etc/init.d/rcS
end script

what's wrong?

Revision history for this message
ingo (rum-topf) wrote :

Yes, I was not able to make any sense out of that patch either.

A more noob-friendly entry such as a proper working rcS file would help us all :)

Thanks in advance!

Revision history for this message
ingo (rum-topf) wrote :

OK, I've finally managed to work out that a "-" before the line means "delete" and a "+" insert. So now my rcS looks as follows:

# This task runs the old sysv-rc startup scripts.

start on startup

stop on runlevel

# Note: there can be no previous runlevel here, if we have one it's bad
# information (we enter rc1 not rcS for maintenance).
console output
script
        set $(runlevel --set S || true)
        if [ "$1" != "unknown" ]; then
        PREVLEVEL=$1
        RUNLEVEL=$2
        export PREVLEVEL RUNLEVEL
        fi

        PREVLEVEL=N
        RUNLEVEL=S
        export PREVLEVEL RUNLEVEL

        exec /etc/init.d/rcS
end script

Revision history for this message
Luis Mondesi (lemsx1) wrote :

Ingo,

why don't you just get the upstart-compat-sysv (upstart-* suite) package from Gutsy and do this (from a Terminal):

#!/bin/sh
# this is a script or you can do one command at a time:

  cd /tmp
  mkdir upstart

# now get (all) packages from the Gutsy archive:
  wget http://archive.ubuntu.com/ubuntu/pool/main/u/upstart/upstart-compat-sysv_0.3.8-2_i386.deb

# you need these for sanity
  wget http://archive.ubuntu.com/ubuntu/pool/main/u/upstart/system-services_0.3.8-2_i386.deb
  wget http://archive.ubuntu.com/ubuntu/pool/main/u/upstart/upstart_0.3.8-2_i386.deb
  wget http://archive.ubuntu.com/ubuntu/pool/main/u/upstart/upstart-logd_0.3.8-2_i386.deb

# extract to /tmp/upstart
  dpkg -x upstart-compat-sysv_0.3.8-2_i386.deb upstart

# again, this is just for sanity
  dpkg -x system-services_0.3.8-2_i386.deb upstart
  dpkg -x upstart_0.3.8-2_i386.deb upstart
  dpkg -x upstart-logd_0.3.8-2_i386.deb upstart

# override the files in /etc/event.d with the new ones:
  sudo cp upstart/etc/event.d/* /etc/event.d/

That will give you a working system again.
When prompted for a password, use your own password.

Revision history for this message
ingo (rum-topf) wrote :

Thank you very much Luis!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.