diff options
Diffstat (limited to 'libexec/rc/rc.d/hostid')
-rwxr-xr-x | libexec/rc/rc.d/hostid | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libexec/rc/rc.d/hostid b/libexec/rc/rc.d/hostid index 39a0f4acb498..0210ca433501 100755 --- a/libexec/rc/rc.d/hostid +++ b/libexec/rc/rc.d/hostid @@ -24,7 +24,6 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD$ # # PROVIDE: hostid @@ -106,6 +105,8 @@ hostid_hardware() if valid_hostid $uuid; then echo "${uuid}" + elif [ "$uuid" ]; then + echo "INVALID" fi } @@ -113,11 +114,18 @@ hostid_generate() { # First look for UUID in hardware. uuid=`hostid_hardware` - if [ -z "${uuid}" ]; then + + # Warn about invalid UUIDs + if [ "${uuid}" = "INVALID" ]; then warn "hostid: unable to figure out a UUID from DMI data, generating a new one" sleep 2 + uuid="" + fi + + # Generate a random UUID if invalid or not found + if [ -z "${uuid}" ]; then # If not found, fall back to software-generated UUID. - uuid=`uuidgen` + uuid=`uuidgen ${hostid_uuidgen_flags}` fi hostid_set $uuid } |