[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

some issues with the init scripts and other stuff as well... :)



Hi all,

OK, this is not a bug report, but it's time to go to bed now! I prefer to send an email on the list to avoid to forget everything, as I'll be out of the office until Monday (This follows discussion on IRC).

I'm using debian sid, up-to-date, emdebian from emdebian.org/unstable, up-to-date as well.

---

* /etc/rc.d/udev-mtab use "grep --quiet --no-messages", which busybox's grep doesn't understand, should use "grep -q -s"
TESTED: OK

* mountoverflowtmp: df -kP | grep -v Filesystem => df -k | grep -v Filesystem
  Not sure about the impact of not using -P (posix compatibility)
The only difference with -P on a debian machine is the header of the output, which is ignore by the script via the grep -v
TESTED: OK

* from ? that call usr/bin/savelog
/usr/bin/savelog: line 160: getopts: not found

/usr/bin/savelog: shift: line 162: Illegal number: -1

* when installing ssh client and server
/var/lib/dpkg/info/openssh-server.postinst: line 453: perl: not found
/var/lib/dpkg/info/openssh-client.postinst: line 51: syntax error: "}" unexpected

* /etc/rc.d/S35mountall.sh:
"kill -USR1 1" halts the system! Commented out, and guess what? it works better! :).

* from mount{all|nfs}-bootclean.sh:
  from root/lib/init/bootclean.sh
Cleaning /var/run...find: unrecognized: -xtype
replace -xtype by -type ?
TESTED: OK but don't know really the side effects...

---

Then i tried to make some changes to update-rc.d, i've attached the file, there are some comments in the header about why and how i did that (it's just an idea, experimental stuff). Actually i tried to rely as much as possible on the debian init scripts, i would like to use only this in my inittab:
# /etc/inittab
# Note: BusyBox init doesn't support runlevels.

# Start-up the system
::sysinit:/etc/init.d/rcS start
# Put a getty on the console
ttyAM0::respawn:/sbin/getty -L ttyAM0 115200 vt100
# Stuff to do before rebooting
::shutdown:/etc/init.d/rcS stop

---

This is what i get after emsecondstage:
$ ls -1 root/etc/rc.d/
K20sendsigs
K25hwclock.sh
K31umountnfs.sh
K40umountfs
K60umountroot
K63mountoverflowtmp
K90halt
K90reboot
S0001glibc.sh
S0002hostname.sh
S0002mountkernfs.sh
S0003udev
S0004mountdevsubfs.sh
S0005bootlogd
S0008hwclockfirst.sh
S0010checkroot.sh
S0011hwclock.sh
S0012mtab.sh
S0020module-init-tools
S0030checkfs.sh
S0035mountall.sh
S0036mountall-bootclean.sh
S0036udev-mtab
S0037mountoverflowtmp
S0040networking
S0045mountnfs.sh
S0046mountnfs-bootclean.sh
S0055bootmisc.sh
S0055urandom
S0099stop-bootlogd-single
S99rc.local
S99rmnologin
S99stop-bootlogd

And the corresponding init log (nfsroot, with the modifications describe above): init started: BusyBox v1.10.2 (2008-07-06 18:30:06 BST)

starting pid 185, tty '': '/etc/init.d/rcS'

.udev/ already exists on the static /dev! (warning).
  ^
This is because /dev/.udev is not deleted on my nfsroot between reboots Starting the hotplug events dispatcher: udevd.

Synthesizing the initial hotplug events...done.

Waiting for /dev to be fully populated... ts72xx_wdt: TS-72xx watchdog driver, v0.2

done.

Activating swap:.

Will now check all file systems.

fsck 1.41.0 (10-Jul-2008)

Checking all file systems.

Done checking file systems. A log is being saved in /var/log/fsck/checkfs if that location is writable.. Will now mount local filesystems:.

Will now activate swapfile swap:done.

Checking minimum space in /tmp...done.

Configuring network interfaces...run-parts: failed to open directory /etc/network/if-pre-up.d: No such file or directory failed.

/usr/bin/savelog: line 160: getopts: not found

/usr/bin/savelog: shift: line 162: Illegal number: -1

Initializing random number generator...done.

Running local boot scripts (/etc/rc.local).

starting pid 593, tty '/dev/ttyAM0': '/sbin/getty -L ttyAM0 115200 vt100'

Cheers!
Ch'Gans
#!/bin/sh
#
# Copyright 2008 Hands.com Ltd <phil@hands.com>
# Copyright 2008 Neil Williams <codehelp@debian.org>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.

#
# As busybox doesn't understand runlevels, here is the way we work:
#  - We honnor all start/stop in multi-user runlevel without any
#    modification
#  - All start for system start-up are honnored but with an extra
#    "00" prefix to ensure they are called before the multi-user
#    ones.
#  - We honnor only the stop in runlevel Halt or Reboot
#  - We drop everything concerning single user runlevel
#
# Known issues:
#  - rc.local will be called after rmnologin and stop-bootlogd
#  - K90halt and K90reboot should be filtered
#

#
# Other ideas:
#  - make /etc/init.d/rcS accept start and stop as a sole argument,
#    so that we can use in inittab:
#      ::sysinit:/etc/init.d/rcS start
#      ::shutdown:/etc/init.d/rcS stop
#  - use sysvinit, even for en embedded system it is useful.
#

call="$0 $*"

initd="/etc/init.d"
etcd="/etc/rc.d"
bn=$1;shift
if [ "$bn" = '-f' ]; then
	bn=$1
	shift
fi

warn_unhandled () {
	echo "$call"
	echo "Ignoring: $@" 1>&2
}

defaults () {
	makelinks "S${1:-20}"
	makelinks "K${2:-${1:-20}}"
}

# $1: S or K
# $2: one or two-digit prefix 
makelinks () {
	case "$2" in
        	?) pfx=0$2 ;;
	        *) pfx=$2 ;;
	esac
	src="../init.d/$bn"
	dst="${etcd}/${1}${pfx}${bn}"
	echo " Debug: $call"
	echo " Adding symlink for $initd/$bn ...";
	echo "$dst -> $src"
	ln -s $src $dst
}

if [ -z "$bn" -o -z "$1" ]; then
	echo "Insufficient arguments"
	exit 1
fi
if [ ! -f "$initd/$bn" ]; then
	echo "update-rc.d: $initd/$bn: file does not exist\n"
	exit 1
fi
if [ "$1" = 'remove' ]; then
	shift
	echo "rm -f /etc/rc.d/*${bn}"
	rm -f "/etc/rc.d/*${bn}"
	exit;
elif [ "$1" = 'defaults' ]; then
	makelinks "S" "${2:-20}"
	makelinks "K" "${3:-${2:-20}}"
	exit 0;
else
	if [ "$1" = 'start' ]
	then
		shift
		pfx=$1
		shift
		doSys="no"
		doS="no"
		doK="no"
		while [ "$1" != "." ]
		do
			case $1 in
				S)
					doSys="yes";
					;;
				2|3|4|5)
					doS="yes"
					;;
				0|6)
					doK="yes"
					;;
				*)
					warn_unhandled "start ${*}"
					;;
			esac
			shift
		done
		if [ "${doSys}" = "yes" ]; then
			makelinks "S00" "${pfx}"
		elif [ "$doS" = "yes" ]; then
			makelinks "S" "${pfx}"
		fi
		if [ "$doK" = "yes" ]; then
			makelinks "K" "${pfx}"
		fi
		
		shift
		if [ "$1" = 'stop' ]; then
			shift
			pfx=$1
			shift
			doS="no"
			doK="no"
			while [ "$1" != "." ]
			do
				case $1 in
					0|6)
						doK="yes"
						;;
					*)
						warn_unhandled "stop ${*}"
						;;
				esac
				shift
			done
			if [ "$doS" = "yes" ]; then
				makelinks "S" "${pfx}"
			fi
			if [ "$doK" = "yes" ]; then
				makelinks "K" "${pfx}"
			fi
		fi
	else
		warn_unhandled "${*}"
	fi
	exit 0;
fi

Reply to: