From 403612a5adbe11b23281bc4d23705a232bdf9801 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 23 Jul 2018 14:17:33 +0200 Subject: [dhcpc-busybox] Also add special primary handling to systemd-udhcpc --- .../data/opt/openslx/scripts/systemd-udhcpc++ | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'core/modules/dhcpc-busybox') diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc++ index 608ec846..4487b2c8 100755 --- a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc++ +++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc++ @@ -1,26 +1,33 @@ #!/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}')" -udhcpc_opts="" +declare -a udhcpc_opts if [ -n "$net_ip" ]; then - udhcpc_opts="$udhcpc_opts -r $net_ip" + udhcpc_opts+=( "-r" "$net_ip" ) fi -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="$udhcpc_opts -x 0x3d:$uid" +. /opt/openslx/config +primary="br0" +[ -n "$SLX_BRIDGE" ] && primary="$SLX_BRIDGE" + +if [ "$primary" = "$net_if" ]; 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 mkdir -p /run/udhcpc || echo "Could not create '/run/udhcpc'." -/opt/openslx/sbin/udhcpc ${udhcpc_opts} -O domain -O nissrv -O nisdomain -O wpad -O search -O wins -t 8 -s /opt/openslx/scripts/udhcpc-openslx -i "${net_if}" -p "/run/udhcpc/udhcpc.${net_if}.pid" +/opt/openslx/sbin/udhcpc "${udhcpc_opts[@]}" -O domain -O nissrv -O nisdomain -O wpad -O search -O wins -t 8 -s /opt/openslx/scripts/udhcpc-openslx -i "${net_if}" -p "/run/udhcpc/udhcpc.${net_if}.pid" ret=$? if [ "${ret}" != 0 ]; then - slxlog "udhcpc" "Could not run 'udhcpc ${udhcpc_opts}' on ${net_if}." + slxlog "udhcpc" "Could not run 'udhcpc ${udhcpc_opts[*]}' on ${net_if}." fi exit "${ret}" -- cgit v1.2.3-55-g7522