From 9078927b395db1bc0259a03fd7e105fc306ca526 Mon Sep 17 00:00:00 2001 From: Dirk von Suchodoletz Date: Fri, 3 Aug 2007 13:06:49 +0000 Subject: Further on ... (see r1308, #153) git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1309 95ad53e4-c205-0410-b2fa-d234c58c8868 --- initramfs/cdboot/init | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++ initramfs/mkdxsinitrd | 46 +++++++++--------- 2 files changed, 151 insertions(+), 24 deletions(-) create mode 100755 initramfs/cdboot/init diff --git a/initramfs/cdboot/init b/initramfs/cdboot/init new file mode 100755 index 00000000..8a93d052 --- /dev/null +++ b/initramfs/cdboot/init @@ -0,0 +1,129 @@ +#!/bin/sh +# Copyright (c) 2003 - 2006 - RZ Uni Freiburg +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program 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 at http://openslx.org +# +# Main script for new type of initial ramdisk for OpenSLX linux stateless +# clients version 4 + +############################################################################# +# device files get their own filesystem (to be move mounted later) +devdir="/dev" +mount -n -t tmpfs -o 'size=25%,mode=0755' initramfsdevs ${devdir} + +# create basic device files an directories in dev (for most hardware related +# devices mdev should handle that) +for i in "/dev/mem c 1 1" "/dev/null c 1 3" "/dev/zero c 1 5" \ + "/dev/urandom c 1 9" "/dev/kmsg c 1 11" "/dev/tty0 c 4 0" \ + "/dev/tty1 c 4 1" "/dev/tty2 c 4 2" "/dev/tty3 c 4 3" \ + "/dev/tty4 c 4 4" "/dev/tty5 c 4 5" "/dev/tty6 c 4 6" \ + "/dev/tty7 c 4 7" "/dev/tty8 c 4 8" "/dev/tty9 c 4 9" \ + "/dev/tty10 c 4 10" "/dev/tty c 5 0" "/dev/console c 5 1" \ + "/dev/ptmx c 5 2" "/dev/psaux c 10 1" "/dev/agpgart c 10 175" \ + "/dev/fb0 c 29 0" "/dev/bootsplash p" "/dev/xconsole p"; do + mknod $i +done +mkdir -p ${devdir}/pts ${devdir}/shm ${devdir}/.udevdb ${devdir}/.udev + +# source functions file common for all distros, messages contains all error +# and info output (for some reason the error output is not produced properly +# - crash) + +# initramfs-setup configuration (common settings for all clients using a +# certain InitRamFS generated by slxmkramfs/mkdxsinitrd) +[ -f /etc/initramfs-setup ] && . /etc/initramfs-setup 2>/dev/null + +export PATH=/bin:/sbin:/usr/bin/:/usr/sbin + +export DEBUGLEVEL=0 +export KERNEL="${slxconf_kernver}" +export NWMODULES="${slxconf_listnwmod}" + +# set a default LAN interface, might be modified for WLAN or on machines with +# more than one ethernet card built in +nwif="eth0" + +# mount the important standard directories +[ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc +[ ! -d /sys/class ] && mount -n -t sysfs sysfs /sys + +# keep quiet +#echo "0 0 0 0" >/proc/sys/kernel/printk + +# fixme: shut down if script fails +trap "exec (sleep 30; echo o>/proc/sysrq-trigger)" \ + SIGHUP SIGINT SIGPIPE SIGTERM + +# if no kernel version is set, try to get it directly from /proc +if [ -z $KERNEL ] ; then + KERNEL=$(cat /proc/version) + KERNEL=${KERNEL#*version } + KERNEL=${KERNEL% (*) (*} +fi + +# load network adaptor modules +for mod in ${NWMODULES}; do + modprobe ${MODPRV} $mod || echo "module $mod did not load for some reason" + usleep 10000 +done + +# read kernel commandline +read KCMDLINE < /proc/cmdline +export KCMDLINE +# read the system wide machine-setup and then the kernel commandline +for opts in $(sed "s/#.*//" /etc/initramfs-setup) ${KCMDLINE} ; do + case ${opts} in + debug) + DEBUGLEVEL=1;; + # ... or a specified debug level + esac +done +# at this point a timer should be started to ensure an automated reboot +# or halt of the machine if SLX init does not succeed (e.g. missing kernel +# module for the network adaptor) +if [ ${DEBUGLEVEL} -lt 3 -o ${DEBUGLEVEL} = 8 ] ; then + cat< /bin/watchdog +#!/bin/ash +echo \$$ > /tmp/watchdogpid +[ ! -f /proc/version ] && mount -n -t proc proc /proc +. /etc/functions +sleep 120 2> /dev/null +echo "o" > /proc/sysrq-trigger +EOF + chmod u+x /bin/watchdog + watchdog & +fi + +if [ -n "${essid}" ] ; then + # WLAN setup will most probably change the network interface name stored in + # nwif (to wlan0 or something like that) + : +else + # check here for the active ethernet link + ip link show dev eth1 >/dev/null 2>&1 && error "$init_2eif" nonfatal +fi + +# set up loopback networking +[ $DEBUGLEVEL -eq 20 ] && echo "** starting ip config at $(sysup)" +ip link set dev lo up +ip addr add 127.0.0.1/8 dev lo +ip link set dev $nwif up || echo "noeth" + +# start udhcpc here + +[ -f /tmp/confviadhcp ] && . /tmp/confviadhcp + [ -z "$clientip" -o -z "$subnet_mask" -o -z "$gateway" \ + -o -z "$broadcast_address" ] && error "$init_errdhcp" + ip addr add $clientip/$(nm2pref $subnet_mask) broadcast $broadcast_address \ + dev $nwif + ip route add default via $gateway + +# start the new kernel with initialramfs and cmdline +#kexec diff --git a/initramfs/mkdxsinitrd b/initramfs/mkdxsinitrd index d30bd9a6..171b8ba6 100755 --- a/initramfs/mkdxsinitrd +++ b/initramfs/mkdxsinitrd @@ -336,7 +336,7 @@ while getopts :Cdhk:c:i:r:o:s:f:n:m:S:tu:wI:a: a ; do esac exit 1 ;; - c) cdboot=1;; + C) cdboot=1;; c) CLCONFFILE=$OPTARG;; d) use_dhclient=1;; k) KERNVER=$OPTARG;; @@ -505,6 +505,9 @@ if [ -z "$cdboot" ] ; then debian*) cp ${ROOTDIR}/lib/libnss_compat.so.2 ${INSTDIR}/lib;; esac + # add libpci.so to the libraries, as we are going to copy it manually: + slxldd --root-path=${ROOTDIR} ${SLX_SHARE_PATH}/initramfs/lib/libpci.so.2 \ + >>${INSTDIR}/tmp/libraries else # fast kernel switch tool cobi kexec bin @@ -515,10 +518,6 @@ if [ -n "${enable_wlan}" ] ; then cobi iwconfig bin fi -# add libpci.so to the libraries, as we are going to copy it manually: -slxldd --root-path=${ROOTDIR} ${SLX_SHARE_PATH}/initramfs/lib/libpci.so.2 \ - >>${INSTDIR}/tmp/libraries - # now copy all libraries that have been determined to be required: # first we handle all 64-bit libs... for lib in $(fgrep /lib64/ ${INSTDIR}/tmp/libraries 2>/dev/null|sort -u); do @@ -659,6 +658,24 @@ if [ -z "$cdboot" ] ; then test -f ${SLX_PRIVATE_PATH}/config/$cfg && \ cp ${SLX_PRIVATE_PATH}/config/$cfg ${INSTDIR}/bin done + # custom hardware configuration files pcitable.local and Cards.local + # fixme!! New source for these files (instead of templates)! + if [ -f ${SLX_SHARE_PATH}/templates/pcitable.local ] ; then + cat ${SLX_SHARE_PATH}/templates/pcitable.local > \ + ${INSTDIR}/usr/share/hwdata/pcitable.new + cat ${INSTDIR}/usr/share/hwdata/pcitable >>\ + ${INSTDIR}/usr/share/hwdata/pcitable.new + mv ${INSTDIR}/usr/share/hwdata/pcitable.new \ + ${INSTDIR}/usr/share/hwdata/pcitable + fi + if [ -f ${SLX_SHARE_PATH}/templates/Cards.local ] ; then + cat ${SLX_SHARE_PATH}/templates/Cards.local > \ + ${INSTDIR}/usr/share/hwdata/Cards.new + cat ${INSTDIR}/usr/share/hwdata/Cards >>\ + ${INSTDIR}/usr/share/hwdata/Cards.new + mv ${INSTDIR}/usr/share/hwdata/Cards.new \ + ${INSTDIR}/usr/share/hwdata/Cards + fi else # just copy the several ethernet drivers mkdir -p ${INSTDIR}/lib/modules/${KERNVER}/kernel/drivers/net @@ -685,25 +702,6 @@ if [ -n "${CLCONFFILE}" ] ; then fi echo "## end of common initramfs-setup" >>${INSTDIR}/etc/initramfs-setup -# custom hardware configuration files pcitable.local and Cards.local -# fixme!! New source for these files (instead of templates)! -if [ -f ${SLX_SHARE_PATH}/templates/pcitable.local ] ; then - cat ${SLX_SHARE_PATH}/templates/pcitable.local > \ - ${INSTDIR}/usr/share/hwdata/pcitable.new - cat ${INSTDIR}/usr/share/hwdata/pcitable >>\ - ${INSTDIR}/usr/share/hwdata/pcitable.new - mv ${INSTDIR}/usr/share/hwdata/pcitable.new \ - ${INSTDIR}/usr/share/hwdata/pcitable -fi -if [ -f ${SLX_SHARE_PATH}/templates/Cards.local ] ; then - cat ${SLX_SHARE_PATH}/templates/Cards.local > \ - ${INSTDIR}/usr/share/hwdata/Cards.new - cat ${INSTDIR}/usr/share/hwdata/Cards >>\ - ${INSTDIR}/usr/share/hwdata/Cards.new - mv ${INSTDIR}/usr/share/hwdata/Cards.new \ - ${INSTDIR}/usr/share/hwdata/Cards -fi - ######################################################################### # End of file copy procedures -- cgit v1.2.3-55-g7522