rc.conf: Use user.localbase to determine _localbase

When running an rc.d script outside of boot, ${_localbase} isn't set,
and rc.conf hardcodes the default value to /usr/local.  Instead, try
to get the localbase from the user.localbase sysctl, and only fall
back to /usr/local if we can't for some reason.

This fixes e.g. /etc/rc.d/ldconfig when localbase has a non-default
value.

Reviewed by:		imp, des
Differential Revision:	https://reviews.freebsd.org/D51852
This commit is contained in:
Lexi Winter
2025-08-10 13:24:03 +01:00
parent c8cf8d851c
commit 5467020a54
+1
View File
@@ -21,6 +21,7 @@
##############################################################
# Set default value of _localbase if not previously set
: ${_localbase:="$(/sbin/sysctl -n user.localbase 2> /dev/null)"}
: ${_localbase:="/usr/local"}
# rc_debug can't be set here without interferring with rc.subr's setting it