Date: Tue, 3 Oct 2000 03:32:45 +0200 From: Neil Blakey-Milner <nbm@mithrandr.moria.org> To: FreeBSD Hackers <hackers@FreeBSD.org> Cc: Doug Barton <DougB@gorean.org>, Sheldon Hearn <sheldonh@uunet.co.za> Subject: Making /etc/defaults/rc.conf a configuration file. Message-ID: <20001003033245.A63319@mithrandr.moria.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi,
With these patches, and the new tiny util 'sourceconf', we can make
/etc/defaults/rc.conf and /etc/defaults/periodic.conf configuration
files again, such that they can be parsed by things other than 'sh'.
It also allows you to set 'rc_conf_files' (or, actually, whatever you
set filevar to) in lower places than the default file, so that you don't
change the default file.
This only shows how to replace things using rc.conf - changing scripts
to use periodic.conf is as simple as replacing
if [ -r /etc/defaults/periodic.conf ]
then
. /etc/defaults/periodic.conf
source_periodic_confs
fi
with
rcfile=/etc/defaults/periodic.conf listvar=periodic_conf_files . /etc/sourceconf
Neil
--
Neil Blakey-Milner
Sunesi Clinical Systems
nbm@mithrandr.moria.org
[-- Attachment #2 --]
Index: etc/netstart
===================================================================
RCS file: /home/ncvs/src/etc/netstart,v
retrieving revision 1.55
diff -u -r1.55 netstart
--- etc/netstart 2000/04/27 08:43:47 1.55
+++ etc/netstart 2000/10/03 01:14:04
@@ -9,13 +9,9 @@
# the network by hand, this script will do it for you).
#
-# If there is a global system configuration file, suck it in.
-if [ -f /etc/defaults/rc.conf ]; then
- . /etc/defaults/rc.conf
- source_rc_confs
-elif [ -f /etc/rc.conf ]; then
- . /etc/rc.conf
-fi
+# Suck in the configuration variables
+#
+. /etc/sourceconf
if [ -f /etc/rc.network ]; then
. /etc/rc.network
Index: etc/pccard_ether
===================================================================
RCS file: /home/ncvs/src/etc/pccard_ether,v
retrieving revision 1.18
diff -u -r1.18 pccard_ether
--- etc/pccard_ether 2000/09/07 03:06:06 1.18
+++ etc/pccard_ether 2000/10/03 01:02:26
@@ -9,12 +9,7 @@
# Suck in the configuration variables
#
-if [ -r /etc/defaults/rc.conf ]; then
- . /etc/defaults/rc.conf
- source_rc_confs
-elif [ -r /etc/rc.conf ]; then
- . /etc/rc.conf
-fi
+. /etc/sourceconf
interface=$1
shift
Index: etc/rc
===================================================================
RCS file: /home/ncvs/src/etc/rc,v
retrieving revision 1.230
diff -u -r1.230 rc
--- etc/rc 2000/08/21 14:37:52 1.230
+++ etc/rc 2000/10/03 01:13:43
@@ -34,14 +34,9 @@
fi
fi
-# If there is a global system configuration file, suck it in.
+# Suck in the configuration variables
#
-if [ -r /etc/defaults/rc.conf ]; then
- . /etc/defaults/rc.conf
- source_rc_confs
-elif [ -r /etc/rc.conf ]; then
- . /etc/rc.conf
-fi
+. /etc/sourceconfs
# Configure ccd devices.
#
@@ -564,18 +559,13 @@
echo .
# Do traditional (but rather obsolete) rc.local file if it exists. If you
-# use this file and want to make it programmatic, source /etc/defaults/rc.conf
+# use this file and want to make it programmatic, source /etc/sourceconf
# in /etc/rc.local and add your custom variables to /etc/rc.conf, as
# shown below. Please do not put local extensions into /etc/rc itself.
# Use /etc/rc.local
#
# ---- rc.local ----
-# if [ -r /etc/defaults/rc.conf ]; then
-# . /etc/defaults/rc.conf
-# source_rc_confs
-# elif [ -r /etc/rc.conf ]; then
-# . /etc/rc.conf
-# fi
+# . /etc/sourceconf
#
# ... additional startup conditionals ...
# ---- rc.local ----
Index: etc/rc.devfs
===================================================================
RCS file: /home/ncvs/src/etc/rc.devfs,v
retrieving revision 1.8
diff -u -r1.8 rc.devfs
--- etc/rc.devfs 2000/04/27 08:43:48 1.8
+++ etc/rc.devfs 2000/10/03 01:14:34
@@ -1,14 +1,9 @@
#
# $FreeBSD: src/etc/rc.devfs,v 1.8 2000/04/27 08:43:48 sheldonh Exp $
#
-# If there is a global system configuration file, suck it in.
+# Suck in the configuration variables
#
-if [ -r /etc/defaults/rc.conf ]; then
- . /etc/defaults/rc.conf
- source_rc_confs
-elif [ -r /etc/rc.conf ]; then
- . /etc/rc.conf
-fi
+. /etc/sourceconf
# Setup DEVFS, ie permissions, links etc.
#
Index: etc/rc.diskless2
===================================================================
RCS file: /home/ncvs/src/etc/rc.diskless2,v
retrieving revision 1.6
diff -u -r1.6 rc.diskless2
--- etc/rc.diskless2 2000/04/27 08:43:48 1.6
+++ etc/rc.diskless2 2000/10/03 01:04:43
@@ -5,12 +5,7 @@
# If there is a global system configuration file, suck it in.
#
-if [ -r /etc/defaults/rc.conf ]; then
- . /etc/defaults/rc.conf
- source_rc_confs
-elif [ -r /etc/rc.conf ]; then
- . /etc/rc.conf
-fi
+. /etc/sourceconf
mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
Index: etc/rc.firewall
===================================================================
RCS file: /home/ncvs/src/etc/rc.firewall,v
retrieving revision 1.37
diff -u -r1.37 rc.firewall
--- etc/rc.firewall 2000/08/30 13:14:32 1.37
+++ etc/rc.firewall 2000/10/03 01:04:57
@@ -3,12 +3,7 @@
# $FreeBSD: src/etc/rc.firewall,v 1.37 2000/08/30 13:14:32 ru Exp $
# Suck in the configuration variables.
-if [ -r /etc/defaults/rc.conf ]; then
- . /etc/defaults/rc.conf
- source_rc_confs
-elif [ -r /etc/rc.conf ]; then
- . /etc/rc.conf
-fi
+. /etc/sourceconf
############
# Define the firewall type in /etc/rc.conf. Valid values are:
Index: etc/rc.shutdown
===================================================================
RCS file: /home/ncvs/src/etc/rc.shutdown,v
retrieving revision 1.11
diff -u -r1.11 rc.shutdown
--- etc/rc.shutdown 2000/08/18 10:34:11 1.11
+++ etc/rc.shutdown 2000/10/03 01:14:46
@@ -17,14 +17,9 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
export HOME PATH
-# If there is a global system configuration file, suck it in.
+# Suck in the configuration variables
#
-if [ -r /etc/defaults/rc.conf ]; then
- . /etc/defaults/rc.conf
- source_rc_confs
-elif [ -r /etc/rc.conf ]; then
- . /etc/rc.conf
-fi
+. /etc/sourceconf
# Write some entropy so the rebooting /dev/random can reseed
#
Index: etc/defaults/rc.conf
===================================================================
RCS file: /home/ncvs/src/etc/defaults/rc.conf,v
retrieving revision 1.78
diff -u -r1.78 rc.conf
--- etc/defaults/rc.conf 2000/09/01 01:08:52 1.78
+++ etc/defaults/rc.conf 2000/10/03 01:23:32
@@ -298,28 +298,3 @@
start_vinum="" # set to YES to start vinum
entropy_file="/var/db/entropy"
# Set to NO to disable caching entropy through reboots
-
-##############################################################
-### Define source_rc_confs, the mechanism used by /etc/rc.* ##
-### scripts to source rc_conf_files overrides safely. ##
-##############################################################
-
-if [ -z "${source_rc_confs_defined}" ]; then
- source_rc_confs_defined=yes
- source_rc_confs ( ) {
- local i sourced_files
- for i in ${rc_conf_files}; do
- case ${sourced_files} in
- *:$i:*)
- ;;
- *)
- sourced_files="${sourced_files}:$i:"
- if [ -r $i ]; then
- . $i
- fi
- ;;
- esac
- done
- }
-fi
-
[-- Attachment #3 --]
#!/bin/sh
#
# Copyright (c) 2000 Neil Blakey-Milner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Original code by Doug Barton <Doug@gorean.org>
#
sourceconf_decho ( ) {
case "$sourceconf_debug" in
'')
;;
*)
echo $*
;;
esac
}
sourceconf_dosrc ( ) {
local ${listvar}
for i in $*; do
case "${sourceconf_sourced_files}" in
*:$i:*)
;;
*)
sourceconf_sourced_files="${sourceconf_sourced_files}:$i:"
sourceconf_decho $i
if [ -r $i ]; then
. $i
eval sourceconf_dosrc \$${listvar}
fi
;;
esac
done
}
sourceconf_start ( ) {
local rcfile
local sourceconf_sourced_files
local listvar
sourceconf_sourced_files=
case "$rcfile" in
'')
rcfile=/etc/defaults/rc.conf
;;
esac
case "$listvar" in
'')
listvar=rc_conf_files
;;
esac
sourceconf_dosrc $rcfile
}
sourceconf_start
unset sourceconf_start
unset sourceconf_dosrc
unset sourceconf_decho
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001003033245.A63319>
