summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorJonathan Bauer2013-02-20 16:06:02 +0100
committerJonathan Bauer2013-02-20 16:06:02 +0100
commitfb2460902baad0a35f76d54c54a00c3a27353f04 (patch)
tree3a2fe2fecd1405bb850ddb96bcc10bab184b3447 /data
parentfunctions common (diff)
downloadtm-scripts-fb2460902baad0a35f76d54c54a00c3a27353f04.tar.gz
tm-scripts-fb2460902baad0a35f76d54c54a00c3a27353f04.tar.xz
tm-scripts-fb2460902baad0a35f76d54c54a00c3a27353f04.zip
init auto ip config
Diffstat (limited to 'data')
-rwxr-xr-xdata/stage3.1/init70
1 files changed, 63 insertions, 7 deletions
diff --git a/data/stage3.1/init b/data/stage3.1/init
index 15b6c947..0db7597e 100755
--- a/data/stage3.1/init
+++ b/data/stage3.1/init
@@ -20,14 +20,66 @@ mount -n -t tmpfs -o 'mode=755' run "/run"
[ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc
[ ! -d /sys/class ] && mount -n -t sysfs sysfs /sys
-#modprobe -a squashfs aufs 2>/dev/null
-insmod /lib/modules/aufs.ko
-insmod /lib/modules/squashfs.ko
+# read kernel command line for debugging switch
+read KCL < /proc/cmdline
+export KCL
+for opts in ${KCL}; do
+ case ${opts} in
+ debug)
+ DEBUG=1;;
+ ip=*)
+ # process IP info
+ ipinfo=${opts#ip=};;
+ esac
+done
+
+
+modprobe usbhid
+modprobe pcnet32
+nwif="eth0"
+
+# set up loopback networking
+[ $DEBUGLEVEL -eq 20 ] && echo "** starting ip config at $(sysup)"
+ip link set dev lo up 2>/dev/null
+ip addr add 127.0.0.1/8 dev lo 2>/dev/null
+ip link set dev $nwif up 2>/dev/null || error "$init_noeth"
+
+# analyze ip information from the kernel command line and put parts
+# of it into several variables
+if [ -n "$ipinfo" ] ; then
+ getip () {
+ local val="$ipinfo:"; i=$(($1 - 1));
+ while [ $i -gt 0 ] ; do
+ val=${val#*:} ; i=$(($i - 1));
+ done;
+ echo $val|sed "s/:.*//"; }
+ clientip=$(getip 1)
+ serverip=$(getip 2)
+ gateway=$(getip 3)
+ subnet_mask=$(getip 4)
+ broadcast_address=$(ipcalc -s -b $clientip $subnet_mask|sed s/.*=//)
+ [ -z "$broadcast_address" ] && broadcast_address=255.255.255.255
+ # we might have an idea of the dns server via preboot
+ dns_srv=$(getip 5)
+ [ -n "$dns_srv" ] && echo nameserver $dns_srv >/etc/resolv.conf;
+ echo -e "# ip configuration written by $0 script:\nclientip=$clientip\n\
+subnet_mask=$subnet_mask\ngateway=$gateway\nserverip=$serverip\n\
+broadcast_address=$broadcast_address" >>/etc/initramfs-setup
+ # set static ip address
+ ip addr add $clientip/$(ipcalc -s -p $clientip $subnet_mask|sed s/.*=//) \
+ broadcast $broadcast_address dev $nwif 2>/dev/null
+ ip route add default via $gateway 2>/dev/null
+else
+ noipyet="yes"
+fi
+
+for MOD in aufs squashfs sunrpc lockd fscache auth_rpcgss nfs_acl nfs; do
+ insmod /lib/modules/${MOD}.ko
+done
mkdir -p /dev/shm/union /dev/shm/uniontmp /rorootfs
mount -n /mnt/openslx.sqfs /rorootfs
-
mount -n -t tmpfs none /dev/shm/uniontmp
mount -n -t aufs -o br:/dev/shm/uniontmp:/rorootfs=ro none /mnt
@@ -35,13 +87,17 @@ mkdir -p /mnt/uniontmp
mount -n --move /dev/shm/uniontmp /mnt/uniontmp
+
+
+if [ $DEBUG -ge 1 ]; then
+ echo "Starting debug shell, CTRL + D will start Stage 3.2."
+ setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
+fi
+
for mnt in proc sys run ; do
- #mount -n --move $mnt /mnt/$mnt
umount -n $mnt
done
-#/bin/sh
unset BOOT_IMAGE initrd
# new style of pivoting (switch_root or run-init)
exec /sbin/switch_root -c /dev/console /mnt /usr/lib/systemd/systemd
-setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'