summaryrefslogtreecommitdiffstats
path: root/etc/rc.d
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2015-04-15 21:48:06 +0000
committerdelphij <delphij@FreeBSD.org>2015-04-15 21:48:06 +0000
commit404cb28d68faf12d79dd4a83068946561d77ebdd (patch)
tree956e58de703da00ecf4e23bf88206981192f9535 /etc/rc.d
parentac2c19f7217d2592521bab48c9b29a676873fae8 (diff)
downloadFreeBSD-src-404cb28d68faf12d79dd4a83068946561d77ebdd.zip
FreeBSD-src-404cb28d68faf12d79dd4a83068946561d77ebdd.tar.gz
Verify if the saved hostid is still the same and update if
it was changed. Sponsored by: iXsystems, Inc. Obtained from: FreeNAS (trueos commit 0abb740)
Diffstat (limited to 'etc/rc.d')
-rwxr-xr-xetc/rc.d/hostid_save15
1 files changed, 11 insertions, 4 deletions
diff --git a/etc/rc.d/hostid_save b/etc/rc.d/hostid_save
index fca0521..9741aec 100755
--- a/etc/rc.d/hostid_save
+++ b/etc/rc.d/hostid_save
@@ -16,12 +16,19 @@ rcvar="hostid_enable"
hostid_save()
{
- if [ ! -r ${hostid_file} ]; then
- $SYSCTL_N kern.hostuuid > ${hostid_file}
- if [ $? -ne 0 ]; then
- warn "could not store hostuuid in ${hostid_file}."
+ current_hostid=`$SYSCTL_N kern.hostuuid`
+
+ if [ -r ${hostid_file} ]; then
+ read saved_hostid < ${hostid_file}
+ if [ ${saved_hostid} = ${current_hostid} ]; then
+ exit 0
fi
fi
+
+ echo ${current_hostid} > ${hostid_file}
+ if [ $? -ne 0 ]; then
+ warn "could not store hostuuid in ${hostid_file}."
+ fi
}
load_rc_config $name
OpenPOWER on IntegriCloud