Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 01 Dec 2013 18:18:03 -0800
From:      Colin Percival <cperciva@freebsd.org>
To:        freebsd-rc@FreeBSD.org
Subject:   RFC: support for re-sourcing /etc/rc.conf
Message-ID:  <529BEDDB.8010003@freebsd.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------020807080703050704060006
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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

--------------020807080703050704060006
Content-Type: text/plain; charset=us-ascii;
 name="rc-sigalrm.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="rc-sigalrm.patch"

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"

--------------020807080703050704060006--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?529BEDDB.8010003>