]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/hostid_save
Merge branch 'releng/11.3' into releng-CDN/11.3
[FreeBSD/FreeBSD.git] / etc / 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_save()
19 {
20         current_hostid=`$SYSCTL_N kern.hostuuid`
21
22         if [ -r ${hostid_file} ]; then
23                 read saved_hostid < ${hostid_file}
24                 if [ ${saved_hostid} = ${current_hostid} ]; then
25                         exit 0
26                 fi
27         fi
28
29         echo ${current_hostid} > ${hostid_file}
30         if [ $? -ne 0 ]; then
31                 warn "could not store hostuuid in ${hostid_file}."
32         fi
33 }
34
35 load_rc_config $name
36 run_rc_command "$1"