summaryrefslogtreecommitdiffstats
path: root/core/modules/dhcpc-busybox
diff options
context:
space:
mode:
authorSimon Rettberg2018-07-23 14:17:33 +0200
committerSimon Rettberg2018-07-23 14:17:33 +0200
commit403612a5adbe11b23281bc4d23705a232bdf9801 (patch)
tree54faae56d3bcec6f867cd26dd6904b94a92d2f91 /core/modules/dhcpc-busybox
parent[dhcpc-busybox] udhcpc-openslx: Make shellcheck happy (diff)
downloadmltk-403612a5adbe11b23281bc4d23705a232bdf9801.tar.gz
mltk-403612a5adbe11b23281bc4d23705a232bdf9801.tar.xz
mltk-403612a5adbe11b23281bc4d23705a232bdf9801.zip
[dhcpc-busybox] Also add special primary handling to systemd-udhcpc
Diffstat (limited to 'core/modules/dhcpc-busybox')
-rwxr-xr-xcore/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc++23
1 files changed, 15 insertions, 8 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++
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}"