]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/rc/rc.d/hostid_save
ssh: Update to OpenSSH 9.3p1
[FreeBSD/FreeBSD.git] / libexec / rc / rc.d / hostid_save
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
12 name="hostid_save"
13 desc="Save unique host ID to disk"
14 start_cmd="hostid_save"
15 stop_cmd=":"
16 rcvar="hostid_enable"
17
18 hostid_machine_id()
19 {
20         local IFS
21
22         IFS=-
23         set -- ${current_hostid}
24         IFS=
25         current_machine_id=$*
26 }
27
28 hostid_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
47 load_rc_config $name
48 run_rc_command "$1"