diff options
| author | Jonathan Bauer | 2020-05-25 11:26:54 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2020-05-25 11:26:54 +0200 |
| commit | 8b36285c9ec75ee9fa59f44b0714b952b574190f (patch) | |
| tree | 3d4e51530e54e3d7643e47f2bd4e550be0de07f0 /modules.d/slx-network/scripts | |
| parent | build-initramfs.sh: support CentOS-7 again (diff) | |
| parent | Merge branch 'master' into nobash-merge (diff) | |
| download | systemd-init-8b36285c9ec75ee9fa59f44b0714b952b574190f.tar.gz systemd-init-8b36285c9ec75ee9fa59f44b0714b952b574190f.tar.xz systemd-init-8b36285c9ec75ee9fa59f44b0714b952b574190f.zip | |
Merge branch 'nobash-merge' into downloader-nobash-merge
Diffstat (limited to 'modules.d/slx-network/scripts')
3 files changed, 34 insertions, 6 deletions
diff --git a/modules.d/slx-network/scripts/setup-bootif-network.stage3 b/modules.d/slx-network/scripts/setup-bootif-network.stage3 index 53ad8de9..50718894 100755 --- a/modules.d/slx-network/scripts/setup-bootif-network.stage3 +++ b/modules.d/slx-network/scripts/setup-bootif-network.stage3 @@ -88,18 +88,37 @@ if [ -n "$SLX_PXE_CLIENT_IP" ]; then dev "$MAIN_NETIF" fi -if [ "$USE_DHCP_UUID" = "yes" ] && [ -s "/run/system-uuid" ]; then - UUID="$(cat /run/system-uuid)" +additional_opts=() + +# we need to send the same UID (without '-') as the PXE firmware did, so use the plain +# one read with dmidecode (and not the one by get-system-uuid). +if [ "$USE_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" + additional_opts+=("-x" "0x3d:$UID") + fi +fi + +if [ -n "$SLX_PXE_CLIENT_IP" ]; then + additional_opts+=("-r" "$SLX_PXE_CLIENT_IP") fi +# DHCP options to request +request_opts=("-O" "hostname") +request_opts+=("-O" "ntpsrv") +request_opts+=("-O" "domain") +request_opts+=("-O" "wpad") +request_opts+=("-O" "search") +request_opts+=("-O" "nisdomain") + # udhcpc for i in 1 1 1 fail; do [ "$i" = "fail" ] && emergency_shell "DHCP failed 3 times... cannot continue." udhcpc -t 4 -T 3 -f -n -q \ -i "${MAIN_NETIF}" \ - "${SLX_PXE_CLIENT_IP:+-r $SLX_PXE_CLIENT_IP}" \ - "${UUID:+-x 0x3d:$UUID}" \ - -O ntpsrv -O domain -O wpad -O search -O nisdomain \ + "${request_opts[@]}" \ + "${additional_opts[@]}" \ -s "/usr/local/bin/udhcpc-trigger" # success? [ "$?" -eq 0 ] && break @@ -110,3 +129,5 @@ done set +x } &>> "/run/openslx/initramfs-network.log.$$" + + diff --git a/modules.d/slx-network/scripts/setup-bootif-network.stage4 b/modules.d/slx-network/scripts/setup-bootif-network.stage4 index 61f925d0..4f41dfed 100755 --- a/modules.d/slx-network/scripts/setup-bootif-network.stage4 +++ b/modules.d/slx-network/scripts/setup-bootif-network.stage4 @@ -21,7 +21,10 @@ readonly MAIN_NETIF # set default options declare -a udhcpc_opts +udhcpc_opts+=("-T" "1") +udhcpc_opts+=("-A" "5") udhcpc_opts+=("-t" "8") +udhcpc_opts+=("-O" "hostname") udhcpc_opts+=("-O" "domain") udhcpc_opts+=("-O" "nissrv") udhcpc_opts+=("-O" "nisdomain") diff --git a/modules.d/slx-network/scripts/udhcpc-trigger.stage4 b/modules.d/slx-network/scripts/udhcpc-trigger.stage4 index b4dfeafa..d7009dc6 100755 --- a/modules.d/slx-network/scripts/udhcpc-trigger.stage4 +++ b/modules.d/slx-network/scripts/udhcpc-trigger.stage4 @@ -66,7 +66,11 @@ case "$1" in ip addr add "$ip/$(ipcalc -s -p "$ip" "$subnet" | sed s/.*=//)" dev "$interface" # Set default route, if given if [ -n "$router" ]; then - ip route replace default via "$router" + # Only replace route if it's the same interface as the current default route, or we don't have any + current="$( ip route show | awk '{ if ($1 == "default") {print $5; exit 0}}' )" + if [ -z "$current" ] || [ "$interface" = "$current" ]; then + ip route replace default via "$router" + fi fi # get domain, hostname and thus fqdn from DNS |
