summaryrefslogtreecommitdiffstats
path: root/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc
blob: a29756b7aff7e50e0779d928442f77dcc1347143 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/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 [ "$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