From 8f990792fcf6e6f1c1e9b751d1a489ca6b39f55f Mon Sep 17 00:00:00 2001 From: Xin LI Date: Wed, 15 Apr 2015 21:48:06 +0000 Subject: [PATCH] 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) --- etc/rc.d/hostid_save | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/etc/rc.d/hostid_save b/etc/rc.d/hostid_save index fca0521e8b24..9741aec09f82 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