diff options
author | Simon Rettberg | 2013-06-05 18:41:10 +0200 |
---|---|---|
committer | Simon Rettberg | 2013-06-05 18:41:10 +0200 |
commit | d8f50c155f281be06cfa3e38269c01f4086db95e (patch) | |
tree | ba5db09b58e37826cfd21f4682fefd191716f0f8 | |
parent | Merge branch 'master' of simonslx:openslx-ng/tm-scripts (diff) | |
download | tm-scripts-d8f50c155f281be06cfa3e38269c01f4086db95e.tar.gz tm-scripts-d8f50c155f281be06cfa3e38269c01f4086db95e.tar.xz tm-scripts-d8f50c155f281be06cfa3e38269c01f4086db95e.zip |
[setup_network] Rename vars
[setup_network] Change MAC of eth0 after building bridge
[init] Optional message can be passed to drop_shell
[kernel] Disable IP autoconfig
-rw-r--r-- | data/kernel.wanted.config | 1 | ||||
-rwxr-xr-x | remote/rootfs/rootfs-stage31/data/bin/setup_network | 21 | ||||
-rwxr-xr-x | remote/rootfs/rootfs-stage31/data/init | 20 | ||||
-rwxr-xr-x | remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script | 2 | ||||
-rw-r--r-- | remote/rootfs/rootfs-stage32/rootfs-stage32.conf.zypper | 1 |
5 files changed, 27 insertions, 18 deletions
diff --git a/data/kernel.wanted.config b/data/kernel.wanted.config index 80367038..31f602b5 100644 --- a/data/kernel.wanted.config +++ b/data/kernel.wanted.config @@ -230,3 +230,4 @@ CONFIG_VXGE=y CONFIG_WINBOND_840=y CONFIG_XFS_FS=y CONFIG_ZNET=y +CONFIG_IP_PNP=n diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_network b/remote/rootfs/rootfs-stage31/data/bin/setup_network index f9ff1bd1..57872244 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_network +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_network @@ -11,16 +11,19 @@ ip addr add 127.0.0.1/8 dev lo 2>/dev/null echo "Setting up bridge" BRIDGE="br0" -BRNWIF="eth0" -NWIFMAC="${MAC}" +SLAVE="eth0" +BRIDGEMAC="$MAC" -# bridge 0 already defined or some other problem -brctl addbr "$BRIDGE" +# Flip mac address of original interface - this var is not local so init sees the changes too +MAC="$(echo "$MAC" | awk -F ':' '{printf $1 ":" $2 ":" $5 ":" $3 ":" $6 ":" $4}')" +ip link set addr "$MAC" "$SLAVE" + +brctl addbr "$BRIDGE" || drop_shell "Could not create bridge $BRIDGE" brctl stp "$BRIDGE" 0 brctl setfd "$BRIDGE" 0.000000000001 -ip link set addr "$NWIFMAC" "$BRIDGE" -ip link set dev "$BRNWIF" up -brctl addif "$BRIDGE" "$BRNWIF" +ip link set addr "$BRIDGEMAC" "$BRIDGE" || drop_shell "Could not set mac of $BRIDGE" +ip link set dev "$SLAVE" up +brctl addif "$BRIDGE" "$SLAVE" || drop_shell "Could not add $SLAVE to $BRIDGE" # analyze ip information from the kernel command line and put parts # of it into several variables @@ -41,10 +44,10 @@ if [ -n "$IPINFO" ] ; then # we might have an idea of the dns server via preboot DNS_SERVER="$(getip 5)" # set static ip address - ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" \ - broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE" + ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE" ip link set dev "$BRIDGE" up ip route add default via "$GATEWAY" dev "$BRIDGE" else NOIPYET="yes" fi + diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index 06610542..ee90cf15 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -14,6 +14,7 @@ # debug shell drop_shell() { + [ $# -gt 0 ] && echo $@ echo "Dropping debug shell. CTRL + D will continue booting." setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1' } @@ -85,24 +86,27 @@ echo "Setup networking..." # Source script so the variables are still available if [ -n "$NFS" ]; then # mount stage32 per NFS if activated 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; } + mount -t nfs -o ro,async,nolock ${NFSSERVER}:${NFSPATH} /rorootfs || drop_shell "Problem mounting NFS-Directory from ${NFSSERVER}:${NFSPATH}." else # or per squashfs else echo "Mounting stage 3.2 as SquashFS..." - mount -t squashfs /mnt/*.sqfs /rorootfs || { echo "Problem mounting Squashfs."; drop_shell; } + mount -t squashfs /mnt/*.sqfs /rorootfs || drop_shell "Problem mounting Squashfs." fi -[ $DEBUG -ge 1 ] && drop_shell +[ $DEBUG -ge 1 ] && drop_shell "Requested Debug Shell." echo "Building aufs..." mv /mnt/modprobing /dev/shm/uniontmp #mount -t overlayfs -o lowerdir=/rorootfs,upperdir=/dev/shm/uniontmp overlayfs /mnt -mount -n -t aufs -o br:/dev/shm/uniontmp:/rorootfs=ro none /mnt || { echo "Problem building aufs."; drop_shell; } +mount -n -t aufs -o br:/dev/shm/uniontmp:/rorootfs=ro none /mnt || drop_shell "Problem building aufs." mkdir -p /mnt/uniontmp /mnt/tmp -mount -n --move /dev/shm/uniontmp /mnt/uniontmp || { echo "Problem moving uniontmp."; drop_shell; } +mount -n --move /dev/shm/uniontmp /mnt/uniontmp || drop_shell "Problem moving uniontmp." # create udev rule for nic we booted from -echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$MAC'", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"' > "/mnt/etc/udev/rules.d/70-net-boot-nic-name.rules" +cat > "/mnt/etc/udev/rules.d/70-net-boot-nic-name.rules" <<HEREEND +SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="$MAC", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" +SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="$BRIDGEMAC", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="br0" +HEREEND # create ip config cat >> /mnt/opt/openslx/config <<HEREEND @@ -111,11 +115,11 @@ SLX_PXE_CLIENT_IP='$CLIENTIP' SLX_PXE_SERVER_IP='$SERVERIP' SLX_PXE_GATEWAY='$GATEWAY' SLX_PXE_DNS='$DNS_SERVER' -SLX_PXE_MAC='$MAC' +SLX_PXE_MAC='$BRIDGEMAC' HEREEND for mnt in proc sys run ; do - umount -n $mnt + umount -n "$mnt" done echo "Switching root...." diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script index 83877adb..1cfd3036 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script @@ -22,7 +22,7 @@ IP_CONF="/tmp/udhcpc_ip_config" export PATH=$PATH:/opt/openslx/sbin:/opt/openslx/bin -echo "$interface -> $ip" >> "/tmp/udhcpclog" +echo "$interface [$1] $ip" >> "/tmp/udhcpclog" case $1 in bound|renew) diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.zypper b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.zypper index 4d44e2d6..af6f2546 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.zypper +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf.zypper @@ -1,6 +1,7 @@ REQUIRED_MODULES=" kernel" REQUIRED_INSTALLED_PACKAGES="nfs-client xfsprogs squashfs timezone" REQUIRED_CONTENT_PACKAGES="timezone" +REQUIRED_DIRECTORIES="/usr/lib/xtables" REQUIRED_LIBRARIES=" libcap libcidn libcom_err |