--- trunk/magellan-initscripts/etc/rc.d/init.d/rc 2005/03/15 19:07:56 71 +++ trunk/magellan-initscripts/etc/rc.d/init.d/rc 2005/07/03 21:34:35 150 @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.4 2005-03-15 19:07:56 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.5 2005-07-03 21:34:35 niro Exp $ source /etc/sysconfig/rc source $rc_functions @@ -7,14 +7,14 @@ # get mage version MAGEVER="$(< /etc/mageversion)" -#source kernel config if exists +# source kernel config if exists [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel -#some needed functions functions +# some needed functions functions populate_udev() { /sbin/udevstart - #not provided by sysfs but needed + # not provided by sysfs but needed ln -snf /proc/self/fd /dev/fd ln -snf fd/0 /dev/stdin ln -snf fd/1 /dev/stdout @@ -22,10 +22,10 @@ ln -snf /proc/kcore /dev/core ln -snf /proc/asound/oss/sndstat /dev/sndstat - #create problematic directories + # create problematic directories mkdir -p /dev/{pts,shm} - #same as /dev/.devfsd + # same as /dev/.devfsd touch /dev/.udev return 0 @@ -35,15 +35,15 @@ [ "$1" != "" ] && runlevel=$1 -if [ "$runlevel" = "sysinit" ] +if [[ $runlevel = sysinit ]] then echo echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" - echo -e "\"I'm not a Gentoo-System, I'm a pure LFS\"" + echo -e "Copyright 2001-2005 Niels Rogalla; http://magellan-linux.net" echo - #mount proc filesystem, needed for bootsplash; - #no use of '/etc/rc.d/init.d/mountproc' anymore + # mount proc filesystem, needed for bootsplash; + # no use of '/etc/rc.d/init.d/mountproc' anymore if [ ! -e /proc/mounts ] then echo -e ${COLOREDSTAR}"Mounting proc file system ..." @@ -51,17 +51,17 @@ evaluate_retval fi - #set default verbose level for kernel messages + # set default verbose level for kernel messages [ -z "${RC_VERBOSE_LEVEL}" ] && RC_VERBOSE_LEVEL=3 echo "${RC_VERBOSE_LEVEL}" > /proc/sys/kernel/printk - #mount sys file system before udev or devfs (kernel-2.6) - if [ "$(kernel_major_version)" == "2.6" ] + # mount sys file system before udev or devfs (kernel-2.6) + if [[ $(kernel_major_version) = 2.6 ]] then if [ -d /sys ] then echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." - mount -t sysfs none /sys + mount -n -t sysfs sysfs /sys evaluate_retval else echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." @@ -71,8 +71,8 @@ fi ## load devfs ## - #load devfs only with a 2.4 kernel or its really wanted with a 2.6 - if [ "$(kernel_major_version)" == "2.4" -o "${RC_USED_DEV}" == "devfs" ] + # load devfs only with a 2.4 kernel or its really wanted with a 2.6 + if [[ $(kernel_major_version) = 2.4 ]] || [[ ${RC_USED_DEV} = devfs ]] then # start devfsd daemon, needed for bootsplash; # no use of '/etc/rc.d/init.d/devfs' anymore @@ -81,11 +81,10 @@ if [ ! -e /dev/.devfsd ] then echo -e ${COLOREDSTAR}"Mounting devfs file system ..." - mount -t devfs devfs /dev + mount -n -t devfs devfs /dev evaluate_retval fi - if [ -e /dev/.devfsd ] then echo -e ${COLOREDSTAR}"Starting devfsd ..." @@ -102,40 +101,32 @@ read $rc_base/init.d/halt fi - fi #### load udev #### - #load udev only with a 2.6 kernel - if [ "$(kernel_major_version)" == "2.6" -a "${RC_USED_DEV}" == "udev" ] + # load udev only with a 2.6 kernel + if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] then -# #first at all unmount devfs if this was loaded by the kernel -# DEVFS_MOUNTED="$(cat /proc/mounts | grep devfs | cut -d ' ' -f3)" -# if [ "${DEVFS_MOUNTED}" == "devfs" ] -# then -# umount -n /dev \ -# && echo "debug: unmounted devfs successfully" \ -# || echo "debug: unmounting devfs failed" -# fi - - #create a ramdisk for populating udev - echo -e ${COLOREDSTAR}"Mounting ramfs at /dev ..." - mount -n -t ramfs none /dev + # create a ramdisk for populating udev + echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." + # tmpfs was suggested by Greg Kroah-Hartman + # many video drivers needed exec access + mount -n -t ramfs udev /dev -o exec,nosuid,mode=0755 evaluate_retval - #if a device tarball exists load it and if it is activated + # if a device tarball exists load it and if it is activated echo -e ${COLOREDSTAR}"Configurating system to use udev ..." - if [ "${RC_DEVICE_TARBALL}" = "yes" ] + if [[ ${RC_DEVICE_TARBALL} = yes ]] then echo -e ${COLOREDSTAR}" Populating /dev with with device nodes ..." tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev evaluate_retval fi - #now load udev + # now load udev populate_udev - #if hotplug support exists in the kernel use it to manage udev + # if hotplug support exists in the kernel use it to manage udev if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ] then echo -e ${COLOREDSTAR}" Using /sbin/hotplug for udev management ..." @@ -150,32 +141,28 @@ evaluate_retval fi - ## load devpts ## # devfs/udev with 2.6 has no ptys, so devpts is also needed - if [ $(kernel_major_version) == 2.6 ] + if [[ $(kernel_major_version) = 2.6 ]] then # check if we really have devpts support - DEVPTS_CHECK="$(cat /proc/filesystems | grep devpts | cut -d $'\t' -f2)" - DEVFS_MOUNTED="$(cat /proc/mounts | grep devfs | cut -d ' ' -f3)" - if [ "${DEVPTS_CHECK}" == devpts ] + if kernel_supports_fs devpts then # /dev/pts maybe not exists. # We only create this directory only if devfs was mounted, # or it will fail as / is still mounted readonly - if [ ! -d "/dev/pts" \ - -a -e "/dev/.devfsd" \ - -a "${DEVFS_MOUNTED}" == "devfs" ] + # udev has this dir already, only a sanity check for devfs + if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs then mkdir -p /dev/pts &> /dev/null || \ echo "Could not create /dev/pts !" fi - #now mount devpts + # now mount devpts if [ -d /dev/pts ] then echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." - mount -n -t devpts -o gid=4,mode=0620 none /dev/pts + mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts evaluate_retval fi else @@ -196,57 +183,29 @@ mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k evaluate_retval - #load bootsplash + # load bootsplash splash "rc_init" "${runlevel}" fi - -if [ "$runlevel" == "0" ] +if [[ $runlevel = 0 ]] || [[ $runlevel = 6 ]] then - - #load bootsplash + # load bootsplash splash "rc_init" "${runlevel}" - # if requested save devices to a device tarball before halt # only for kernels >=2.6 *and* udev # make shure that udev is mounted but *not* devfs --> /dev/.devfsd - if [ "${RC_DEVICE_TARBALL}" = "yes" \ - -a -e /dev/.udev \ - -a ! -e /dev/.devfsd \ - -a ! -e /.bootdev ] + if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ + [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] then echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." - cd /dev - tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null + ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2 evaluate_retval fi fi -if [ "$runlevel" == "6" ] -then - - #load bootsplash - splash "rc_init" "${runlevel}" - - # if requested save devices to a device tarball before halt - # only for kernels >=2.6 *and* udev - # make shure that udev is mounted but *not* devfs --> /dev/.devfsd - if [ "${RC_DEVICE_TARBALL}" = "yes" \ - -a -e /dev/.udev \ - -a ! -e /dev/.devfsd \ - -a ! -e /.bootdev ] - then - echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." - cd /dev - tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null - mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2 - cd .. - evaluate_retval - fi -fi if [ "$runlevel" = "" ] then @@ -254,6 +213,7 @@ exit 1 fi + previous=$PREVLEVEL [ "$previous" = "" ] && previous=N