[Pkg-sysvinit-devel] rc.local

Michael earlymorning at gmx.ch
Sat Oct 17 01:32:33 UTC 2009


thank you for tracking tips Petter

Hello maintainers, i have a weird problem on this debian box.

Debian Sid amd64, stock kernel 2.6.30-2-amd64
sysv-rc: 2.87
initscripts: 2.87

I use the script /etc/rc.local since at least 2 years for some specific netowrk setup, but at some point int the past (i can't tell) it gets executed multiple times.

Exactly, twice in runlevel 2. Actually i saw it been executed even 3 times before, but i don't want to complicate the issue :) so let's settle for 2 times because that's the latest result.

When i put this 'debugger' into rc.local:

log=/tmp/log

echo "Runlevel: $RUNLEVEL" >> $log
echo "PPID: " $PPID >> $log
echo "Process:" >> $log; 
ps e -p $PPID >> $log


then /tmp/log says after boot:

Runlevel: 2
PPID:  2413
Process:
  PID TTY      STAT   TIME COMMAND
 2413 ?        S      0:00 /bin/sh /etc/rc2.d/S99rc.local start CONSOLE=/dev/console SELINUX_INIT=YES TERM=linux rootmnt=/root INIT_VERSION=sysvinit-2.86 init=/sbin/init PATH=/sbin:/usr/sbin:/bin:/usr/bin runlevel=2 RUNLEVEL=2 PWD=/ VERBOSE=yes previous=N PREVLEVEL=N SHLVL=1 HOME=/ BOOT_IMAGE=/boot/vmlinuz-2.6.30-2-amd64 _=/etc/rc2.d/S99rc.local

Runlevel: 2
PPID:  2793
Process:
  PID TTY      STAT   TIME COMMAND
 2793 ?        S      0:00 /bin/sh /etc/rc2.d/S99rc.local start CONSOLE=/dev/console SELINUX_INIT=YES TERM=linux rootmnt=/root INIT_VERSION=sysvinit-2.86 init=/sbin/init PATH=/sbin:/usr/sbin:/bin:/usr/bin runlevel=2 RUNLEVEL=2 PWD=/ VERBOSE=yes previous=N PREVLEVEL=N SHLVL=1 HOME=/ BOOT_IMAGE=/boot/vmlinuz-2.6.30-2-amd64 _=/etc/rc2.d/S99rc.local

You can see both log entries are from runlevel 2. 

#> ls /etc/rc?.d/*rc.local 

/etc/rc2.d/S99rc.local  /etc/rc3.d/S99rc.local  /etc/rc4.d/S99rc.local  /etc/rc5.d/S99rc.local

#> cat /etc/init.d/rc.local

#! /bin/sh
### BEGIN INIT INFO
# Provides:          rc.local
# Required-Start:    $remote_fs $syslog $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO

# xxx mi:
VERBOSE=yes

PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
	if [ -x /etc/rc.local ]; then
	        [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
		/etc/rc.local
		ES=$?
		[ "$VERBOSE" != no ] && log_end_msg $ES
		return $ES
	fi
}

case "$1" in
    start)
	do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

You can see i put VERBOSE=yes into it but can not see anything additional in syslog. INdeed i can see nothing from init at all there, is that normal ??
I also enabled bootlogd but that doesn't add any log entries.

/ r: grep -r "gandalf init" /var/log
/var/log/daemon.log:Oct 11 10:27:19 gandalf init: Switching to runlevel: 0
/var/log/daemon.log:Oct 12 07:43:22 gandalf init: Switching to runlevel: 0
/var/log/daemon.log:Oct 14 23:11:02 gandalf init: Trying to re-exec init
/var/log/daemon.log:Oct 15 11:35:57 gandalf init: Switching to runlevel: 0
/var/log/daemon.log:Oct 16 03:37:18 gandalf init: Switching to runlevel: 6
/var/log/daemon.log:Oct 16 15:33:02 gandalf init: Switching to runlevel: 0
/var/log/daemon.log:Oct 17 01:22:58 gandalf init: Trying to re-exec init

As you can see i did some reboots for tracking. 
I've no idea what the re-exec lines mean, they didn't occur right now again.

At boottime, some services FAIL: syslog, cron, xinetd, gpm. But after login they're there, running! I suspect this is because they're strated twice.

I booted into single user mode and discovered that there are two init processes:
#> ps aux | grep init
root         1  0.4  0.0  10316   708 ?        Ss   02:30   0:00 init [S]         
root      1872  0.0  0.0  10316   244 tty1     Ss   02:30   0:00 init [S]    


and when i issued 'init2' on commandline then it was only one:

root         1  0.0  0.0  10316   776 ?        Ss   02:30   0:00 init [2]    

and as you can see the process 1872 terminated then. 

Is this normal behaviour ?

I attach a zipfile with logfiles: daemon, syslog, kernel. I resetted them to 0 bytes and copied them directly after boot, in runlevel 2, on textconsole, before any X (i disabled the display login manager).

I have no clue what to check next. The best thing i can come up with is that i upgraded to grub2 some weeks ago, but i just followed the instructions and it went flawless. Anyway, i attach grub.cfg too.

I hope you can help me to solve this riddle  .... !

tia Micha

-------------- next part --------------
A non-text attachment was scrubbed...
Name: logfiles.zip
Type: application/zip
Size: 321213 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20091017/fc1e96b8/attachment-0001.zip>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grub.cfg
Type: application/octet-stream
Size: 2345 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20091017/fc1e96b8/attachment-0001.obj>


More information about the Pkg-sysvinit-devel mailing list