Add a helper function to check kern.features.* sysctls.
Discussed with: dougb
This commit is contained in:
parent
90dc53a6f0
commit
d3ae0231fe
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=222996
@ -349,11 +349,8 @@ afexists()
|
|||||||
_af=$1
|
_af=$1
|
||||||
|
|
||||||
case ${_af} in
|
case ${_af} in
|
||||||
inet)
|
inet|inet6)
|
||||||
${SYSCTL_N} kern.features.inet > /dev/null 2>&1
|
check_kern_features ${_af}
|
||||||
;;
|
|
||||||
inet6)
|
|
||||||
${SYSCTL_N} kern.features.inet6 > /dev/null 2>&1
|
|
||||||
;;
|
;;
|
||||||
ipx)
|
ipx)
|
||||||
${SYSCTL_N} net.ipx > /dev/null 2>&1
|
${SYSCTL_N} net.ipx > /dev/null 2>&1
|
||||||
|
22
etc/rc.subr
22
etc/rc.subr
@ -1734,6 +1734,28 @@ check_required_after()
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check_kern_features mib
|
||||||
|
# Return existence of kern.features.* sysctl MIB as true or
|
||||||
|
# false. The result will be cached in $_rc_cache_kern_features_
|
||||||
|
# namespace. "0" means the kern.features.X exists.
|
||||||
|
|
||||||
|
check_kern_features()
|
||||||
|
{
|
||||||
|
local _v
|
||||||
|
|
||||||
|
[ -n "$1" ] || return 1;
|
||||||
|
_v=`eval echo "\\$_rc_cache_kern_features_$1"`
|
||||||
|
[ -n "$_v" ] && return "$_v";
|
||||||
|
|
||||||
|
if ${SYSCTL_N} kern.features.$1 > /dev/null 2>&1; then
|
||||||
|
eval _rc_cache_kern_features_$1=0
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
eval _rc_cache_kern_features_$1=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# _echoonce var msg mode
|
# _echoonce var msg mode
|
||||||
# mode=0: Echo $msg if ${$var} is empty.
|
# mode=0: Echo $msg if ${$var} is empty.
|
||||||
# After doing echo, a string is set to ${$var}.
|
# After doing echo, a string is set to ${$var}.
|
||||||
|
Loading…
Reference in New Issue
Block a user