summaryrefslogtreecommitdiffstats
path: root/core/modules/system-uuid
diff options
context:
space:
mode:
authorSimon Rettberg2020-07-08 16:12:32 +0200
committerSimon Rettberg2020-07-08 16:12:32 +0200
commitc1d6cad0e7653fcad04f27a7827a439827470092 (patch)
tree32578b2e35511271a913ac01bfb9a6b30166e0fd /core/modules/system-uuid
parent[remote-access] Tweak screen splitting (diff)
downloadmltk-c1d6cad0e7653fcad04f27a7827a439827470092.tar.gz
mltk-c1d6cad0e7653fcad04f27a7827a439827470092.tar.xz
mltk-c1d6cad0e7653fcad04f27a7827a439827470092.zip
[init/kexec/] More advanced network setup via KCL, could skip DHCP
If enough information if provided via KCL, we can skip the initial DHCP request in stage 3.1. Currently we require IP address, subnet mask and DNS server to skip DHCP. If we extend the boot server to supply a fallback/default DNS server, we could even do without DNS which would work in almost all cases. kexec-reboot has been extended to make use of this feature, but can be extended even more to provide up to date values from the current system configuration. Currently, some of the values it provides to the new kernel will be cached values from stage 3.1. kexec-reboot also honors the ipxe menu id from the KCL if given, to properly download the matching menu entry, which will take updates to the entry into account (e.g. changed URLs to kernel/init).
Diffstat (limited to 'core/modules/system-uuid')
-rwxr-xr-xcore/modules/system-uuid/data/bin/get-uuid27
1 files changed, 15 insertions, 12 deletions
diff --git a/core/modules/system-uuid/data/bin/get-uuid b/core/modules/system-uuid/data/bin/get-uuid
index 67928de2..0a03bbed 100755
--- a/core/modules/system-uuid/data/bin/get-uuid
+++ b/core/modules/system-uuid/data/bin/get-uuid
@@ -1,15 +1,5 @@
#!/bin/ash
-eval $(grep -Eo BOOTIF=\\S+ /proc/cmdline)
-if [ "${#BOOTIF}" -ne "20" ]; then
- echo "Getting MAC from /proc/cmdline failed, using 'ip a'..."
- BOOTIF=01-$(ip a | grep -A 1 ': br0' | grep -o 'ether ..:..:..:..:..:..' | cut -d' ' -f2 | sed s/:/-/g)
- if [ "${#BOOTIF}" -ne "20" ]; then
- echo "FAIL FAIL FAIL"
- BOOTIF="99-88-77-66-55-44-33"
- fi
-fi
-
UUID=$( dmidecode -q -s system-uuid | grep -v '^#' | head -n 1 | tr 'a-z' 'A-Z' )
if [ "${#UUID}" -ne "36" ]; then
echo "Determined UUID (${UUID}) has not expected length of 36, falling back to MAC..."
@@ -37,8 +27,21 @@ else
rm -f -- "$TMPLIST" "$BADLIST"
fi
if [ -z "$UUID" ]; then
- UUID=$( echo "$BOOTIF" | sed -r 's/[^0-9A-Fa-f]//g' )
- [ "${#UUID}" -eq 14 ] && UUID="${UUID:2}"
+ if [ "${#MAC}" -ne 17 ]; then
+ MAC="$( grep -Eo '(?<=ipv4.if=)\S+' /proc/cmdline )"
+ fi
+ if [ "${#MAC}" -ne 17 ]; then
+ MAC="$( grep -Eo '(?<=BOOTIF=01-)\S+' /proc/cmdline )"
+ fi
+ if [ "${#MAC}" -ne 17 ]; then
+ echo "Getting MAC from /proc/cmdline failed, using 'ip a'..."
+ MAC="$( ip a | grep -A 1 ': br0' | grep -o 'ether ..:..:..:..:..:..' | cut -d' ' -f2 )"
+ fi
+ if [ "${#MAC}" -ne 17 ]; then
+ echo "FAIL FAIL FAIL"
+ MAC="88-77-66-55-44-33"
+ fi
+ UUID=$( echo "$MAC" | sed -r 's/[^0-9A-Fa-f]//g' )
if [ "${#UUID}" -eq 12 ]; then
UUID="baad1d00-9491-4716-b98b-$UUID"
else