--- trunk/magellan-initscripts/etc/rc.d/init.d/rc 2006/05/29 21:25:45 376 +++ trunk/magellan-initscripts/rc/rc 2011/03/11 17:44:48 1263 @@ -1,8 +1,8 @@ #!/bin/bash -# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.9 2006-05-29 21:25:45 niro Exp $ +# $Id$ -source /etc/sysconfig/rc -source $rc_functions +source /etc/conf.d/rc +source ${rc_functions} # get mage version MAGEVER="$(< /etc/mageversion)" @@ -10,113 +10,15 @@ # source kernel config if exists [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel -udev_version() -{ - local version=0 - - if [[ -x /sbin/udev ]] - then - version=$(/sbin/udev -V) - # We need it without a leading '0', else bash do the wrong thing - version=${version##0} - # Older udev's will print nothing - [[ -z ${version} ]] && version=0 - fi - - echo "${version}" -} - -# this works only for 2.6.15 kernels and greater -trigger_events() -{ - local list="" - local i - local first - local last - local default - - # if you want real hotplug (with all modules being loaded for all - # devices in the system), uncomment out the next line. - #list="$list $(echo /sys/bus/*/devices/*/uevent)" - list="${list} $(echo /sys/class/*/*/uevent)" - list="${list} $(echo /sys/block/*/uevent /sys/block/*/*/uevent)" - for i in ${list} - do - case "${i}" in - */device/uevent) - # skip followed device symlinks - continue - ;; - */class/mem/*|*/class/tty/*) - first="${first} ${i}" - ;; - */block/md*) - last="${last} ${i}" - ;; - */*) - default="${default} ${i}" - ;; - esac - done - - # trigger the sorted events - for i in ${first} ${default} ${last} - do - echo "add" > "${i}" - done -} - -populate_udev() -{ - local loop - - # populate /dev with devices already found by the kernel - if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] - then - echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." - trigger_events - evaluate_retval - else - echo -e ${COLOREDSTAR}" Populating /dev with existing devices with udevstart ..." - /sbin/udevstart - evaluate_retval - fi - - # loop until everything is finished - # there's gotta be a better way... - echo -e ${COLOREDSTAR}" Letting udev process events ..." - loop=0 - while test -d /dev/.udev/queue - do - sleep 0.1; - test "${loop}" -gt 300 && break - loop=$((${loop} + 1)) - done - evaluate_retval - - return 0 -} +# override devicemanager helper functions +if [[ ${RC_DEVICEMANAGER} = udev ]] && [[ -f ${rc_base}/init.d/udev ]] +then + source ${rc_base}/init.d/udev -seed_dev() -{ - # seed /dev with some things that we know we need - echo -e ${COLOREDSTAR}" Seeding /dev with needed nodes ..." - ( - # copy over any persistant things - cp --preserve=all --recursive --update /lib/udev/devices/* /dev - - # 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 - ln -snf fd/2 /dev/stderr - [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core - - # create problematic directories - mkdir -p /dev/{pts,shm} - ) - evaluate_retval -} +elif [[ ${RC_DEVICEMANAGER} = mdev ]] && [[ -f ${rc_base}/init.d/mdev ]] +then + source ${rc_base}/init.d/mdev +fi trap "" INT QUIT TSTP @@ -124,16 +26,16 @@ if [[ $runlevel = sysinit ]] then - echo - echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" - echo -e "Copyright 2001-2006 Niels Rogalla; http://magellan-linux.net" - echo + rc_echo + rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" + rc_echo "Copyright 2001-2011 Niels Rogalla; http://magellan-linux.net" + rc_echo # 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 ..." + rc_print "Mounting proc file system ..." mount -n /proc evaluate_retval fi @@ -142,159 +44,68 @@ [ -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 + if [ -d /sys ] then - if [ -d /sys ] - then - echo -e ${COLOREDSTAR}"Mounting sysfs file system ..." - mount -n -t sysfs sysfs /sys - evaluate_retval - else - echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." - echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." - echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." - fi + rc_print "Mounting sysfs file system ..." + mount -n -t sysfs sysfs /sys + evaluate_retval + else + rc_echo -e ${COLORED}"Fatal: mountpoint /sys missing ..." + rc_echo -e ${COLYELLOW}"Please create the directory /sys (mkdir -p /sys)." + rc_echo -e ${COLYELLOW}"It's essential for a 2.6 kernel." 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 ]] || [[ ${RC_USED_DEV} = devfs ]] + # start device management + start_devicemanager + + ## load devpts ## + # devfs/udev with 2.6 has no ptys, so devpts is also needed + # check if we really have devpts support + if kernel_supports_fs devpts then - # start devfsd daemon, needed for bootsplash; - # no use of '/etc/rc.d/init.d/devfs' anymore - # check if devfs was mounted by the kernel, - # if not mount it (mbuild_livecd needs this one) - if [ ! -e /dev/.devfsd ] + # /dev/pts maybe not exists. + # We only create this directory only if devfs was mounted, + # or it will fail as / is still mounted readonly + # udev has this dir already, only a sanity check for devfs + if [ ! -d "/dev/pts" -a -e "/dev/.devfsd" ] && is_fs_mounted devfs then - echo -e ${COLOREDSTAR}"Mounting devfs file system ..." - mount -n -t devfs devfs /dev - evaluate_retval + mkdir -p /dev/pts &> /dev/null || \ + rc_echo "Could not create /dev/pts !" fi - if [ -e /dev/.devfsd ] + # now mount devpts + if [ -d /dev/pts ] then - echo -e ${COLOREDSTAR}"Starting devfsd ..." - ## directory /lib/dev-state !must! exists ## - /sbin/devfsd /dev &> /dev/null + rc_print "Mounting devpts at /dev/pts ..." + mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts evaluate_retval - else - echo -e ${COLRED}"No devfs filesystem found ..." - echo -e ${COLYELLOW}"Your Kernel doesn't support the devfs filesystem." - echo -e ${COLYELLOW}"Devfs is necessary to run Magellan-Linux." - echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." - echo - echo -e ${COLYELLOW}"Press any key to shutdown the system safely ..." - read - $rc_base/init.d/halt fi + else + # devpts is not supported, give a warning + rc_echo -e ${COLRED}"No devpts filesystem found ..." + rc_echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." + rc_echo -e ${COLYELLOW}"Devfs/Udev with a kernel-2.6.x needs devpts," + rc_echo -e ${COLYELLOW}"or no pty's are available." + rc_echo -e ${COLYELLOW}"Please make sure that this is enabled in your kernel." + rc_echo + rc_echo -e ${COLYELLOW}"Press any key to continue ..." + read fi + ## end devpts ## - #### load udev #### - # load udev only with a 2.6 kernel - if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] - then - # 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 - echo -e ${COLOREDSTAR}"Configurating system to use udev ..." - if [[ ${RC_DEVICE_TARBALL} = yes ]] - then - echo -e ${COLOREDSTAR}" Populating /dev with saved device nodes ..." - tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev - evaluate_retval - fi - - # other eeded device nodes with udev - seed_dev - - if [ -e /proc/sys/kernel/hotplug ] - then - if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] - then - echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." - echo "" > /proc/sys/kernel/hotplug - evaluate_retval - elif [[ $(udev_version) -ge "48" ]] - then - echo -e ${COLOREDSTAR}" Setting /sbin/udevsend as hotplug agent ..." - echo "/sbin/udevsend" > /proc/sys/kernel/hotplug - evaluate_retval - elif [[ -x /sbin/hotplug ]] - then - echo -e ${COLOREDSTAR}" Using /sbin/hotplug as hotplug agent ..." - print_status success - else - echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..." - echo "/sbin/udev" > /proc/sys/kernel/hotplug - evaluate_retval - fi - else - echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" - print_status failure - fi - - echo -e ${COLOREDSTAR}" Starting udevd daemon ..." - /sbin/udevd --daemon - evaluate_retval - - populate_udev - - # create nodes that udev can't - echo -e ${COLOREDSTAR}" Finializing udev configuration ..." - [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null - [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null - [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null - print_status success - - # same thing as /dev/.devfsd - touch /dev/.udev - fi - ## load devpts ## - # devfs/udev with 2.6 has no ptys, so devpts is also needed - if [[ $(kernel_major_version) = 2.6 ]] + ## load usbfs ## + if kernel_supports_fs usbfs then - # check if we really have devpts support - 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 - # 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 - if [ -d /dev/pts ] - then - echo -e ${COLOREDSTAR}"Mounting devpts at /dev/pts ..." - mount -n -t devpts -o gid=4,mode=0620 devpts /dev/pts - evaluate_retval - fi - else - # devpts is not supported, give a warning - echo -e ${COLRED}"No devpts filesystem found ..." - echo -e ${COLYELLOW}"Your Kernel doesn't support the devpts filesystem." - echo -e ${COLYELLOW}"Devfs with a kernel-2.6.x needs devpts," - echo -e ${COLYELLOW}"or no pty's are available." - echo -e ${COLYELLOW}"Please make shure that this is enabled in your kernel." - echo - echo -e ${COLYELLOW}"Press any key to continue ..." - read - fi + rc_print "Mounting usbfs at /proc/bus/usb ..." + mount -n -t usbfs usbfs /proc/bus/usb + evaluate_retval fi + ## end usbfs ## - ### services state dir ### - echo -e ${COLOREDSTAR}"Mounting tmpfs at ${svcdir} ..." + ## services state dir ## + rc_print "Mounting tmpfs at ${svcdir} ..." mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k evaluate_retval @@ -314,17 +125,20 @@ if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] then - echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." + rc_print "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 + mv -f "/tmp/devices-$$.tar.bz2" /lib/udev/state/devices.tar.bz2 evaluate_retval fi + + # stop device management + stop_devicemanager fi if [ "$runlevel" = "" ] then - echo "Usage: $0 " >&2 + rc_echo "Usage: $0 " >&2 exit 1 fi @@ -334,7 +148,7 @@ if [ ! -d $rc_base/rc$runlevel.d ] then - echo "$rc_base/rc$runlevel.d does not exist" + rc_echo "$rc_base/rc$runlevel.d does not exist" exit 1 fi @@ -354,8 +168,8 @@ if [ ! -f $prev_start ] && [ ! -f $sysinit_start ] then $WARNING - echo "$i can't be executed because it was" - echo "not started in the previous runlevel ($previous)" + rc_echo "$i can't be executed because it was" + rc_echo "not started in the previous runlevel ($previous)" $NORMAL continue fi