summaryrefslogtreecommitdiffstats
path: root/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc
diff options
context:
space:
mode:
authorSimon Rettberg2021-07-16 17:27:59 +0200
committerSimon Rettberg2021-07-16 17:27:59 +0200
commitc29500c7b461603790126f7591fcb6dc3b9634e7 (patch)
tree274f978a440628cef0c6bbbdc4656e74c4686263 /core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc
parent[vmware-common] fix english (diff)
downloadmltk-c29500c7b461603790126f7591fcb6dc3b9634e7.tar.gz
mltk-c29500c7b461603790126f7591fcb6dc3b9634e7.tar.xz
mltk-c29500c7b461603790126f7591fcb6dc3b9634e7.zip
[dhcpc-busybox] Add option to ignore secondary interfaces, improve
.... resolv.conf awk generator
Diffstat (limited to 'core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc')
-rwxr-xr-xcore/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc34
1 files changed, 34 insertions, 0 deletions
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