xref: /freebsd/libexec/rc/rc.d/os-release (revision 6467506baf5c2958d7d19546cf4076d19a8586c2)
1*6467506bSWarner Losh#!/bin/sh
2*6467506bSWarner Losh#
3*6467506bSWarner Losh# $FreeBSD$
4*6467506bSWarner Losh#
5*6467506bSWarner Losh
6*6467506bSWarner Losh# PROVIDE: os-release
7*6467506bSWarner Losh# REQUIRE: mountcritremote FILESYSTEMS
8*6467506bSWarner Losh# BEFORE:  LOGIN
9*6467506bSWarner Losh
10*6467506bSWarner Losh. /etc/rc.subr
11*6467506bSWarner Losh
12*6467506bSWarner Losh: ${osrelease_file:=/var/run/os-release}
13*6467506bSWarner Losh: ${osrelease_perms:=444}
14*6467506bSWarner Loshname="osrelease"
15*6467506bSWarner Loshdesc="Update ${osrelease_file}"
16*6467506bSWarner Loshstart_cmd="osrelease_start"
17*6467506bSWarner Loshstop_cmd=":"
18*6467506bSWarner Losh
19*6467506bSWarner Loshosrelease_start()
20*6467506bSWarner Losh{
21*6467506bSWarner Losh	local _version _version_id
22*6467506bSWarner Losh
23*6467506bSWarner Losh	check_startmsgs && echo -n "Updating ${osrelease_file} "
24*6467506bSWarner Losh	_version=$(freebsd-version -u)
25*6467506bSWarner Losh	_version_id=${_version%%[^0-9.]*}
26*6467506bSWarner Losh	t=$(mktemp -t os-release)
27*6467506bSWarner Losh	cat > "$t" <<-__EOF__
28*6467506bSWarner Losh		NAME=FreeBSD
29*6467506bSWarner Losh		VERSION=$_version
30*6467506bSWarner Losh		VERSION_ID=$_version_id
31*6467506bSWarner Losh		ID=freebsd
32*6467506bSWarner Losh		ANSI_COLOR="0;31"
33*6467506bSWarner Losh		PRETTY_NAME="FreeBSD $_version"
34*6467506bSWarner Losh		CPE_NAME=cpe:/o:freebsd:freebsd:$_version_id
35*6467506bSWarner Losh		HOME_URL=https://FreeBSD.org/
36*6467506bSWarner Losh		BUG_REPORT_URL=https://bugs.FreeBSD.org/
37*6467506bSWarner Losh__EOF__
38*6467506bSWarner Losh	install -C -o root -g wheel -m ${osrelease_perms} "$t" "${osrelease_file}"
39*6467506bSWarner Losh	rm -f "$t"
40*6467506bSWarner Losh	check_startmsgs && echo 'done.'
41*6467506bSWarner Losh}
42*6467506bSWarner Losh
43*6467506bSWarner Loshload_rc_config $name
44*6467506bSWarner Loshrun_rc_command "$1"
45