literal name_enable wherever possible, and ${name}_enable
when it's not, to prepare for the demise of set_rcvar().
In cases where I had to hand-edit unusual instances also
modify formatting slightly to be more uniform (and in
some cases, correct). This includes adding some $FreeBSD$
tags, and most importantly moving rcvar= to right after
name= so it's clear that one is derived from the other.
55 lines
1.0 KiB
Bash
55 lines
1.0 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: devcpu
|
|
# REQUIRE: root mountcritlocal
|
|
# KEYWORD: nojail
|
|
|
|
#
|
|
# Add the following line to /etc/rc.conf to enable flow-capture:
|
|
# devcpu_enable (bool): Set it to "YES" to update cpucodes on startup
|
|
# Set to "NO" by default.
|
|
# devcpu_datadir (str): Directory, cpucode updates stored in.
|
|
# Default is "%%DATADIR%%"
|
|
# devcpu_cpus (str): A list of cpus to update on startup, or "-a" for all.
|
|
# Example: devcpu_cpus="cpu0 /dev/cpu1"
|
|
# Set to "-a" by default.
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="devcpu"
|
|
rcvar=devcpu_enable
|
|
stop_cmd=":"
|
|
start_precmd="devcpu_prepare"
|
|
start_cmd="devcpu_start"
|
|
requires_modules="cpu"
|
|
|
|
CMT="%%PREFIX%%/bin/cpu_microcode_tool"
|
|
|
|
devcpu_prepare()
|
|
{
|
|
if ! kldstat -q -m cpu; then
|
|
if ! kldload cpu > /dev/null 2>&1; then
|
|
warn "Can't load cpu module."
|
|
return 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
devcpu_start()
|
|
{
|
|
echo "Updating cpucodes."
|
|
${CMT} -I "${devcpu_datadir}" ${devcpu_cpus}
|
|
}
|
|
|
|
load_rc_config $name
|
|
|
|
# Set default values
|
|
: ${devcpu_enable="NO"}
|
|
: ${devcpu_datadir="%%DATADIR%%"}
|
|
: ${devcpu_cpus="-a"}
|
|
|
|
run_rc_command "$1"
|