git: c204fdb1c859 - stable/13 - periodic: set _localbase for periodic scripts from within periodic.conf
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 11 Feb 2025 13:48:53 UTC
The branch stable/13 has been updated by otis:
URL: https://cgit.FreeBSD.org/src/commit/?id=c204fdb1c859847ff972acdcadf6002759038e11
commit c204fdb1c859847ff972acdcadf6002759038e11
Author: Juraj Lutter <otis@FreeBSD.org>
AuthorDate: 2024-11-08 13:38:19 +0000
Commit: Juraj Lutter <otis@FreeBSD.org>
CommitDate: 2025-02-11 13:48:14 +0000
periodic: set _localbase for periodic scripts from within periodic.conf
Set _localbase variable from within /etc/defaults/periodic.conf
for use by periodic scripts.
This fixes e5d7100c09, no other functional changes intended.
Reported by: gahr, otis
Reviewed by: markj, gahr
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D47486
(cherry picked from commit c8b89c11a1181e900acb638cfde7a55e92553175)
---
usr.sbin/periodic/periodic.conf | 9 +++++++++
usr.sbin/periodic/periodic.sh | 12 ++++--------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/usr.sbin/periodic/periodic.conf b/usr.sbin/periodic/periodic.conf
index 088e3c612e70..36b3ff5b0070 100644
--- a/usr.sbin/periodic/periodic.conf
+++ b/usr.sbin/periodic/periodic.conf
@@ -15,6 +15,15 @@
#
#
+_set_localbase() {
+ _localbase=`/sbin/sysctl -n user.localbase 2> /dev/null`
+ # Set default value of _localbase if not previously set
+ : ${_localbase:="/usr/local"}
+}
+
+# Set _localbase with fallback to /usr/local
+_set_localbase
+
# What files override these defaults ?
periodic_conf_files="/etc/periodic.conf /etc/periodic.conf.local ${_localbase}/etc/periodic.conf"
diff --git a/usr.sbin/periodic/periodic.sh b/usr.sbin/periodic/periodic.sh
index a45d6af73691..0a78a930b4b6 100644
--- a/usr.sbin/periodic/periodic.sh
+++ b/usr.sbin/periodic/periodic.sh
@@ -29,14 +29,6 @@ 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
@@ -44,6 +36,10 @@ if [ -r /etc/defaults/periodic.conf ]; then
source_periodic_confs
fi
+# 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
+
host=`hostname`
export host