From c29500c7b461603790126f7591fcb6dc3b9634e7 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 16 Jul 2021 17:27:59 +0200 Subject: [dhcpc-busybox] Add option to ignore secondary interfaces, improve .... resolv.conf awk generator --- .../data/opt/openslx/scripts/systemd-udhcpc | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc (limited to 'core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc') diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc new file mode 100755 index 00000000..49d0180d --- /dev/null +++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc @@ -0,0 +1,34 @@ +#!/bin/bash +# For arrays + +net_if="$1" +net_ip="$(ip addr show dev "${net_if}" | grep -m1 '^\s*inet ' | awk -F " " '{print $2}' | awk -F "/" '{print $1}')" + +declare -a udhcpc_opts +if [ -n "$net_ip" ]; then + udhcpc_opts+=( "-r" "$net_ip" ) +fi + +. /opt/openslx/config +primary="${SLX_BRIDGE:-br0}" + +if [ "${SLX_DHCP_SECONDARY:-yes}" != "yes" ]; then + echo "No DHCP on other NICs requested. Doing nothing." + exit 0 +fi + +if [ "$primary" = "$net_if" ] && [ "$SLX_NET_DHCP_UUID" = "yes" ]; then + uid="$( dmidecode -s system-uuid | sed -r 's/^(..)(..)(..)(..)-(..)(..)-(..)(..)-(....)-/00\4\3\2\1\6\5\8\7\9/' )" + if [ "${#uid}" = 34 ]; then + echo "Using SMBIOS uid for DHCP" + udhcpc_opts+=( "-x" "0x3d:$uid" ) + fi +fi + +exec /opt/openslx/sbin/udhcpc "${udhcpc_opts[@]}" \ + -O domain -O nissrv -O nisdomain -O wpad -O search -O wins \ + -s /opt/openslx/scripts/udhcpc-openslx \ + -i "${net_if}" -f -t 8 + +slxlog "udhcpc" "Could not run 'udhcpc ${udhcpc_opts[*]}' on ${net_if}." +exit 1 -- cgit v1.2.3-55-g7522