xref: /freebsd/libexec/rc/rc.d/os-release (revision f99f0ee14e3af81c23150a6a340259ca8a33d01a)
1 #!/bin/sh
2 #
3 #
4 
5 # PROVIDE: os-release
6 # REQUIRE: mountcritremote FILESYSTEMS
7 # BEFORE:  LOGIN
8 
9 . /etc/rc.subr
10 
11 : ${osrelease_file:=/var/run/os-release}
12 : ${osrelease_perms:=444}
13 name="osrelease"
14 desc="Update ${osrelease_file}"
15 rcvar="osrelease_enable"
16 start_cmd="osrelease_start"
17 stop_cmd=":"
18 
19 osrelease_start()
20 {
21 	local _version _version_id
22 
23 	startmsg -n "Updating ${osrelease_file} "
24 	_version=$(freebsd-version -u)
25 	_version_id=${_version%%[^0-9.]*}
26 	t=$(mktemp -t os-release)
27 	cat > "$t" <<-__EOF__
28 		NAME=FreeBSD
29 		VERSION="$_version"
30 		VERSION_ID="$_version_id"
31 		ID=freebsd
32 		ANSI_COLOR="0;31"
33 		PRETTY_NAME="FreeBSD $_version"
34 		CPE_NAME="cpe:/o:freebsd:freebsd:$_version_id"
35 		HOME_URL="https://FreeBSD.org/"
36 		BUG_REPORT_URL="https://bugs.FreeBSD.org/"
37 __EOF__
38 	install -C -o root -g wheel -m ${osrelease_perms} "$t" "${osrelease_file}"
39 	rm -f "$t"
40 	startmsg 'done.'
41 }
42 
43 load_rc_config $name
44 
45 # doesn't make sense to run in a svcj: config setting
46 osrelease_svcj="NO"
47 
48 run_rc_command "$1"
49