RFC: support for re-sourcing /etc/rc.conf

Colin Percival cperciva at freebsd.org
Mon Dec 2 02:20:46 UTC 2013


Hi all,

I'd like to commit the attached patch to /etc/rc.  When SIGALRM is received,
it reloads /etc/rc.conf; this makes it possible for an rc.d script to perform
first-boot system configuration and have it reflected by other rc.d scripts.

In particular, this will allow me to provide EC2 user-data of
	>>/etc/rc.conf
	firstboot_pkgs_enable="YES"
	firstboot_pkgs_list="apache22"
to an image with the sysutils/ec2-scripts and sysutils/firstboot-pkgs ports
installed, and have a system running with apache22 installed moments later.

The first signal which came to mind for this was SIGHUP, since that's used
by many daemons for "reload configuration file", but for some reason that
signal never arrives at /etc/rc -- so I switched to SIGALRM, which works
just fine.

I'd like to get this into the tree as soon as possible in order to maximize
my odds of convincing re@ that "rc.conf can't be re-sourced after it has been
modified during boot" is a bug which should be fixed in 10.0-RELEASE.

Comments?

-- 
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid
-------------- next part --------------
Index: etc/rc
===================================================================
--- etc/rc	(revision 258085)
+++ etc/rc	(working copy)
@@ -71,6 +71,11 @@
 . /etc/rc.subr
 load_rc_config 'XXX'
 
+# If we receive a SIGALRM, re-source /etc/rc.conf; this allows rc.d
+# scripts to perform "boot-time configuration" including enabling and
+# disabling rc.d scripts which appear later in the boot order.
+trap "_rc_conf_loaded=false; load_rc_config 'XXX'" ALRM
+
 skip="-s nostart"
 if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then
 	skip="$skip -s nojail"


More information about the freebsd-rc mailing list