From 102beba757a8ab12a79d457070fdbae93bc78ca2 Mon Sep 17 00:00:00 2001 From: Dirk von Suchodoletz Date: Fri, 3 Aug 2007 22:54:34 +0000 Subject: Raw concept of cd-demo initramfs generation and init script are done, see comments in #153 ... git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1316 95ad53e4-c205-0410-b2fa-d234c58c8868 --- initramfs/cdboot/init | 62 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 16 deletions(-) (limited to 'initramfs') diff --git a/initramfs/cdboot/init b/initramfs/cdboot/init index eb95c8fe..fbd7bdbf 100755 --- a/initramfs/cdboot/init +++ b/initramfs/cdboot/init @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/ash # Copyright (c) 2007 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. @@ -9,8 +9,29 @@ # # 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 +# Main script for cd-boot demo initial ramdisk - preloading environment for +# for running OpenSLX linux stateless clients version 4 for testing + +############################################################################# +# compute prefix bit number from netmask +nm2pref () { +set $(IFS="."; echo $1) +local n=0 +local i + for i in $1 $2 $3 $4 ; do + case $i in + 0) break ;; + 128) n=$(($n + 1)) ; break ;; + 192) n=$(($n + 2)) ; break ;; + 224) n=$(($n + 3)) ; break ;; + 240) n=$(($n + 4)) ; break ;; + 252) n=$(($n + 6)) ; break ;; + 254) n=$(($n + 7)) ; break ;; + 255) n=$(($n + 8)) ; continue ;; + esac + done +echo $n +} ############################################################################# # device files get their own filesystem (to be move mounted later) @@ -42,8 +63,8 @@ mkdir -p ${devdir}/pts ${devdir}/shm ${devdir}/.udevdb ${devdir}/.udev export PATH=/bin:/sbin:/usr/bin/:/usr/sbin export DEBUGLEVEL=0 -export KERNEL="${slxconf_kernver}" -export NWMODULES="${slxconf_listnwmod}" +export KERNEL="${ramfs_kernver}" +export NWMODULES="${ramfs_nicmods}" # set a default LAN interface, might be modified for WLAN or on machines with # more than one ethernet card built in @@ -87,12 +108,11 @@ 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 +if [ "${DEBUGLEVEL}" -gt 0 ] ; 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 @@ -109,23 +129,33 @@ else ip link show dev eth1 >/dev/null 2>&1 && echo "more than one nw if found" fi -# set up loopback networking -[ $DEBUGLEVEL -eq 20 ] && echo "** starting ip config at $(sysup)" +# set up loopback networking and power up ethernet 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 +mkdir -p /usr/share/udhcpc +echo -e '#!/bin/ash\nunset infomsg HOME IFS mask lease interface DEBUGLEVEL\n +set >/tmp/ipstuff' >/usr/share/udhcpc/default.script +chmod u+x /usr/share/udhcpc/default.script [ -f /lib/modules/@@@KERNVER@@@/kernel/net/packet/af_packet.ko ] && \ modprobe -q af_packet [ -n $vci ] && vci="-V $vci" -udhcpc -b -q $vci -i $nwif 2>/dev/null +udhcpc -b -q $vci -s /usr/share/udhcpc/default.script -i $nwif #2>/dev/null +. /tmp/ipstuff || echo "no ip config" +ip addr add $ip/$(nm2pref $subnet) dev $nwif +ip route add default via $router + +# at this point a little selection script could be downloaded, which lets the +# user choose what kind of SLX client he wants to get -[ -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 +# get kernel and initramfs +wget -c -O /tmp/kernel http://132.230.4.73/trac/kdefault +wget -c -O /tmp/iramfs http://132.230.4.73/trac/idefault +/bin/ash # start the new kernel with initialramfs and cmdline -#kexec +kexec -l /tmp/kernel --initrd=/tmp/iramfs --append="ip=$ip:$siaddr:$router:$subnet\ + file=http://132.230.4.73/trac/default.tgz debug=3" +kexec -e -- cgit v1.2.3-55-g7522