summaryrefslogtreecommitdiffstats
path: root/core/modules/dhcpc-busybox/data
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/dhcpc-busybox/data')
-rw-r--r--core/modules/dhcpc-busybox/data/etc/systemd/system/bridge-additional-nics.service8
-rw-r--r--core/modules/dhcpc-busybox/data/etc/udev/rules.d/99-openslx-net.rules2
-rwxr-xr-xcore/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-bridge_additional_nics48
-rwxr-xr-xcore/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx57
4 files changed, 67 insertions, 48 deletions
diff --git a/core/modules/dhcpc-busybox/data/etc/systemd/system/bridge-additional-nics.service b/core/modules/dhcpc-busybox/data/etc/systemd/system/bridge-additional-nics.service
new file mode 100644
index 00000000..751f3598
--- /dev/null
+++ b/core/modules/dhcpc-busybox/data/etc/systemd/system/bridge-additional-nics.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Setup bridges for addition network interfaces
+Wants=systemd-udevd.service
+After=systemd-udev-settle.service systemd-udevd.service
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-bridge_additional_nics
diff --git a/core/modules/dhcpc-busybox/data/etc/udev/rules.d/99-openslx-net.rules b/core/modules/dhcpc-busybox/data/etc/udev/rules.d/99-openslx-net.rules
index 17c0068c..1d8778dc 100644
--- a/core/modules/dhcpc-busybox/data/etc/udev/rules.d/99-openslx-net.rules
+++ b/core/modules/dhcpc-busybox/data/etc/udev/rules.d/99-openslx-net.rules
@@ -1 +1 @@
-ACTION=="add", SUBSYSTEM=="net", KERNEL=="br0|br-nic-*", TAG+="systemd", ENV{SYSTEMD_ALIAS}="/sys/subsystem/net/devices/$name", ENV{SYSTEMD_WANTS}="network-interface@$name.service"
+ACTION=="add", SUBSYSTEM=="net", KERNEL=="br-nic-*", TAG+="systemd", ENV{SYSTEMD_ALIAS}="/sys/subsystem/net/devices/$name", ENV{SYSTEMD_WANTS}="network-interface@$name.service"
diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-bridge_additional_nics b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-bridge_additional_nics
new file mode 100755
index 00000000..fd820909
--- /dev/null
+++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-bridge_additional_nics
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Small script scanning sysfs for physical network interfaces
+# and creating additional network bridges 'br-nic-[0-9]'.
+
+. /opt/openslx/config
+
+# do nothing if not netbooted
+[ -z "$SLX_PXE_NETIF" ] && exit 1
+
+declare -g id=1
+for nic in /sys/class/net/*; do
+ # The presence of this symlink pointing to the physical device
+ # seems to be the better way to detect them.
+ [ -h "${nic}/device" ] || continue
+
+ # do not handle the primary interface
+ [ "$SLX_PXE_NETIF" = "${nic##*/}" ] && continue
+
+ # physical nic found, create a bridge with the same MAC
+ bridge="br-nic-${id}"
+ mac="$(cat "${nic}/address")"
+ if ! [[ $mac =~ ^([0-9a-f]{2}:){5}[0-9a-f]{2}$ ]]; then
+ echo "'$mac' does not seems like a valid MAC address."
+ continue
+ fi
+
+ (
+ set -e
+ brctl addbr "$bridge"
+ brctl stp "$bridge" 0
+ ip link set addr "$mac" "$bridge"
+ ip link set dev "${nic##*/}" up
+ brctl addif "$bridge" "${nic##*/}"
+ ip link set dev "$bridge" up
+ )
+ ret=$?
+ if [ "$ret" != 0 ]; then
+ echo "Failed to setup additional bridge '$bridge' for '$nic'."
+ brctl delbr "$bridge"
+ continue
+ fi
+
+ # all fine, increase counter and continue
+ (( id++ ))
+done
+
+exit 0
diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
index c034efb5..b2a4e896 100755
--- a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
+++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
@@ -155,10 +155,13 @@ case "$1" in
rebuild_resolv_conf
fi
-
+ # NOTE: The udev rule triggering our network setup is changed in *installer*
+ # to only trigger this script on additional interfaces bridges. Keeping the code
+ # here for now and for easier merging...
# Things that should only happen for the main interface that was used for booting
if [ "$interface" = "$primary" ]; then
- # Update IP
+ # Update IP, TODO: check if we really want/need to overwrite the PXE_IP,
+ # it might be better/clearer to change the SLX_DHCP_CLIENT_IP...
sed -i "s/^\(SLX_PXE_CLIENT_IP=\).*$/\1'$ip'/" /opt/openslx/config
# Write DOMAIN and SEARCH to /opt/openslx/config if empty
if [ -z "$SLX_NET_DOMAIN" ] && [ -n "$domain" ]; then
@@ -175,36 +178,6 @@ case "$1" in
echo "SLX_NET_WINS='$wins'" >> /opt/openslx/config
fi
- # Only if network is not ready yet
- if ! [ -e "/run/network/network-ready" ] || ! [ -e "/etc/hostname" ] || grep -q '^noname-' "/etc/hostname"; then
- # Update hostname
- if [ -z "$dns_fqdn" ] && [ -n "$domain" ] && [ -n "$hostname" ]; then
- # fallback to what the dhcp told us
- dns_fqdn="${hostname}.${domain}"
- fi
- if [ -z "$dns_fqdn" ]; then
- # only if there is no /etc/hostname, we fall back (far back, that is)
- [ ! -s "/etc/hostname" ] && dns_fqdn="slx-client"
- fi
- # finally, if dns_fqdn was set to anything, apply it
- if [ -n "$dns_fqdn" ]; then
- dns_short="${dns_fqdn%%.*}"
- echo "$dns_short" > "/proc/sys/kernel/hostname"
- echo "$dns_short" > "/etc/hostname"
- if grep '^SLX_HOSTNAME=' /opt/openslx/config 2>/dev/null; then
- sed -i "s/^\(SLX_HOSTNAME=\).*$/\1'$dns_short'/" /opt/openslx/config
- else
- echo "# Config written by openslx-dhcp-script (1)" >> /opt/openslx/config
- echo "SLX_HOSTNAME='$dns_short'" >> /opt/openslx/config
- fi
- fi
-
- # Update /etc/issue for proper spacing
- /opt/openslx/scripts/openslx-create_issue
- touch "/run/network/network-ready"
- # Mark network target as reached
- systemctl start network.target &
- fi # end "network not ready yet"
# Remove any stray addresses; we expect the primary interface to only have one
# address supplied via DHCP. We do this after adding the new one, obviously.
rem_list=$( ip -o addr show "$interface" | awk '{ for (i=1;i<NF;++i) if ($i == "inet") print $(i+1) }' | grep -v "^${ip}/" )
@@ -217,7 +190,7 @@ case "$1" in
done
fi
fi # end "primary only"
-
+
# Hostname in /etc/hosts
touch "/etc/hosts"
hostlist=""
@@ -238,20 +211,10 @@ case "$1" in
fi
# Get rid of orphaned lines in /etc/hosts
sed -i -r '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s*$/d' /etc/hosts
-
- # "dns ready" target
- if [ -n "$dns" ] && [ ! -e "/run/network/dns-ready" ]; then
- touch "/run/network/dns-ready"
- # Write to openslx-config
- echo "# Config written by openslx-dhcp-script (2)" >> /opt/openslx/config
- echo "SLX_DNS='$dns'" >> /opt/openslx/config
- systemctl start network-dns.target &
- fi
- # "default route exists" target
- if [ -n "$router" ] && [ ! -e "/run/network/gateway-ready" ]; then
- touch "/run/network/gateway-ready"
- systemctl start network-gateway.target &
- fi
+ # Write to openslx-config
+ echo "# Config written by openslx-dhcp-script (2)" >> /opt/openslx/config
+ sed -i "/^SLX_DNS=/d" /opt/openslx/config
+ echo "SLX_DNS='$dns'" >> /opt/openslx/config
;;
deconfig)