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)
This commit is contained in:
Xin LI 2015-04-15 21:48:06 +00:00
parent 8bf2dccec4
commit 8f990792fc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=281565

View File

@ -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