--- /sbin/rc.orig 2003-07-11 15:24:17.000000000 -0400 +++ /sbin/rc 2003-07-11 15:39:37.000000000 -0400 @@ -195,50 +195,50 @@ eend 0 fi - if get_bootparam "adelie" - then - einfo "Server/Node low-level initialisation..." - - # Saving the kernel attributed hostname to a file for future - # initialisation selection: see /etc/init.d/switch. - echo "$(< /proc/sys/kernel/hostname)" > "${svcdir}/hostname" + # Swap needs to be activated *after* devfs has been mounted and *after* + # devfsd has been started, so that the fstab can be properly parsed + # and only if the server/Gentoo box is initialized ... + ebegin "Activating (possible) swap" + /sbin/swapon -a &> /dev/null + eend 0 - if checkserver - then - # For server we do pretty much a standard boot ... - einfo "Server detected." - else - # - # Low-level Node Initialisation - # - einfo "Node detected." + # Set the console loglevel to 1 for a cleaner boot + # the logger should anyhow dump the ring-0 buffer at start to the + # logs, and that with dmesg can be used to check for problems + /bin/dmesg -n 1 - init_node + # We set the forced softlevel from the kernel command line + # It needs to be run right after proc is mounted for the + # boot runlevel + for copt in `cat /proc/cmdline` + do + if [ "${copt%=*}" = "softlevel" ] + then + CONFSUFFIX=".${copt##*=}" + elif [ "${copt%=*}" = "bootlevel" ] + then + BOOTLEVEL="${copt##*=}" fi - fi + done - # If a Adelie server, or normal Gentoo box, init swap ... - if checkserver + if [ -z "${BOOTLEVEL}" -o ! -d "/etc/runlevels/${BOOTLEVEL}" ] then - # Swap needs to be activated *after* devfs has been mounted and *after* - # devfsd has been started, so that the fstab can be properly parsed - # and only if the server/Gentoo box is initialized ... - ebegin "Activating (possible) swap" - /sbin/swapon -a &> /dev/null - eend 0 + if [ -d /etc/runlevels/boot${CONFSUFFIX} -o \ + -L /etc/runlevels/boot${CONFSUFFIX} ] + then + BOOTLEVEL="boot${CONFSUFFIX}" + else + BOOTLEVEL="boot" + fi fi - # Set the console loglevel to 1 for a cleaner boot - # the logger should anyhow dump the ring-0 buffer at start to the - # logs, and that with dmesg can be used to check for problems - /bin/dmesg -n 1 # $BOOT can be used by rc-scripts to test if it is the first time # the 'boot' runlevel is executed. Now also needed by some stuff in # the 'sysinit' runlevel ... export BOOT="yes" # I want to get rid of $BOOT, as SOFTLEVEL *should* be used instead .. - export SOFTLEVEL="boot" + export SOFTLEVEL="${BOOTLEVEL}" start_critical_service() { local retval= @@ -253,9 +253,20 @@ return "${retval}" } + + # We first try to find a locally defined list of critical services + # for a particular runlevel. If we cannot find it, we use the + # defaults. + if [ -f /etc/runlevels/${BOOTLEVEL}/critical ] + then + CRITICAL_SERVICES=$(< /etc/runlevels/${BOOTLEVEL}/critical) + else + CRITICAL_SERVICES="checkroot hostname modules checkfs localmount" + fi + # We do not want to break compadibility, so we do not fully integrate # these into /sbin/rc, but rather start them by hand ... - for x in checkroot hostname modules checkfs localmount + for x in ${CRITICAL_SERVICES} do if ! start_critical_service "${x}" then @@ -288,7 +299,7 @@ # Now that the dependency cache are up to date, make sure these # are marked as started ... - for x in checkroot hostname modules checkfs localmount + for x in ${CRITICAL_SERVICES} do ln -snf "/etc/init.d/${x}" "${svcdir}/started/${x}" done @@ -300,8 +311,14 @@ # $BOOT can be used by rc-scripts to test if it is the first time # the 'boot' runlevel is executed export BOOT="yes" + # I want to get rid of $BOOT, as SOFTLEVEL *should* be used instead .. - export SOFTLEVEL="boot" + export SOFTLEVEL="${BOOTLEVEL}" + + # We reset argv1 to the bootlevel given on the kernel command line + # if there is one + argv1="${BOOTLEVEL}" + fi if [ "${argv1}" = "sysinit" ] @@ -327,10 +344,16 @@ then export SOFTLEVEL="$(< ${svcdir}/softlevel)" else - export SOFTLEVEL="boot" + export SOFTLEVEL="${BOOTLEVEL}" fi else - export SOFTLEVEL="${argv1}" + if [ -z "${OLDSOFTLEVEL}" -a \ + "${argv1}" = "default" -a "${forcedlevel}" ] + then + export SOFTLEVEL="${forcedlevel}" + else + export SOFTLEVEL="${argv1}" + fi fi if [ ! -f "${svcdir}/softlevel" ] @@ -360,17 +383,17 @@ exit 1 else myscripts= - if [ "${SOFTLEVEL}" != "boot" ] + if [ "${SOFTLEVEL}" != "${BOOTLEVEL}" ] then # Normal runlevels *include* boot scripts mylevels="$(dolisting "/etc/runlevels/${SOFTLEVEL}/")" - mylevels="${mylevels} $(dolisting /etc/runlevels/boot/)" + mylevels="${mylevels} $(dolisting /etc/runlevels/${BOOTLEVEL}/)" else # Non-normal runlevels don't include boot scripts as default mylevels="$(dolisting "/etc/runlevels/${SOFTLEVEL}/")" fi - [ "${OLDSOFTLEVEL}" = "boot" -o "${OLDSOFTLEVEL}" = "single" ] \ + [ "${OLDSOFTLEVEL}" = "${BOOTLEVEL}" -o "${OLDSOFTLEVEL}" = "single" ] \ && /bin/dmesg -n 1 for x in ${mylevels}