git: 9000459d3bc2 - stable/13 - periodic: Honor kern.localbase
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 06 Jul 2023 07:57:44 UTC
The branch stable/13 has been updated by otis: URL: https://cgit.FreeBSD.org/src/commit/?id=9000459d3bc2816df3525cda8d3fa4eee6c92b26 commit 9000459d3bc2816df3525cda8d3fa4eee6c92b26 Author: Juraj Lutter <otis@FreeBSD.org> AuthorDate: 2023-06-06 11:40:49 +0000 Commit: Juraj Lutter <otis@FreeBSD.org> CommitDate: 2023-07-06 07:56:35 +0000 periodic: Honor kern.localbase Take kern.localbase into account with fallback to /usr/local and also allow for LOCALBASE/etc/periodic.conf (similarly to what many other utilities do). Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D40435 (cherry picked from commit e5d7100c09e03e66535eee69d7e454c01e4a9d28) --- usr.sbin/periodic/periodic.8 | 9 +++++++-- usr.sbin/periodic/periodic.conf | 6 +++--- usr.sbin/periodic/periodic.sh | 8 ++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/usr.sbin/periodic/periodic.8 b/usr.sbin/periodic/periodic.8 index 2fda1db157f5..fd09fbf1b368 100644 --- a/usr.sbin/periodic/periodic.8 +++ b/usr.sbin/periodic/periodic.8 @@ -183,7 +183,7 @@ and the standard and .Pa security scripts -.It Pa /etc/periodic.conf +.It Pa /etc/periodic.conf , ${LOCALBASE}/etc/periodic.conf this file contains local overrides for the default .Nm configuration @@ -207,7 +207,12 @@ system registry will typically have a .Va local_periodic variable reading: .Pp -.Dl local_periodic="/usr/local/etc/periodic" +.Dl local_periodic="${_localbase}/etc/periodic" +.Pp +where +.Pa ${_localbase} +is being set from within +.Pa /usr/sbin/periodic . .Pp To log .Nm diff --git a/usr.sbin/periodic/periodic.conf b/usr.sbin/periodic/periodic.conf index 4429c8d48eea..c14f4dd001db 100644 --- a/usr.sbin/periodic/periodic.conf +++ b/usr.sbin/periodic/periodic.conf @@ -17,10 +17,10 @@ # # What files override these defaults ? -periodic_conf_files="/etc/periodic.conf /etc/periodic.conf.local" +periodic_conf_files="/etc/periodic.conf /etc/periodic.conf.local ${_localbase}/etc/periodic.conf" -# periodic script dirs -local_periodic="/usr/local/etc/periodic" +# periodic script dirs. _localbase is being set in /usr/sbin/periodic +local_periodic="${_localbase}/etc/periodic" # Max time to sleep to avoid causing congestion on download servers anticongestion_sleeptime=3600 diff --git a/usr.sbin/periodic/periodic.sh b/usr.sbin/periodic/periodic.sh index 84e14e9cfd80..97de8192dd28 100644 --- a/usr.sbin/periodic/periodic.sh +++ b/usr.sbin/periodic/periodic.sh @@ -30,6 +30,14 @@ if [ $# -lt 1 ] ; then usage fi +_localbase=`/sbin/sysctl -n user.localbase 2> /dev/null` +# Set default value of _localbase if not previously set +: ${_localbase:="/usr/local"} + +# Use a deterministic path to match the preset from /etc/crontab in case +# periodic is run interactively. +export PATH=/sbin:/bin:/usr/sbin:/usr/bin:${_localbase}/sbin:${_localbase}/bin + # If possible, check the global system configuration file, # to see if there are additional dirs to check if [ -r /etc/defaults/periodic.conf ]; then