1#!/bin/sh 2# 3# $FreeBSD$ 4# 5 6# PROVIDE: hostid_save 7# REQUIRE: hostid root 8# KEYWORD: nojail 9 10. /etc/rc.subr 11 12name="hostid_save" 13desc="Save unique host ID to disk" 14start_cmd="hostid_save" 15stop_cmd=":" 16rcvar="hostid_enable" 17 18hostid_machine_id() 19{ 20 local IFS 21 22 IFS=- 23 set -- ${current_hostid} 24 IFS= 25 current_machine_id=$* 26} 27 28hostid_save() 29{ 30 current_hostid=`$SYSCTL_N kern.hostuuid` 31 32 read saved_hostid 2>/dev/null < ${hostid_file} 33 if [ "${saved_hostid}" != "${current_hostid}" ]; then 34 echo "${current_hostid}" > ${hostid_file} || 35 warn "could not store hostuuid in ${hostid_file}." 36 fi 37 38 hostid_machine_id 39 40 read saved_machine_id 2>/dev/null < ${machine_id_file} 41 if [ "${saved_machine_id}" != "${current_machine_id}" ]; then 42 echo "${current_machine_id}" > ${machine_id_file} || 43 warn "could not store hostuuid in ${machine_id_file}." 44 fi 45} 46 47load_rc_config $name 48run_rc_command "$1" 49