]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/rc/rc.d/machine_id
hostid: Generate random UUID by default
[FreeBSD/FreeBSD.git] / libexec / rc / rc.d / machine_id
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: machine_id
7 # REQUIRE: mountcritremote FILESYSTEMS
8 # BEFORE:  LOGIN
9
10 . /etc/rc.subr
11
12 : ${machine_id_file:=/var/db/machine-id}
13 : ${machine_id_perms:=444}
14 name="machine_id"
15 desc="Update ${machine_id_file}"
16 rcvar="machine_id_enable"
17 start_cmd="machine_id_start"
18 stop_cmd=":"
19
20
21 machine_id_start()
22 {
23         if [ ! -f ${machine_id_file} ] ; then
24                 startmsg -n "Creating ${machine_id_file} "
25                 t=$(mktemp -t machine-id)
26                 /bin/uuidgen -r -c -o $t
27                 install -C -o root -g wheel -m ${machine_id_perms} "$t" "${machine_id_file}"
28                 rm -f "$t"
29                 startmsg 'done.'
30         fi
31 }
32
33 load_rc_config $name
34 run_rc_command "$1"