summaryrefslogtreecommitdiffstats
path: root/remote
diff options
context:
space:
mode:
authorJonathan Bauer2013-05-23 19:14:59 +0200
committerJonathan Bauer2013-05-23 19:14:59 +0200
commit5b1ad8d4699ca08f1e03a3dc516a6c0b21f6088d (patch)
treec3307f27de454c234c1a57bfcf0fa4ddbe6eda4a /remote
parentMerge branch 'master' of git:openslx-ng/tm-scripts (diff)
downloadtm-scripts-5b1ad8d4699ca08f1e03a3dc516a6c0b21f6088d.tar.gz
tm-scripts-5b1ad8d4699ca08f1e03a3dc516a6c0b21f6088d.tar.xz
tm-scripts-5b1ad8d4699ca08f1e03a3dc516a6c0b21f6088d.zip
split network setup in stage31/init
Diffstat (limited to 'remote')
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/bin/setup_network42
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/init97
2 files changed, 75 insertions, 64 deletions
diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_network b/remote/rootfs/rootfs-stage31/data/bin/setup_network
new file mode 100755
index 00000000..32c1d5ef
--- /dev/null
+++ b/remote/rootfs/rootfs-stage31/data/bin/setup_network
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+echo "Mac address is '$MAC'"
+
+# setup network
+NWIF="eth0"
+# set up loopback networking
+echo "Setting up loopback"
+ip link set dev lo up 2>/dev/null
+ip addr add 127.0.0.1/8 dev lo 2>/dev/null
+echo "Setting up $NWIF"
+ip link set dev $NWIF up 2>/dev/null || { echo "No link for $NWIF, dropping to shell.."; setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'; }
+
+# 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
diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init
index 9bda6db1..0cb341cf 100755
--- a/remote/rootfs/rootfs-stage31/data/init
+++ b/remote/rootfs/rootfs-stage31/data/init
@@ -12,20 +12,25 @@
# First script for initial ramfs for OpenSLX linux stateless clients
#############################################################################
+# debug shell
+drop_shell() {
+ echo "Dropping debug shell. CTRL + D will continue booting."
+ setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
+}
+
+# set PATH correctly
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export LD_LIBRARY_PATH=/usr/lib64
-
-mount -n -t tmpfs -o 'mode=755' run "/run"
-
# mount the important standard directories
+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
-echo "1" > /proc/sys/kernel/sysrq
+# let kernel know that mdev is to be used for hotplug
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
-# read graphic and network adaptor configuration (without proprietary drivers yet)
+# read graphic and network adaptor configuration (without proprietary drivers yet)
# TODO: must ugly hack ever... needs to be improved when we add prop drivers
for DRM in /lib/modules/*/kernel/drivers/gpu/drm/*.ko /lib/modules/*/kernel/drivers/gpu/drm/*/*.ko; do
DRM="$(basename "$DRM")"
@@ -34,6 +39,9 @@ for DRM in /lib/modules/*/kernel/drivers/gpu/drm/*.ko /lib/modules/*/kernel/driv
modprobe "$DRM"
done
+# discover devices
+mdev -s &
+
# read kernel command line for debugging switch
DEBUG=0
read KCL < /proc/cmdline
@@ -46,82 +54,43 @@ for opts in ${KCL}; do
SPLASH=1 ;;
ip=*)
# process IP info
- ipinfo=${opts#ip=} ;;
+ IPINFO=${opts#ip=} ;;
nfs=*)
- nfs=${opts#nfs=}
- nfspath=${nfs#*:}
- nfsserver=${nfs%:/*}
+ NFS=${opts#nfs=}
+ NFSPATH=${nfs#*:}
+ NFSSERVER=${nfs%:/*}
;;
BOOTIF=*)
- macaddr="$( echo "$opts" | cut -b 11- | tr '-' ':' )" ;;
+ MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' )" ;;
esac
done
-echo "Mac address is '$macaddr'"
-
-mdev -s &
+# suppress kernel output if DEBUG is not set
+[ $DEBUG -ge 1 ] && echo "0" >/proc/sys/kernel/printk
+# start plymouth if activated
if [ "x$SPLASH" == "x1" -a "x$DEBUG" != "x1" ]; then
- # start plymouth
+ echo "Starting plymouth..."
plymouthd && plymouth show-splash
fi
-# setup network
-nwif="eth0"
-# set up loopback networking
-echo "Setting up loopback"
-ip link set dev lo up 2>/dev/null
-ip addr add 127.0.0.1/8 dev lo 2>/dev/null
-echo "Setting up $nwif"
-ip link set dev $nwif up 2>/dev/null || { echo "No link for $nwif, dropping to shell.."; setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'; }
-
-# 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
-
+# preparations for mounting stage3.2
mkdir -p /dev/shm/union /dev/shm/uniontmp /rorootfs
mount -n -t tmpfs none /dev/shm/uniontmp
-if [ -n "$nfs" ] ; then
- echo "Mounting stage 3.2 as NFS"
- mount -t nfs -o ro,async,nolock ${nfsserver}:${nfspath} /rorootfs || { echo "Problem mounting NFS-Directory from ${nfsserver}:${nfspath}. Dropping to DEBUG shell."; DEBUG=1; }
+# mount stage32 per NFS if activated
+# or per squashfs else
+if [ -n "$NFS" ]; then
+ echo "Setup networking..."
+ /bin/setup_network
+ echo "Mounting stage 3.2 as NFS..."
+ mount -t nfs -o ro,async,nolock ${NFSSERVER}:${NFSPATH} /rorootfs || { echo "Problem mounting NFS-Directory from ${NFSSERVER}:${NFSPATH}."; drop_shell; }
else
- echo "Mounting stage 3.2 as SquashFS"
- mount -t squashfs /mnt/*.sqfs /rorootfs || { echo "Problem mounting Squashfs. Dropping to DEBUG shell."; DEBUG=1; }
+ echo "Mounting stage 3.2 as SquashFS..."
+ mount -t squashfs /mnt/*.sqfs /rorootfs || { echo "Problem mounting Squashfs."; drop_shell; }
fi
-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'
-else
- #Debug is not set so hide kernel debug output
- echo "0" >/proc/sys/kernel/printk
-fi
+[ $DEBUG -ge 1 ] && drop_shell
echo "Building aufs..."
mv /mnt/modprobing /dev/shm/uniontmp