Replace literal uses of /usr/local with a variable

The variable defaults to "/usr/local", unless sysctl returns some other
value for "user.localbase".

The value of user.localbase defaults to _PATH_LOCALBASE as defined in
paths.h and thus this commit has no immediate effect.

The purpose of this change is to make /etc/defaults/rc.conf automatically
use the value of _PATH_LOCALBASE when not set to the default value.

Reviewed by:	imp, scottl
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D27014
This commit is contained in:
Stefan Eßer 2020-11-03 12:29:10 +00:00
parent f1560bd080
commit 08867050c9
2 changed files with 12 additions and 7 deletions

View File

@ -59,6 +59,8 @@ else
_boot="quietstart"
fi
_localbase=`/sbin/sysctl -n user.localbase 2> /dev/null`
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
if [ ${dlv:=0} -ne 0 -o -f /etc/diskless ]; then
sh /etc/rc.initdiskless

View File

@ -21,6 +21,9 @@
### Important initial Boot-time options ####################
##############################################################
# Set default value of _localbase if not previously set
: ${_localbase:="/usr/local"}
# rc_debug can't be set here without interferring with rc.subr's setting it
# when the kenv variable rc.debug is set.
#rc_debug="NO" # Set to YES to enable debugging output from rc.d
@ -58,7 +61,7 @@ varmfs_flags="-S" # Extra mount options for the mfs /var
mfs_type="auto" # "md", "tmpfs", "auto" to prefer tmpfs with md as fallback
populate_var="AUTO" # Set to YES to always (re)populate /var, NO to never
cleanvar_enable="YES" # Clean the /var directory
local_startup="/usr/local/etc/rc.d" # startup script dirs.
local_startup="${_localbase}/etc/rc.d" # startup script dirs.
script_name_sep=" " # Change if your startup scripts' names contain spaces
rc_conf_files="/etc/rc.conf /etc/rc.conf.local"
@ -188,7 +191,7 @@ ipfw_netflow_enable="NO" # Enable netflow logging via ng_netflow
ip_portrange_first="NO" # Set first dynamically allocated port
ip_portrange_last="NO" # Set last dynamically allocated port
ike_enable="NO" # Enable IKE daemon (usually racoon or isakmpd)
ike_program="/usr/local/sbin/isakmpd" # Path to IKE daemon
ike_program="${_localbase}/sbin/isakmpd" # Path to IKE daemon
ike_flags="" # Additional flags for IKE daemon
ipsec_enable="NO" # Set to YES to run setkey on ipsec_file
ipsec_file="/etc/ipsec.conf" # Name of config file for setkey
@ -647,19 +650,19 @@ linux_mounts_enable="YES" # If linux_enable is set to YES, mount Linux-specific
clear_tmp_enable="NO" # Clear /tmp at startup.
clear_tmp_X="YES" # Clear and recreate X11-related directories in /tmp
ldconfig_insecure="NO" # Set to YES to disable ldconfig security checks
ldconfig_paths="/usr/lib/compat /usr/local/lib /usr/local/lib/compat/pkg"
ldconfig_paths="/usr/lib/compat ${_localbase}/lib ${_localbase}/lib/compat/pkg"
# shared library search paths
ldconfig32_paths="/usr/lib32 /usr/lib32/compat"
# 32-bit compatibility shared library search paths
ldconfigsoft_paths="/usr/libsoft /usr/libsoft/compat /usr/local/libsoft"
ldconfigsoft_paths="/usr/libsoft /usr/libsoft/compat ${_localbase}/libsoft"
# soft float compatibility shared library search paths
# Note: temporarily with extra stuff for transition
ldconfig_local_dirs="/usr/local/libdata/ldconfig"
ldconfig_local_dirs="${_localbase}/libdata/ldconfig"
# Local directories with ldconfig configuration files.
ldconfig_local32_dirs="/usr/local/libdata/ldconfig32"
ldconfig_local32_dirs="${_localbase}/libdata/ldconfig32"
# Local directories with 32-bit compatibility ldconfig
# configuration files.
ldconfig_localsoft_dirs="/usr/local/libdata/ldconfigsoft"
ldconfig_localsoft_dirs="${_localbase}/libdata/ldconfigsoft"
# Local directories with soft float compatibility ldconfig
# configuration files.
kern_securelevel_enable="NO" # kernel security level (see security(7))