From 535000109a2bd1b6475f3fba24fa8f94940eae07 Mon Sep 17 00:00:00 2001 From: Dirk von Suchodoletz Date: Wed, 31 Jan 2007 22:14:19 +0000 Subject: Cleanups in major startup scripts/functions and small fixes ... git-svn-id: http://svn.openslx.org/svn/openslx/trunk@662 95ad53e4-c205-0410-b2fa-d234c58c8868 --- initramfs/initrd-stuff/bin/hwautocfg | 93 ++++++++++++--------------- initramfs/initrd-stuff/etc/functions | 51 +++++++++------ initramfs/initrd-stuff/etc/messages | 24 ++++--- initramfs/initrd-stuff/init | 118 ++++++++++++++++++----------------- 4 files changed, 150 insertions(+), 136 deletions(-) diff --git a/initramfs/initrd-stuff/bin/hwautocfg b/initramfs/initrd-stuff/bin/hwautocfg index 45758c71..83e22ff7 100755 --- a/initramfs/initrd-stuff/bin/hwautocfg +++ b/initramfs/initrd-stuff/bin/hwautocfg @@ -259,13 +259,13 @@ modprobe ${MODPRV} usbcore & # "drivers" (pseudo, placeholder strings, ...) to exclude from loading # depending on distro more hw modules have to be excluded too. use the # D_HWMODTOIGNORE for that purpose -DRIVERLIST=" disabled unknown ignore pcspkr synaptics keybdev kanotix\ +driverlist=" disabled unknown ignore pcspkr synaptics keybdev kanotix\ ${D_HWMODTOIGNORE} " # driver blacklist (real modules which fail to load) -DRIVERLIST=${DRIVERLIST}"hw_random genericwheelusb " +driverlist=${driverlist}"hw_random genericwheelusb " # hack for pseudo modules (not to load) hopefully "usbcore" is present # as a module, might be exchanged with any other existing ... -for i in $DRIVERLIST ; do +for i in $driverlist ; do echo -e "alias\t$i\tusbcore" >> /etc/modprobe.conf done @@ -290,29 +290,29 @@ waitfor /tmp/hwrun1 50000 || \ error "$hcfg_hwsetup" [ $DEBUGLEVEL -eq 21 ] && echo "** 1st hwdetection finished at $(sysup)" # load ide drivers first, takes a while to initialize -for DRIVER in cmd64x hpt366 piix slc90e66 cs5520 it821x rz1000 \ +for driver in cmd64x hpt366 piix slc90e66 cs5520 it821x rz1000 \ triflex aec62xx cs5530 ns87415 sc1200 trm290 alim15x3 \ cy82c693 opti621 serverworks via82cxxx amd74xx pdc202xx_new \ siimage atiixp hpt34x pdc202xx_old sis5513; do - strinfile " ${DRIVER}" /tmp/hwsetup.info && { - IDE="yes" - modprobe ${MODPRV} ${DRIVER} & - DRIVERLIST="${DRIVERLIST} ${DRIVER}"; } + strinfile " ${driver}" /tmp/hwsetup.info && { + ide="yes" + modprobe ${MODPRV} ${driver} & + driverlist="${driverlist} ${driver}"; } done # check for IDE/SCSI (SATA) -for DRIVER in ata_piix sata_via sata_nv sata_sil sata_sis sata_svw \ +for driver in ata_piix sata_via sata_nv sata_sil sata_sis sata_svw \ sata_sx4 sata_uli sata_vsc sata_qstor sata_promise sata_mv; do - strinfile " ${DRIVER}" /tmp/hwsetup.info && { + strinfile " ${driver}" /tmp/hwsetup.info && { #SCSIIDE="yes" - modprobe ${MODPRV} ${DRIVER} & - DRIVERLIST="${DRIVERLIST} ${DRIVER}"; } + modprobe ${MODPRV} ${driver} & + driverlist="${driverlist} ${driver}"; } done # check for USB, pcmcia and ieee1394 hardware drivers -for DRIVER in ohci-hcd uhci-hcd ehci-hcd ohci1394; do - strinfile " ${DRIVER}" /tmp/hwsetup.info && { +for driver in ohci-hcd uhci-hcd ehci-hcd ohci1394; do + strinfile " ${driver}" /tmp/hwsetup.info && { USB="yes" - modprobe ${MODPRV} ${DRIVER} - DRIVERLIST="${DRIVERLIST} ${DRIVER}"; } + modprobe ${MODPRV} ${driver} + driverlist="${driverlist} ${driver}"; } done [ -x /bin/mdev ] && mdev -s & # load usbhid (for USB keyboard/mouse) or remove usbcore module if USB @@ -322,35 +322,35 @@ if [ -n "$USB" ] ; then else rmmod usbcore fi # remove unneeded network card modules -for DRIVER in ${NWMODULES}; do - strinfile " ${DRIVER}" /tmp/hwsetup.info || { - rmmod ${DRIVER} & - DRIVERLIST="${DRIVERLIST} ${DRIVER}"; } +for driver in ${NWMODULES}; do + strinfile " ${driver}" /tmp/hwsetup.info || { + rmmod ${driver} & + driverlist="${driverlist} ${driver}"; } done -# check for PCMCIA / cardbus stuff -for DRIVER in yenta_socket i82365 pd6729 tcic; do - strinfile ${DRIVER} /tmp/hwsetup.info && { - modprobe ${MODPRV} ${DRIVER} - DRIVERLIST="${DRIVERLIST} ${DRIVER}" - PCMCIA="yes"; } +# check for pcmcia / cardbus stuff +for driver in yenta_socket i82365 pd6729 tcic; do + strinfile " ${driver}" /tmp/hwsetup.info && { + modprobe ${MODPRV} ${driver} + driverlist="${driverlist} ${driver}" + pcmcia="yes"; } done # should we check for card reader modules too? # newer kernels support some of the major multicard readers which could # be found in some barebone systems like Pundits or in many laptops - -if [ -n "${PCMCIA}" ] ; then +if [ -n "${pcmcia}" ] ; then modprobe ${MODPRV} ds fi # sound card setup (alsa and oss compatibility drivers) if [ -f /etc/sysconfig/sound ] ; then . /etc/sysconfig/sound -else DRIVER="snd-dummy" + driver=${DRIVER} +else driver="snd-dummy" fi # problem with a specific module not disabled (via above trick) when # busybox is used # rmmod snd_atiixp_modem snd_atiixp -modprobe ${MODPRV} ${DRIVER} -DRIVERLIST="${DRIVERLIST} ${DRIVER} " +modprobe ${MODPRV} ${driver} +driverlist="${driverlist} ${driver}" modprobe ${MODPRV} snd-pcm-oss modprobe ${MODPRV} snd-mixer-oss @@ -359,21 +359,21 @@ modprobe ${MODPRV} snd-mixer-oss # like dvd or harddisk - wait a few seconds so hopefully the ide driver # is initialized [ -x /bin/mdev ] && mdev -s & +[ -n "$ide" ] && modprobe -q ide_generic 2>/dev/null test -f /proc/bus/usb/devices || \ mount -n -t usbfs usbfs /proc/bus/usb 2>/dev/null -[ -n "$IDE" ] && modprobe -q ide_generic 2>/dev/null [ $DEBUGLEVEL -eq 21 ] && echo "** started 2nd hwdetection at $(sysup)" usleep 200 && hwsetup -v > /tmp/hwsetup.info [ $DEBUGLEVEL -eq 21 ] && echo "** finished 2nd hwdetection at $(sysup)" # remaining drivers listed in /tmp/hwsetup.info -cat /tmp/hwsetup.info| while read LINE ; do - if strinstr "driver:" "${LINE}"; then - DRIVER=${LINE##driver: } - if ! strinstr " ${DRIVER} " "${DRIVERLIST}"; then - strinstr "Card:" "${DRIVER}" || strinstr "ps/2" "${DRIVER}" || { - modprobe ${MODPRV} ${DRIVER} & - usleep 100; } - DRIVERLIST="${DRIVERLIST} ${DRIVER}" +cat /tmp/hwsetup.info| while read line ; do + if strinstr "driver:" "${line}"; then + driver=${line##driver: } + if ! strinstr " ${driver} " "${driverlist}"; then + strinstr "Card:" "${driver}" || strinstr "ps/2" "${driver}" || { + modprobe ${MODPRV} ${driver} & + usleep 50; } + driverlist="${driverlist} ${driver}" fi fi done @@ -383,7 +383,7 @@ done # (strinfile "keybdev" /tmp/hwsetup.info || rmmod usbhid) # load IDE high level drivers -if [ -n "$IDE" ] ; then +if [ -n "$ide" ] ; then # you might want to check /etc/sysconfig/floppy for more info strinfile "ZIP" /tmp/hwsetup.info && modprobe ${MODPRV} ide-floppy strinfile "CDROM" /tmp/hwsetup.info && modprobe ${MODPRV} ide-cd @@ -476,13 +476,6 @@ done #[ -n "${KEYTABLE}" ] && keytable #[ -n "${CONSOLE_FONT}" ] && consolefont -# finalize X configuration XBinPath contains pointer of to X binary -# in /var/X11R6/bin/X - only needed if var is set -#displayvars -#if [ -n $XBinPath ] ; then -# testmkd /mnt/var/X11R6/bin -# ln -sf $XBinPath /mnt/var/X11R6/bin/X -#fi # if any new device appeared up to now if [ -x /bin/mdev ] ; then mdev -s & @@ -490,10 +483,6 @@ if [ -x /bin/mdev ] ; then mknod /dev/input/mice c 13 63 2>/dev/null fi -# wait for completion of Xorg configuration -#waitfor /tmp/xready 20000 -#cp /etc/xorg.conf ${D_XF86CONFFILE} - # do not finish until tmp is setup properly #[ -n "$part44" ] && waitfor /tmp/tmpready 20000 # not needed --> servconfig waits for it! diff --git a/initramfs/initrd-stuff/etc/functions b/initramfs/initrd-stuff/etc/functions index ec8803a1..83611be6 100644 --- a/initramfs/initrd-stuff/etc/functions +++ b/initramfs/initrd-stuff/etc/functions @@ -38,7 +38,7 @@ udev_hotplug () { ############################################################################# # generate events with the sysfs trigger trigger_device_events () { - list=$(echo /sys/bus/*/devices/*/uevent) + local 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 @@ -149,13 +149,20 @@ fi ############################################################################# # (re)generate dynamic linked libraries cache from /etc/ld.so.conf ldcfg () { -[ -z "${NOLDSC}" ] && echo "$init_ldcfg" && ldconfig /tmp/ld.so.cache & +[ -z "${noldsc}" ] && echo "$init_ldcfg" && ldconfig /tmp/ld.so.cache & } ############################################################################# # URI interpreter $1 variable to interprete, $2 type of token to return # prot: tftp, http, nbd, ... server: IP or FQDN uri_token () { local var=$1 +local prot +local rest +local server +local path +local port +local tmpval +local query="" # first check if URI starts with prot:// - URI scheme if strinstr "://" "$1" ; then prot=${var%://*} @@ -180,7 +187,6 @@ else port="" fi # get path and query components - URI path, query -query="" if strinstr "\?" "$rest" ; then path="${path%\?*}" query="${rest#*\?}" @@ -212,6 +218,7 @@ fi nm2pref () { set `IFS="."; echo $1` local n=0 +local i for i in $1 $2 $3 $4 ; do case $i in 0) break ;; @@ -230,6 +237,7 @@ echo $n # configure Xen bridge xenbr0 xenbr_config () { modprobe netloop +local ipls local vifnum="0" local bridge="xenbr${vifnum}" local netdev="eth${vifnum}" @@ -237,20 +245,26 @@ local pdev="p${netdev}" local vdev="veth${vifnum}" local vif0="vif0.${vifnum}" local mac=$(ip link show ${netdev} | sed -n '/^.*link\/ether/p' \ - | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/') + | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/') brctl addbr ${bridge} brctl stp ${bridge} off brctl setfd ${bridge} 0 brctl addif ${bridge} ${vif0} -ip link set ${netdev} name ${pdev} -ip link set ${vdev} name ${netdev} -ip link set ${pdev} down arp off -ip link set ${pdev} addr fe:ff:ff:ff:ff:ff -ip link set ${netdev} addr ${mac} arp on -ip link set ${bridge} up -ip link set ${vif0} up -ip link set ${pdev} up +for ipls in "${netdev} name ${pdev}" "${vdev} name ${netdev}" \ + "${pdev} down arp off" "${pdev} addr fe:ff:ff:ff:ff:ff" \ + "${netdev} addr ${mac} arp on" "${netdev} addr ${mac} arp on" \ + "${bridge} up" "${vif0} up" "${pdev} up" ; do + ip link set ${ipls} +done +#ip link set ${netdev} name ${pdev} +#ip link set ${vdev} name ${netdev} +#ip link set ${pdev} down arp off +#ip link set ${pdev} addr fe:ff:ff:ff:ff:ff +#ip link set ${netdev} addr ${mac} arp on +#ip link set ${bridge} up +#ip link set ${vif0} up +#ip link set ${pdev} up brctl addif ${bridge} ${pdev} } ############################################################################# @@ -280,7 +294,6 @@ case $ipcfg in [ -n "$nbdhost" ] && [ `echo $nbdhost|sed "s,\..*,,"` -ge 224 ] && \ ip route add 224.0.0.0/4 dev eth0 ;; - # the klibc ip configuration / dhcp client tool is deprecated # traditional ifconfig/route - if a distro does not provide ip ifconfig) if [ "$ip" = "0.0.0.0" ]; then @@ -359,7 +372,7 @@ fi } ############################################################################# -# dhcp client +# dhcp client function (support dhclient, dhcpcd, pump, udhcpc) rundhcp () { local vci="$1" @@ -449,9 +462,9 @@ fileget () { # (fixme: rewrite of fileget needed!!) # analyze file soure (URI) in $FILESRC if [ -n "$FILESRC" ] ; then - srvproto=$(uri_token $FILESRC prot) - cfgfile="/$(uri_token $FILESRC path)" - tftpserver=$(uri_token $FILESRC server) + local srvproto=$(uri_token $FILESRC prot) + local cfgfile="/$(uri_token $FILESRC path)" + local tftpserver=$(uri_token $FILESRC server) tftpgetunpack $tftp $cfgfile $tftpserver else # predefined value for openslx environment; it is expected that this @@ -601,7 +614,7 @@ cfgcomplete () { waitfor /tmp/dhcp-done 10000 || error "$error_errdcfg" nonfatal waitfor /tmp/file-done 10000 || error "$error_errfcfg" nonfatal waitfor /tmp/ldap-done 10000 || error "$error_errlcfg" nonfatal -# concat the different files now into the central config file, order +# concatenate the different files now into the central config file, order # matters - ldap data has highest priority if ! test -f /tmp/cfgcomplete ; then for config in /tmp/confviadhcp /tmp/confviafile /tmp/confvialdap @@ -1120,7 +1133,7 @@ config_portmap () { : } -# start NIS (fixmee - does the service is really named ypbind??) +# start nis/ypbind config_nis () { : } diff --git a/initramfs/initrd-stuff/etc/messages b/initramfs/initrd-stuff/etc/messages index 1eb35d79..a8f203d1 100644 --- a/initramfs/initrd-stuff/etc/messages +++ b/initramfs/initrd-stuff/etc/messages @@ -1,14 +1,20 @@ +# Copyright (c) 2003 - 2006 - RZ Uni Freiburg +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program/file is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your feedback to feedback@openslx.org +# +# General information about OpenSLX can be found under http://openslx.org +# # messages file for all error and info messages generated during client # bootup (within initialramfs) for OpenSLX linux diskless clients version 4 # this file could be used for localization of error messages -# -# Dirk von Suchodoletz , 17-10-2006 -# -# (c) 2006 - RZ Universitaet Freiburg -# (c) 2006 - OpenSLX.ORG Project # messages from (slx) init -init_errmsg="functions file contains a lot of script \ +init_errmsg="The functions file contains a lot of slx scripts \ functionality. Without this\ninit script will not run." init_mff="The main $init_errmsg" init_dff="The distro $init_errmsg" @@ -59,9 +65,9 @@ line\nbut failed. There might be the following reasons for that:\n\ running kernel - see error messages above\n\ * You tried to mount from wrong server or path ($nfsroot)\n\ * No NFS server is running or you do not have permissions" -init_ldcfg="Starting ldconfig - switch it off via kernel cmdline option \ -'noldsc'" -init_errlog="Unable to create the logfile configuration in \ +init_ldcfg=" Starting ldconfig - switch it off via kernel cmdline option \ +'noldsc'.\n You might have to add additional library pathes to ld.so.conf." +init_errlog=" Unable to create the logfile configuration in \ /etc/${D_SYSCONFDIR}. That\n might indicate some severe error." init_fstab="Failed to create /etc/fstab in the clients root filesystem. The\n\ noexistence of the file might produce some unexpected behaviour of\n\ diff --git a/initramfs/initrd-stuff/init b/initramfs/initrd-stuff/init index de879d69..44db70e9 100755 --- a/initramfs/initrd-stuff/init +++ b/initramfs/initrd-stuff/init @@ -22,36 +22,37 @@ # configuration settings (several file and directory variables) . /etc/sysconfig/config || ( echo -e $init_dscf && sleep 100 ) # configuration settings for slx environment -. /etc/sysconfig/slxconfig 2>/dev/null || ( echo -e $init_sscf && \ +. /etc/sysconfig/slxconfig 2>/dev/null || ( echo -e ${init_sscf} && \ sleep 100 ) export PATH=/bin:/sbin:/usr/bin/:/usr/sbin -export date="$slxconf_date" +export date="${slxconf_date}" export DEBUGLEVEL=0 -export KERNEL="$slxconf_kernver" -export NWMODULES="$slxconf_listnwmod" -export DISTRO="$slxconf_distro" +export KERNEL="${slxconf_kernver}" +export NWMODULES="${slxconf_listnwmod}" +export DISTRO="${slxconf_distro}" # do not use dnbd cache file nodnbdcache="yes" # device files get their own filesystem (to be move mounted later) -DEVDIR="/dev" -mount -n -t tmpfs -o 'size=25%,mode=0755' initramfsdevs ${DEVDIR} +devdir="/dev" +mount -n -t tmpfs -o 'size=25%,mode=0755' initramfsdevs ${devdir} # copy basic device files into dev (later udev will handle that) cp -a /tmp/null /tmp/console /dev -mkdir -p ${DEVDIR}/pts -mkdir -p ${DEVDIR}/shm -mkdir -p ${DEVDIR}/.udevdb +mkdir -p ${devdir}/pts +mkdir -p ${devdir}/shm +mkdir -p ${devdir}/.udevdb # mount the important standard directories [ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc [ ! -d /sys/class ] && mount -n -t sysfs sysfs /sys # fixme: shut down if script fails -#trap "exec echo o>/proc/sysrq-trigger" EXIT SIGHUP SIGINT SIGPIPE SIGTERM SIGIO +trap "exec (sleep 30; echo o>/proc/sysrq-trigger)" \ + SIGHUP SIGINT SIGPIPE SIGTERM SIGIO # if no kernel version is set, try to get it directly from /proc if [ -z $KERNEL ] ; then @@ -61,10 +62,10 @@ if [ -z $KERNEL ] ; then fi # set defaults for some important variables, might be overwritten via # kernel commandline -TMPFSSIZE="50%" -COWSIZE="50%" -RWDIR=/dev/shm -NFSRO="nfs" +tmpfssize="50%" +cowsize="50%" +rwdir=/dev/shm +nfsro="nfs" # load usb modules for keyboard (reenable usb keyboards, otherwise the # admin has to wait until second run of hwsetup late in stage3) @@ -137,7 +138,7 @@ in $0\ncountry=\"${COUNTRY}\"" >> /etc/machine-setup ;; # if ld.so.cache should not be generated noldsc) - NOLDSC=yes;; + noldsc=yes;; # additional source to unify root filesystem with union=*) UNIONFS=1 @@ -150,7 +151,7 @@ in $0\ncountry=\"${COUNTRY}\"" >> /etc/machine-setup # combination with classical fs, like ext2 useful cowloop=*) COWLOOP=1 - #COWSIZE=${opts#cowloop=} + #cowsize=${opts#cowloop=} ;; # rootfs will void the variables (d)nbdroot, nfsroot ... # fixme: allow multiple rootfs sources to be unioned!? @@ -201,7 +202,7 @@ nfsroot=\"${nfsroot}\"\n" >> /etc/machine-setup ;; # size of tempfs if not max. 50% of RAM should be used tmpfssize=*) - TMPFSSIZE=${opts#tmpfssize=};; + tmpfssize=${opts#tmpfssize=};; # vendor code identifier for dhcp requests, that way odlx clients could # be distinguished from other (dhcp) clients vci=*) @@ -277,6 +278,7 @@ fi echo "** loading all defined network adaptor modules at $(sysup)" for mod in ${NWMODULES}; do modprobe ${MODPRV} $mod || error "$init_errnwad" + usleep 5 done # set up loopback networking (ipsetup - function defined in /etc/functions) @@ -382,11 +384,11 @@ if [ -n "${nbdmod}" ] ; then UNIONFS=""; fi echo "Using Copy-on-Write block device for rw access" - mount -n -t tmpfs -o size=${COWSIZE} ramfs ${RWDIR} + mount -n -t tmpfs -o size=${cowsize} ramfs ${rwdir} mkdir /dev/cow && cp -a /tmp/ctl /dev/cow usleep 200 ln -s /dev/cowloop0 /dev/cow/0 - cowdev -a /dev/nbd0 ${RWDIR}/nbd.cow + cowdev -a /dev/nbd0 ${rwdir}/nbd.cow usleep 200 RWRO="rw" RDEV=/dev/cow/0 @@ -394,7 +396,7 @@ if [ -n "${nbdmod}" ] ; then ldcfg else # use normal UnionFS behaviour because rootfs is not NFS - NFSRO="" + nfsro="" fi # finally mount the block device for i in 1 50 100 200 400 1000 ; do @@ -403,7 +405,8 @@ if [ -n "${nbdmod}" ] ; then done [ $DEBUGLEVEL -eq 20 ] && echo "** finished nw blockdev stuff at $(sysup)" elif [ -n ${iscsiserver} ] ; then - [ $DEBUGLEVEL -eq 20 ] && echo "** started setting up iSCSI initiator" + [ $DEBUGLEVEL -eq 20 ] && echo "** started setting up iSCSI initiator at \ +$(sysup)" #if [ -n ${iscsitarget} ] ; then # echo "InitiatorName=${iscsitarget}"|sed "s,@@@serverip@@@,$serverip," \ # >/etc/initiatorname.iscsi @@ -430,7 +433,7 @@ if [ -z "${nbdmod}" -a -z "${nbdserver}" ] ; then nfsserver=$(checkip $nfsserver) nfsroot=${nfsserver}:${root_path} nfsmnt ${nfsroot} || error "$init_nfs" - [ $DEBUGLEVEL -eq 20 ] && echo "** finished nfs mount" + [ $DEBUGLEVEL -eq 20 ] && echo "** finished nfs mount at $(sysup)" fi # get the complete collection of kernel modules available @@ -441,7 +444,8 @@ mount -n --bind /mnt/lib/modules/${KERNEL} /lib/modules/${KERNEL} || \ if [ ${DEBUGLEVEL} = 21 ] ; then /bin/sh else - [ $DEBUGLEVEL -eq 20 ] && echo "** started hwautocfg in background" + [ $DEBUGLEVEL -eq 20 ] && echo "** started hwautocfg in background at \ +$(sysup)" hwautocfg & fi @@ -451,18 +455,18 @@ if [ -n "${UNIONFS}" -o -n "${UNION}" ] ; then error "$init_loadufs" nonfatal UNIONFS=""; } fi -echo "Vor Union" + # setup of client root filesystem dependent on the availability of UnionFS if [ -n "${UNIONFS}" ] ; then echo "Using UnionFS for rw access" - mkdir -p ${RWDIR}/union ${RWDIR}/uniontmp /rorootfs - mount -n -t tmpfs none ${RWDIR}/uniontmp + mkdir -p ${rwdir}/union ${rwdir}/uniontmp /rorootfs + mount -n -t tmpfs none ${rwdir}/uniontmp # hack for handling unionfs with patched run-init mount -n --move /mnt /rorootfs - mount -n -t unionfs -o dirs=${RWDIR}/uniontmp:/rorootfs=${NFSRO}ro \ + mount -n -t unionfs -o dirs=${rwdir}/uniontmp:/rorootfs=${nfsro}ro \ none /mnt mkdir -p /mnt/uniontmp - mount -n --move ${RWDIR}/uniontmp /mnt/uniontmp + mount -n --move ${rwdir}/uniontmp /mnt/uniontmp chmod 0755 /mnt/uniontmp /mnt # if additional sources should be used for a combined root filesystem # probably more sources should be merged into union (${UNION} is defined) @@ -473,7 +477,7 @@ if [ -n "${UNIONFS}" ] ; then # mount $dir unionadd/$dir # unionctl mnt --add --after /mnt --mode ro /unionadd/$dir # most probably it is a good idea to run ldconfig, so enable it - unset NOLDSC + unset noldsc fi # run ldconfig if not switched off via kernel command line ldcfg @@ -481,49 +485,50 @@ if [ -n "${UNIONFS}" ] ; then for i in ${D_RCDIRS} ${D_INITBOOTD} ; do rm -f /mnt/etc/$i/* 2>/dev/null done -elif [ -z "$COWLOOP" ] ; then +elif [ -z "${COWLOOP}" ] ; then echo "Using bind mounts to ramdisk for rw access" - mount -n -t tmpfs -o size=${TMPFSSIZE} ramfs ${RWDIR} + mount -n -t tmpfs -o size=${tmpfssize} ramfs ${rwdir} for path in ${D_BINDMPTS} ; do - mkdir -p ${RWDIR}/${path} >/dev/null 2>&1 - mount -n --bind ${RWDIR}/${path} /mnt/${path} + mkdir -p ${rwdir}/${path} >/dev/null 2>&1 + mount -n --bind ${rwdir}/${path} /mnt/${path} [ ${DEBUGLEVEL} -gt 1 -a ${DEBUGLEVEL} != 8 ] && \ - echo "Created ${RWDIR}/${path} and mounted it to /mnt/$path" + echo "Created ${rwdir}/${path} and mounted it to /mnt/$path" done # see above ... ldcfg - # Save the RO Directories mentioned in the distro-specific + # save the RO directories mentioned in the distro-specific # config to a temporary directory. They will lateron be restored for path in ${D_RODIRSINRW}; do if [ -d /mnt/${path} ] ; then - LIST=${path}" "$LIST + list=${path}" "${list} # exclude them from etc copy process too echo ${path}|sed -e "s,/root/,," >>/tmp/etc.exclude mkdir -p /root/${path} >/dev/null 2>&1 mount -n --bind /mnt/${path} /root/${path} >/dev/null 2>&1 fi done - for path in /etc/${D_SYSCONFDIR} ${D_DIRINBINDMNT} ${LIST}; do - mkdir -p ${RWDIR}/${path} + for path in /etc/${D_SYSCONFDIR} ${D_DIRINBINDMNT} ${list}; do + mkdir -p ${rwdir}/${path} done - testmkd ${RWDIR}/var/tmp - chmod a+rwxt ${RWDIR}/var/tmp >/dev/null 2>&1 + testmkd ${rwdir}/var/tmp + chmod a+rwxt ${rwdir}/var/tmp >/dev/null 2>&1 # exclude all sysv runlevel link stuff for i in ${D_RCDIRS} ${D_INITBOOTD} ; do echo "*$i/*" >>/tmp/etc.exclude done + # add list of files to be excluded and common excludes to the filter list echo -e "${D_ETCEXCL}\n@@@COMETCEXCL@@@" >>/tmp/etc.exclude # if ld.so.cache is to be generated then do not copy the file - [ -z "${NOLDSC}" ] && echo -e "ld.so.cache*" >>/tmp/etc.exclude + [ -z "${noldsc}" ] && echo -e "ld.so.cache*" >>/tmp/etc.exclude # for tar exclude lists might be used, more difficult for cp cd /mnt tar -X /tmp/etc.exclude -cp etc/* | \ - tar -xp -C ${RWDIR} 2>/dev/null ; + tar -xp -C ${rwdir} 2>/dev/null ; cd / - mount -n --bind ${RWDIR}/etc /mnt/etc - mount -n --bind ${RWDIR}/var /mnt/var + mount -n --bind ${rwdir}/etc /mnt/etc + mount -n --bind ${rwdir}/var /mnt/var # get the "covered" mounts back into filesystem structure - for i in ${LIST}; do + for i in ${list}; do mount -n --move /root/$i /mnt/$i #>>$LOGFILE 2>&1 done #rm -rf /root/* >/dev/null 2>&1 @@ -532,7 +537,6 @@ fi # script for stuff to execute during early bootup d_mkrlscript init boot.ld "Running configuration postponed from InitRamFS" echo "fs complete at $(sysup)" >/tmp/fscmpl -echo "FS complete" # write debug file information after filesystem setup completed echo -e "# /etc${D_SYSCONFDIR}/logfile - file created by $0 (initramfs \ @@ -542,7 +546,7 @@ for linux diskless client specific debugging output\nLOGFILE=\"$LOGFILE\"\n#\ > /mnt/etc/${D_SYSCONFDIR}/logfile || error "$init_errlog" # run distribution independent and dependent configuration of files and -# services +# services (offer debug shell in runlevel 22) if [ ${DEBUGLEVEL} = 22 ] ; then /bin/sh else @@ -572,7 +576,7 @@ echo -e "rootfs / rootfs rw 0 0\ninitramdevs /dev tmpfs rw\ 0 0" > /mnt/etc/mtab # copy library cache if generated -if [ -z "${NOLDSC}" ] ; then +if [ -z "${noldsc}" ] ; then if waitfor /tmp/ldcfg 50000 ; then test -s /mnt/tmp/ld.so.cache && { cp /mnt/tmp/ld.so.cache /mnt/etc/ld.so.cache @@ -589,9 +593,9 @@ waitfor /tmp/hwcfg 30000 || error "$init_errhw" >> /mnt/etc/udev/rules.d/04-scanner.rules # wait a while for services setup to complete waitfor /tmp/svcfg 20000 || error "$init_errsw" -# IP configuration is made and should not be updated automatically, udevd -# should be killed if started within init +# IP configuration is complete and should not be updated automatically killall -9 dhcpcd dhclient pump udhcpc 2>/dev/null +# copy machine configuration file into stage4 filesystem cp /etc/machine-setup /mnt/etc # post init for some distro specific (fixme!! more elegant solution) @@ -613,7 +617,7 @@ for i in 0 200 300 500 800 1000 1200 2000 5000 ; do done [ $i -gt 1000 ] && error "$init_errumnt" -# check for inittab file +# check for inittab file (might fail for new style init -> upstart) test -f /mnt/etc/inittab || error "$init_erritab" # close runlevel script for stuff to execute during early bootup d_mkrlscript close boot.ld "" @@ -623,18 +627,20 @@ sed -n "s,/mnt,,;/\/tmp /p" /proc/mounts >> /mnt/etc/mtab # preparations to leave initramfs - umounting ... umount -n /sys || error "$init_errsys" nonfatal umount -n /proc/bus/usb >/dev/null 2>&1 -mount -n --move /dev /mnt/dev chmod a+rwxt /mnt/dev/shm /mnt/tmp /mnt/tmp/scratch 2>/dev/null +mount -n --move /dev /mnt/dev +# stop udevd (non-busybox udevs) killall -9 udevd 2>/mnt/dev/null # runtimer -[ $DEBUGLEVEL -eq 8 ] && echo "** SLX init ended near $(sysup)" +[ $DEBUGLEVEL -eq 8 -o $DEBUGLEVEL -eq 20 ] && \ + echo "** SLX init ended near $(sysup)" # kill the watchdog (autopoweroff, if stage3 init never finishes) [ -f /tmp/watchdogpid ] && kill $(cat /tmp/watchdogpid) 2>/mnt/dev/null umount -n /proc # unset old environment variables unset debug date initrd ip dnbdroot nbdroot nfsroot vci vga unset BOOT_IMAGE KCMDLINE KERNEL MODPRV NWMODULES OLDPWD UDEVD_EVENT_TIMEOUT \ - UDEVD_EXPECTED_SEQNUM + UDEVD_EXPECTED_SEQNUM PATH # new style of pivoting (switch_root or run-init in klibc) -exec switch_root -c dev/console /mnt /sbin/init || error "$init_runinit" +exec /bin/switch_root -c dev/console /mnt /sbin/init || error "$init_runinit" -- cgit v1.2.3-55-g7522