hostid (180563) | hostid (195938) |
---|---|
1#!/bin/sh 2# 3# Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# | 1#!/bin/sh 2# 3# Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# |
27# $FreeBSD: head/etc/rc.d/hostid 180563 2008-07-16 19:22:48Z dougb $ | 27# $FreeBSD: head/etc/rc.d/hostid 195938 2009-07-29 05:23:52Z pjd $ |
28# 29 30# PROVIDE: hostid | 28# 29 30# PROVIDE: hostid |
31# REQUIRE: root 32# BEFORE: mountcritlocal | 31# BEFORE: fsck |
33# KEYWORD: nojail 34 35. /etc/rc.subr 36 37name="hostid" 38start_cmd="hostid_start" 39stop_cmd=":" 40reset_cmd="hostid_reset" --- 22 unchanged lines hidden (view full) --- 63 y=$x$x$x$x 64 case "${uuid}" in 65 $y$y-$y-$y-$y-$y$y$y) 66 echo "${uuid}" 67 ;; 68 esac 69} 70 | 32# KEYWORD: nojail 33 34. /etc/rc.subr 35 36name="hostid" 37start_cmd="hostid_start" 38stop_cmd=":" 39reset_cmd="hostid_reset" --- 22 unchanged lines hidden (view full) --- 62 y=$x$x$x$x 63 case "${uuid}" in 64 $y$y-$y-$y-$y-$y$y$y) 65 echo "${uuid}" 66 ;; 67 esac 68} 69 |
71hostid_reset() | 70hostid_generate() |
72{ 73 # First look for UUID in hardware. 74 uuid=`hostid_hardware` 75 if [ -z ${uuid} ]; then 76 # If not found, fall back to software-generated UUID. 77 uuid=`uuidgen` 78 fi | 71{ 72 # First look for UUID in hardware. 73 uuid=`hostid_hardware` 74 if [ -z ${uuid} ]; then 75 # If not found, fall back to software-generated UUID. 76 uuid=`uuidgen` 77 fi |
78 hostid_set $uuid 79} 80 81hostid_reset() 82{ 83 hostid_generate |
|
79 # Store newly generated UUID in ${hostid_file}. 80 echo $uuid > ${hostid_file} 81 if [ $? -ne 0 ]; then 82 warn "could not store hostuuid in ${hostid_file}." 83 fi | 84 # Store newly generated UUID in ${hostid_file}. 85 echo $uuid > ${hostid_file} 86 if [ $? -ne 0 ]; then 87 warn "could not store hostuuid in ${hostid_file}." 88 fi |
84 hostid_set $uuid | |
85} 86 87hostid_start() 88{ 89 # If ${hostid_file} already exists, we take UUID from there. 90 if [ -r ${hostid_file} ]; then 91 hostid_set `cat ${hostid_file}` 92 else 93 # No hostid file, generate UUID. | 89} 90 91hostid_start() 92{ 93 # If ${hostid_file} already exists, we take UUID from there. 94 if [ -r ${hostid_file} ]; then 95 hostid_set `cat ${hostid_file}` 96 else 97 # No hostid file, generate UUID. |
94 hostid_reset | 98 hostid_generate |
95 fi 96} 97 98load_rc_config $name 99run_rc_command "$1" | 99 fi 100} 101 102load_rc_config $name 103run_rc_command "$1" |