rc.d and ports
Mike Makonnen
mtm at identd.net
Mon Feb 23 00:42:31 PST 2004
Hi,
A lot of people have been calling to have ports startup scripts
integrated into rc.d. I have finally gotten arround to doing it.
Attached are the rc.d patches to make it work, but
I will need some cooperation from the ports folks.
Essentialy the rc.d patches will recognize a ports script and source
the appropriate configuration files. From the user's point of view
there will be two major differences:
1. No more fooport.sh-sample files that must be renamed to enable the port
2. Ports can be configured from /etc/rc.conf (or /usr/local/etc/rc.conf).
To make this work here's what's needed from the ports makefiles.
This is just a general sketch of what needs to be done. The
ports folks can do this however they deem appropriate.
The makefile for the port should define a variable:
RCVAR_NAME="fooport_enable"
Then, logic similar to this should be inserted in the appropriate
bsd.port* makefile:
if ! grep 1>/dev/null "\$${RCVAR_NAME}=" ${PREFIX}/etc/defaults/rc.conf ; then
echo "${RCVAR_NAME}=NO" >> ${PREFIX}/etc/defaults/rc.conf
fi
The only difference between a ports and a base system startup
script will be that the ports script will have to call an
additional routine: init_ports_config(). For example:
init_ports_config
load_rc_config $name
run_rc_command "$1"
I know from cursory glances at -current mail that people are divided
on whether to have /usr/local/etc/{rc.conf,rc.conf.d} or to support
only /etc/rc.conf. Both will be supported. It's the user's choice
whether he wants every thing in /etc/rc.conf or /usr/local/etc/rc.conf.
However, a /usr/local/etc/defaults/rc.conf is needed because that is where
the default values for ports config knobs will be kept and because they
should be kept separately from base system knobs.
Comments/Corrections solicited.
Cheers.
--
Mike Makonnen | GPG-KEY: http://www.identd.net/~mtm/mtm.asc
mtm at identd.net | Fingerprint: AC7B 5672 2D11 F4D0 EBF8 5279 5359 2B82 7CD4 1F55
mtm at FreeBSD.Org| FreeBSD - Unleash the Daemon !
-------------- next part --------------
Index: etc/rc.subr
===================================================================
RCS file: /home/ncvs/src/etc/rc.subr,v
retrieving revision 1.19
diff -u -r1.19 rc.subr
--- etc/rc.subr 22 Jan 2004 08:46:03 -0000 1.19
+++ etc/rc.subr 22 Feb 2004 08:14:05 -0000
@@ -844,17 +844,29 @@
if [ -r /etc/defaults/rc.conf ]; then
debug "Sourcing /etc/defaults/rc.conf"
. /etc/defaults/rc.conf
- source_rc_confs
+ source_rc_confs "$rc_conf_files"
elif [ -r /etc/rc.conf ]; then
debug "Sourcing /etc/rc.conf (/etc/defaults/rc.conf doesn't exist)."
. /etc/rc.conf
fi
_rc_conf_loaded=YES
fi
+ if checkyesno freebsd_ports ; then
+ if [ -z "$_rc_ports_conf_loaded ]; then
+ source_rc_confs "$rc_ports_conf_files"
+ fi
+ _rc_ports_conf_loaded=YES
+ fi
if [ -f /etc/rc.conf.d/"$_command" ]; then
debug "Sourcing /etc/rc.conf.d/${_command}"
. /etc/rc.conf.d/"$_command"
fi
+ if checkyesno freebsd_ports ; then
+ if [ -f "${rc_ports_conf_dir}/${_command}" ]; then
+ debug "Sourcing ${rc_ports_conf_dir}/${_command}"
+ . "${rc_ports_conf_dir}/${_command}"
+ fi
+ fi
# XXX - Deprecated variable name support
#
@@ -872,6 +884,40 @@
;;
esac
+}
+
+#
+# source_rc_confs list
+# The mechanism used by /etc/rc.* scripts to source rc_conf_files
+# overrides safely. If the files in list exist and are readable
+# they will be sourced by this routine.
+#
+source_rc_confs ()
+{
+ local i sourced_files file_list
+ file_list="$1"
+
+ for i in ${file_list}; do
+ case ${sourced_files} in
+ *:$i:*)
+ ;;
+ *)
+ sourced_files="${sourced_files}:$i:"
+ if [ -r $i ]; then
+ . $i
+ fi
+ ;;
+ esac
+ done
+}
+
+#
+# init_ports_config
+# Initialization routine for FreeBSD ports scripts.
+#
+init_ports_config()
+{
+ freebsd_ports="YES"
}
#
Index: etc/defaults/rc.conf
===================================================================
RCS file: /home/ncvs/src/etc/defaults/rc.conf,v
retrieving revision 1.198
diff -u -r1.198 rc.conf
--- etc/defaults/rc.conf 3 Feb 2004 11:26:08 -0000 1.198
+++ etc/defaults/rc.conf 22 Feb 2004 08:19:42 -0000
@@ -41,6 +41,8 @@
local_startup="/usr/local/etc/rc.d /usr/X11R6/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"
+rc_ports_conf_files="/usr/local/etc/defaults/rc.conf /usr/local/etc/rc.conf"
+rc_ports_conf_dir="/usr/local/etc/rc.conf.d"
# Experimental - test before enabling
gbde_autoattach_all="NO" # YES automatically mounts gbde devices from fstab
@@ -471,27 +473,3 @@
#jail_example_fdescfs_enable="NO" # mount fdescfs in the jail
#jail_example_procfs_enable="NO" # mount procfs in jail
#jail_example_devfs_ruleset="ruleset_name" # devfs ruleset to apply to jail
-
-##############################################################
-### 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
Index: etc/mtree/BSD.local.dist
===================================================================
RCS file: /home/ncvs/src/etc/mtree/BSD.local.dist,v
retrieving revision 1.107
diff -u -r1.107 BSD.local.dist
--- etc/mtree/BSD.local.dist 29 Jan 2004 16:17:25 -0000 1.107
+++ etc/mtree/BSD.local.dist 22 Feb 2004 08:15:07 -0000
@@ -8,6 +8,8 @@
bin
..
etc
+ defaults
+ ..
pam.d
..
rc.d
More information about the freebsd-arch
mailing list