diff options
Diffstat (limited to 'core/rootfs/rootfs-stage31/data/inc/setup_network')
-rw-r--r-- | core/rootfs/rootfs-stage31/data/inc/setup_network | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/core/rootfs/rootfs-stage31/data/inc/setup_network b/core/rootfs/rootfs-stage31/data/inc/setup_network index 6b97fb18..e407d173 100644 --- a/core/rootfs/rootfs-stage31/data/inc/setup_network +++ b/core/rootfs/rootfs-stage31/data/inc/setup_network @@ -47,28 +47,24 @@ for LINE in $IP_OUT; do IFMAC="$( echo "${LINE#*==}" | tr 'A-Z' 'a-z' )" # udev requires mac addesses to be lowercase (a-f), see http://www.debianhelp.co.uk/udev.htm echo "${IFACE} = ${IFMAC}" + if [ -z "$MAC" ]; then + echo "No main MAC address given, trying first interface found..." + MAC="$IFMAC" + fi + if [ "x$IFMAC" == "x$MAC" ]; then + ip link set dev "$IFACE" up brctl addbr "$BRIDGE" || drop_shell "Could not create bridge $BRIDGE" brctl stp "$BRIDGE" 0 brctl setfd "$BRIDGE" 0.000000000001 ip link set addr "$IFMAC" "$BRIDGE" || drop_shell "Could not set mac of $BRIDGE" - ip link set dev "$IFACE" up wait_for_iface "$IFACE" 8 brctl addif "$BRIDGE" "$IFACE" || drop_shell "Could not add $IFACE to $BRIDGE" # save our variables for retry on fail echo "IFACE=$IFACE" > /run/network.conf - # analyze ip information from the kernel command line and put parts - # of it into several variables - if [ -n "$CLIENTIP" ] ; then - # set static ip address - ip link set dev "$BRIDGE" up - ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE" - [ -n "$GATEWAY" ] && ip route add default via "$GATEWAY" dev "$BRIDGE" - else - ip link set dev "$BRIDGE" up - fi + ip link set dev "$BRIDGE" up # Ignore this device later on when systemd handles network interfaces (see hacked 99-systemd.rules in systemd data dir) echo "SUBSYSTEM==\"net\", ACTION==\"add\", KERNEL==\"eth*\", ATTR{address}==\"$IFMAC\", TAG+=\"openslxignore\"" >> "${FUTURE_ROOT}/etc/udev/rules.d/01-ignore-boot-interface.rules" else @@ -90,14 +86,17 @@ done wait_for_iface "$BRIDGE" 5 +# See if we got all required attributes via KCL, in that case skip DHCP +# TODO: Supply DNS servers in config from boot server, so we can even work witout it +if [ -n "$ip" ] && [ -n "$router" ] && [ -n "$dns" ]; then + echo "Skipping DHCP since we have new style KCL" + interface="${BRIDGE}" /inc/udhcpc-trigger bound && return 0 +fi + # udhcpc PARAM= -if [ -n "$CLIENTIP" ]; then - PARAM="-r $CLIENTIP" - echo -n "$CLIENTIP" > "/run/firstip" -fi -if [ -n "$GATEWAY" ]; then - echo -n "$GATEWAY" > "/run/firstgw" +if [ -n "$ip" ]; then + PARAM="-r ${ip%/*}" fi if [ "$USE_DHCP_UUID" = "yes" ]; then @@ -109,15 +108,15 @@ if [ "$USE_DHCP_UUID" = "yes" ]; then fi # save our variables for retry on fail ff. -echo "CLIENTIP=$CLIENTIP" >> /run/network.conf -echo "GATEWAY=$GATEWAY" >> /run/network.conf +echo "ip=$ip" >> /run/network.conf +echo "router=$router" >> /run/network.conf echo "BRIDGE=$BRIDGE" >> /run/network.conf echo "UID=$UID" >> /run/network.conf -udhcpc $PARAM -O hostname -O ntpsrv -O domain -O search -t 5 -T 3 -A 4 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE" +udhcpc $PARAM -O hostname -O ntpsrv -O domain -O search -O dns -t 5 -T 3 -A 4 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE" URET=$? # if these were empty before, udhcpc might have filled them in -[ -z "$CLIENTIP" ] && CLIENTIP=$(cat /run/firstip) -[ -z "$GATEWAY" ] && GATEWAY=$(cat /run/firstgw) +[ -z "$ip" ] && ip=$(cat /run/firstip) +[ -z "$router" ] && router=$(cat /run/firstgw) # udhcpc return value will be return value of this script return $URET |