summaryrefslogtreecommitdiffstats
path: root/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3
diff options
context:
space:
mode:
authorJonathan Bauer2020-05-13 11:04:02 +0200
committerJonathan Bauer2020-05-13 11:04:02 +0200
commit1130873aa55c9b0a7e5af48edc44bd6c6fd1f888 (patch)
tree0fcfa186cd631d8d36611b3d4bc509fd38841d51 /builder/modules.d/slx-network/scripts/setup-bootif-network.stage3
parentMerge branch 'centos8' into downloader (diff)
downloadsystemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.tar.gz
systemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.tar.xz
systemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.zip
restructure repo
* remove packager * move everything from builder/* back to root
Diffstat (limited to 'builder/modules.d/slx-network/scripts/setup-bootif-network.stage3')
-rwxr-xr-xbuilder/modules.d/slx-network/scripts/setup-bootif-network.stage3112
1 files changed, 0 insertions, 112 deletions
diff --git a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3
deleted file mode 100755
index 53ad8de9..00000000
--- a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/bin/bash
-#
-# This script sets up the main network interface we booted from,
-# as designated by SLX_PXE_NETIF (parsed from the PXE KCL in the
-# cmdline dracut hook).
-# It is run inside dracut's initqueue, on settles to detect the
-# physical network interface as fast as possible.
-
-type emergency_shell >/dev/null 2>&1 || . /lib/dracut-lib.sh
-
-. /run/openslx/network.conf
-
-# guard to not run until the phsyical interface is not ready yet
-if [ ! -e "/sys/class/net/${SLX_PXE_NETIF}/device" ]; then
- exit 1
-fi
-
-wait_for_iface() {
- local _iface="$1"
- local _timeout="${2:-50}"
- while [ "$_timeout" -ne 0 ]; do
- [ "$(cat /sys/class/net/${_iface}/operstate)" = "up" ] && break
- (( _timeout -- ))
- usleep 100000
- done
- [ "$_timeout" -ne 0 ]
-}
-
-# For debugging...
-{
-set -x
-
-ip link set dev "$SLX_PXE_NETIF" up
-if ! wait_for_iface "$SLX_PXE_NETIF" 300; then
- warn "'$SLX_PXE_NETIF' still not up after 30sec ... trying anyway."
- # TODO handle case where we waited for 30sec and it is still not up
-fi
-
-# now determine whether we are in bridged/vlan/plain mode
-MAIN_NETIF="$SLX_PXE_NETIF"
-if [ -n "$SLX_VLAN_ID" ]; then
- # create VLAN interface
- modprobe 8021q || warn "Loading '8021q' failed - missing module?"
- ip link add link "$SLX_PXE_NETIF" name "${SLX_PXE_NETIF}.${SLX_VLAN_ID}" \
- type vlan id "$SLX_VLAN_ID"
- ip link set dev "${SLX_PXE_NETIF}.${SLX_VLAN_ID}" up
- if wait_for_iface "${SLX_PXE_NETIF}.${SLX_VLAN_ID}"; then
- MAIN_NETIF="${SLX_PXE_NETIF}.${SLX_VLAN_ID}"
- else
- warn "Setting up VLAN '$SLX_VLAN_ID' failed, trying plain..."
- fi
-fi
-
-if [ -n "$SLX_BRIDGE" ]; then
- for try in {1..10} ""; do
- (
- set -e
- brctl addbr "$SLX_BRIDGE"
- brctl stp "$SLX_BRIDGE" 0
- brctl setfd "$SLX_BRIDGE" 0.000000000001
- ip link set addr "$SLX_PXE_MAC" "$SLX_BRIDGE"
- brctl addif "$SLX_BRIDGE" "$MAIN_NETIF"
- ip link set dev "$SLX_BRIDGE" up
- wait_for_iface "$SLX_BRIDGE"
- )
- # success?
- if [ "$?" -eq 0 ]; then
- MAIN_NETIF="$SLX_BRIDGE"
- break
- fi
-
- # nope, handle
- if [ -z "$try" ]; then
- emergency_shell "Failed to setup main network bridge, giving up!"
- fi
- warn "Failed to setup main network bridge on try $try. Retrying ..."
- # delete bridge, inc try and sleep 100ms before trying again
- [ -e "/sys/class/net/${SLX_BRIDGE}" ] && brctl delbr "$SLX_BRIDGE"
- usleep 100000
- done
-fi
-
-# finally add the IP address on the main NIC
-if [ -n "$SLX_PXE_CLIENT_IP" ]; then
- ip addr add \
- "${SLX_PXE_CLIENT_IP}/$(ipcalc -s -p "$SLX_PXE_CLIENT_IP" "$SLX_PXE_NETMASK" | sed "s/.*=//")" \
- broadcast "$(ipcalc -s -b "$SLX_PXE_CLIENT_IP" "$SLX_PXE_NETMASK" | sed "s/.*=//")" \
- dev "$MAIN_NETIF"
-fi
-
-if [ "$USE_DHCP_UUID" = "yes" ] && [ -s "/run/system-uuid" ]; then
- UUID="$(cat /run/system-uuid)"
-fi
-
-# udhcpc
-for i in 1 1 1 fail; do
- [ "$i" = "fail" ] && emergency_shell "DHCP failed 3 times... cannot continue."
- udhcpc -t 4 -T 3 -f -n -q \
- -i "${MAIN_NETIF}" \
- "${SLX_PXE_CLIENT_IP:+-r $SLX_PXE_CLIENT_IP}" \
- "${UUID:+-x 0x3d:$UUID}" \
- -O ntpsrv -O domain -O wpad -O search -O nisdomain \
- -s "/usr/local/bin/udhcpc-trigger"
- # success?
- [ "$?" -eq 0 ] && break
- # nope, keep trying...
- warn "DHCP failed, retrying in 1sec..."
- sleep $i
-done
-
-set +x
-} &>> "/run/openslx/initramfs-network.log.$$"