summaryrefslogtreecommitdiffstats
path: root/etc/rc.d
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2007-04-11 00:05:25 +0000
committerpjd <pjd@FreeBSD.org>2007-04-11 00:05:25 +0000
commit1e6e7c9b8c8234c23911142b6ecdf6cecacc8534 (patch)
treea20bd0456d862a8590ed32d932e7b51140c2bfb1 /etc/rc.d
parentc22a6a4408dcbbfb42eaaee954606c913c141660 (diff)
downloadFreeBSD-src-1e6e7c9b8c8234c23911142b6ecdf6cecacc8534.zip
FreeBSD-src-1e6e7c9b8c8234c23911142b6ecdf6cecacc8534.tar.gz
If available, take UUID from smbios.system.uuid, if not fall back to
software-generated UUID. Store the result in /etc/hostid and use it in the future. Perform simple UUID format check, as there is a lot of hardware with broken UUIDs. The check should be improved to also eliminate fake UUIDs like 00000000-0000-0000-0000-000000000000. Requested by: many
Diffstat (limited to 'etc/rc.d')
-rw-r--r--etc/rc.d/hostid19
1 files changed, 18 insertions, 1 deletions
diff --git a/etc/rc.d/hostid b/etc/rc.d/hostid
index b380180..2ba4398 100644
--- a/etc/rc.d/hostid
+++ b/etc/rc.d/hostid
@@ -54,9 +54,26 @@ hostid_set()
${SYSCTL_W} kern.hostid=${id} >/dev/null
}
+hostid_hardware()
+{
+ uuid=`kenv smbios.system.uuid 2>/dev/null`
+ x="[0-9a-zA-Z]"
+ y=$x$x$x$x
+ case "${uuid}" in
+ $y$y-$y-$y-$y-$y$y$y)
+ echo "${uuid}"
+ ;;
+ esac
+}
+
hostid_reset()
{
- uuid=`uuidgen`
+ # First look for UUID in hardware.
+ uuid=`hostid_hardware`
+ if [ -z ${uuid} ]; then
+ # If not found, fall back to software-generated UUID.
+ uuid=`uuidgen`
+ fi
# Store newly generated UUID in ${hostid_file}.
echo $uuid > ${hostid_file}
if [ $? -ne 0 ]; then
OpenPOWER on IntegriCloud