#!/bin/sh # $Header: /home/cvsd/magellan-cvs/magellan-src/busybox-initscripts/rc/rc,v 1.2 2008-12-22 22:09:27 niro Exp $ source /etc/conf.d/rc source ${rc_functions} # source kernel config if exists [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel # prefer mdev if it is present, always fall back to udev # these settings can be overriden via /etc/conf.d/kernel if [[ -z ${RC_DEVMANAGER} ]] then if [[ -e ${rc_base}/init.d/mdev ]] then RC_DEVMANAGER="udev" elif [[ -e ${rc_base}/init.d/udev ]] then RC_DEVMANAGER="udev" fi fi # load device management hooks source ${rc_base}/init.d/${RC_DEVMANAGER} # get mage version MAGEVER="$(< /etc/mageversion)" trap "" INT QUIT TSTP [[ ! -z $1 ]] && runlevel=$1 if [[ -z ${runlevel} ]] then echo "Usage: $0 " >&2 exit 1 fi if [[ $runlevel = sysinit ]] then rc_echo rc_echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" rc_echo -e "Copyright 2001-2010 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 rc_print "Mounting proc file system ..." mount -n /proc evaluate_retval fi # load bootsplash splash "rc_init" "${runlevel}" # 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 if [ -d /sys ] then 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 # 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 # /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 || \ rc_echo "Could not create /dev/pts !" fi # now mount devpts if [ -d /dev/pts ] then rc_print "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 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 usbfs ## if kernel_supports_fs usbfs then rc_print "Mounting usbfs at /proc/bus/usb ..." mount -n -t usbfs usbfs /proc/bus/usb evaluate_retval fi ## end usbfs ## ## services state dir ## rc_print "Mounting tmpfs at ${svcdir} ..." mount -n -t tmpfs tmpfs "${svcdir}" -o rw,mode=0644,size="${svcsize}"k evaluate_retval fi if [[ ${runlevel} = shutdown ]] || [[ ${runlevel} = reboot ]] 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 ]] && \ [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] then 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 evaluate_retval fi # stop device management stop_devicemanager # run through all runlevel scripts for i in $(ls -v ${rc_base}/rc${runlevel}.d/K* 2> /dev/null) do check_script_status suffix=${i#${rc_base}/rc${runlevel}.d/K[0-9][0-9]} ${i} stop error_value=$? if [[ ${error_value} != 0 ]] then print_error_msg fi done fi if [[ ${runlevel} = sysinit ]] || [[ ${runlevel} = boot ]] then for i in $( ls -v ${rc_base}/rc${runlevel}.d/S* 2> /dev/null) do suffix=${i#${rc_base}/rc${runlevel}.d/S[0-9][0-9]} check_script_status ${i} start error_value=$? if [[ ${error_value} != 0 ]] then print_error_msg fi done fi if [[ ${runlevel} = boot ]] then # exit bootsplash splash "rc_exit" "${runlevel}" fi