diff options
author | delphij <delphij@FreeBSD.org> | 2015-04-15 21:48:06 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2015-04-15 21:48:06 +0000 |
commit | 404cb28d68faf12d79dd4a83068946561d77ebdd (patch) | |
tree | 956e58de703da00ecf4e23bf88206981192f9535 /etc | |
parent | ac2c19f7217d2592521bab48c9b29a676873fae8 (diff) | |
download | FreeBSD-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')
-rwxr-xr-x | etc/rc.d/hostid_save | 15 |
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 |