diff options
author | Jonathan Bauer | 2019-08-08 13:53:37 +0200 |
---|---|---|
committer | Jonathan Bauer | 2019-08-08 13:53:37 +0200 |
commit | bec14f4e1ac4d1b4a7a782d6c3c54cd5ebe5208b (patch) | |
tree | b0b9d81568f2d732988c54d432fcb5c35ccf39f9 /builder/modules.d/slx-network/scripts/setup-bootif-network.stage4 | |
parent | [busybox] install busybox into stage4 (diff) | |
download | systemd-init-bec14f4e1ac4d1b4a7a782d6c3c54cd5ebe5208b.tar.gz systemd-init-bec14f4e1ac4d1b4a7a782d6c3c54cd5ebe5208b.tar.xz systemd-init-bec14f4e1ac4d1b4a7a782d6c3c54cd5ebe5208b.zip |
[slx-network] support for dhcp in stage4
Diffstat (limited to 'builder/modules.d/slx-network/scripts/setup-bootif-network.stage4')
-rwxr-xr-x | builder/modules.d/slx-network/scripts/setup-bootif-network.stage4 | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage4 b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage4 new file mode 100755 index 00000000..7ccb94e6 --- /dev/null +++ b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage4 @@ -0,0 +1,52 @@ +#!/bin/bash +# For arrays + +export PATH=$PATH:/opt/openslx/sbin:/opt/openslx/bin + +. /run/openslx/network.conf + +net_if="$1" +net_ip="$(ip addr show dev "${net_if}" | grep -m1 '^\s*inet ' | \ + awk -F " " '{print $2}' | awk -F "/" '{print $1}')" + +# set default options +declare -a udhcpc_opts +udhcpc_opts+=("-t" "8") +udhcpc_opts+=("-O" "domain") +udhcpc_opts+=("-O" "nissrv") +udhcpc_opts+=("-O" "nisdomain") +udhcpc_opts+=("-O" "wpad") +udhcpc_opts+=("-O" "search") +udhcpc_opts+=("-O" "wins") + +# need to renew? +if [ -n "$net_ip" ]; then + udhcpc_opts+=( "-r" "$net_ip" ) +fi + +primary="br0" +[ -n "$SLX_BRIDGE" ] && primary="$SLX_BRIDGE" + +# send machine uuid during DHCP if acting on primary interface +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 + +mkdir -p /run/udhcpc || echo "Could not create '/run/udhcpc'." + +udhcpc "${udhcpc_opts[@]}" -i "${net_if}" \ + -s /opt/openslx/scripts/udhcpc-trigger \ + -p "/run/udhcpc/udhcpc.${net_if}.pid" +ret=$? + +if [ "${ret}" != 0 ]; then + echo "udhcpc" "Could not run 'udhcpc ${udhcpc_opts[*]}' on ${net_if}." +fi + +exit "${ret}" + |