aboutsummaryrefslogtreecommitdiff
path: root/libexec/rc/rc.d/machine_id
blob: 7cfd7b2d92f850f4e42cdd7bfad35485cee4f700 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: machine_id
# REQUIRE: mountcritremote FILESYSTEMS
# BEFORE:  LOGIN

. /etc/rc.subr

: ${machine_id_file:=/var/db/machine-id}
: ${machine_id_perms:=444}
name="machine_id"
desc="Update ${machine_id_file}"
rcvar="machine_id_enable"
start_cmd="machine_id_start"
stop_cmd=":"


machine_id_start()
{
	if [ ! -f ${machine_id_file} ] ; then
		startmsg -n "Creating ${machine_id_file} "
		t=$(mktemp -t machine-id)
		/bin/uuidgen -r -o $t
		install -C -o root -g wheel -m ${machine_id_perms} "$t" "${machine_id_file}"
		rm -f "$t"
		startmsg 'done.'
	fi
}

load_rc_config $name
run_rc_command "$1"