From owner-freebsd-rc@FreeBSD.ORG Wed Oct 16 19:48:48 2013 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id B6E88B2A for ; Wed, 16 Oct 2013 19:48:48 +0000 (UTC) (envelope-from bounces+73574-d723-freebsd-rc=freebsd.org@sendgrid.me) Received: from o3.shared.sendgrid.net (o3.shared.sendgrid.net [208.117.48.85]) by mx1.freebsd.org (Postfix) with SMTP id 631BB264B for ; Wed, 16 Oct 2013 19:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info; h=from:mime-version:to:cc:subject:references:in-reply-to:content-type; s=smtpapi; bh=KU95oUnZahTrd/9XzTR016vTYvw=; b=Y3oOtob8f5h5GZHeQA xUfbZd9ZgfxhTk69qbKGD3WCcaFcsz20/DYg4MfZUaXd8Vg4rRxdGzf/GWYpHp5a yXBv+NtRUrIcCWWUB1l+V4y9dosy1JwHvifkOjR3x3rZSCj4SELVDASrwzm+Y25i 2zJ9mTAbWawwSLn7tGkw6QmIM= Received: by filterdell-002.sjc1.sendgrid.net with SMTP id filterdell-002.30721.525EED9A4 Wed, 16 Oct 2013 19:48:42 +0000 (GMT) Received: from mail.tarsnap.com (unknown [10.60.208.15]) by mi17 (SG) with ESMTP id 141c2d02239.18f.1dfa7cc for ; Wed, 16 Oct 2013 19:48:42 +0000 (UTC) Received: (qmail 89473 invoked from network); 16 Oct 2013 19:48:40 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by ec2-107-20-205-189.compute-1.amazonaws.com with ESMTP; 16 Oct 2013 19:48:40 -0000 Received: (qmail 14078 invoked from network); 16 Oct 2013 19:47:44 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by clamshell.daemonology.net with SMTP; 16 Oct 2013 19:47:44 -0000 Message-ID: <525EED60.2000404@freebsd.org> Date: Wed, 16 Oct 2013 12:47:44 -0700 From: Colin Percival User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Ian Lepore Subject: Re: RFC: support for "first boot" rc.d scripts References: <525B258F.3030403@freebsd.org> <41F1219E-4DCC-4B04-A1DC-40038809556B@van-laarhoven.org> <525C210A.2000306@freebsd.org> <1381770007.42859.82.camel@revolution.hippie.lan> In-Reply-To: <1381770007.42859.82.camel@revolution.hippie.lan> X-Enigmail-Version: 1.5.2 Content-Type: multipart/mixed; boundary="------------060902050507040600000606" X-SG-EID: ChUA/E68MWtQtYrYVmEHIGuqNmShXrFL3cq8iGM7RqUzQzcFPg0oe9t0Opce22bZdZ7SGjc788YLjgUjQ1aOe8VdrUWGcLLItqJvdBrsv67tuCw04yl9opwcosew7iXjU9kinobkQnNF7aKO6d5dAlrQKC2pGuIJSxZAXQSfuG4= Cc: FreeBSD current , freebsd-rc@FreeBSD.org, Nick Hibma X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Oct 2013 19:48:48 -0000 This is a multi-part message in MIME format. --------------060902050507040600000606 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 10/14/13 10:00, Ian Lepore wrote: > The embedded systems we create at $work have readonly root and mfs /var, > but we do have writable storage on another filesystem. It would work > for us (not that we need this feature right now) if there were an rcvar > that pointed to the marker file. Of course to make it work, something > would have to get the alternate filesystem mounted early enough to be > useful (that is something we do already with a custom rc script). New patch attached. This one re-probes for the firstboot sentinel after ${early_late_divider}, so you can set firstboot_sentinel to /path/to/my/writable/storage as long as that's available once the boot process reaches FILESYSTEMS (or NETWORKING, or whatever you set early_late_divider to). I figure that if we can assume all the local rc.d scripts are available at that point we can assume that wherever people decide to put the firstboot sentinel will also be available at that point. Does anyone see any problems with this? -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid --------------060902050507040600000606 Content-Type: text/plain; charset=us-ascii; name="firstboot.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="firstboot.patch" Index: etc/defaults/rc.conf =================================================================== --- etc/defaults/rc.conf (revision 256432) +++ etc/defaults/rc.conf (working copy) @@ -619,6 +619,9 @@ accounting_enable="NO" # Turn on process accounting (or NO). ibcs2_enable="NO" # Ibcs2 (SCO) emulation loaded at startup (or NO). ibcs2_loaders="coff" # List of additional Ibcs2 loaders (or NO). +firstboot_sentinel="/firstboot" # Scripts with "firstboot" keyword are run if + # this file exists. Should be on a R/W filesystem so + # the file can be deleted after the boot completes. # Emulation/compatibility services provided by /etc/rc.d/abi sysvipc_enable="NO" # Load System V IPC primitives at startup (or NO). Index: etc/rc =================================================================== --- etc/rc (revision 256432) +++ etc/rc (working copy) @@ -82,10 +82,15 @@ fi fi +# If the firstboot sentinel doesn't exist, we want to skip firstboot scripts. +if ! [ -e ${firstboot_sentinel} ]; then + skip_firstboot="-s firstboot" +fi + # Do a first pass to get everything up to $early_late_divider so that # we can do a second pass that includes $local_startup directories # -files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null` +files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* 2>/dev/null` _rc_elem_done=' ' for _rc_elem in ${files}; do @@ -107,7 +112,13 @@ *) find_local_scripts_new ;; esac -files=`rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null` +# The firstboot sentinel might be on a newly mounted filesystem; look for it +# again and unset skip_firstboot if we find it. +if [ -e ${firstboot_sentinel} ]; then + skip_firstboot="" +fi + +files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* ${local_rc} 2>/dev/null` for _rc_elem in ${files}; do case "$_rc_elem_done" in *" $_rc_elem "*) continue ;; @@ -116,6 +127,15 @@ run_rc_script ${_rc_elem} ${_boot} done +# Remove the firstboot sentinel, and reboot if it was requested. +if [ -e ${firstboot_sentinel} ]; then + rm ${firstboot_sentinel} + if [ -e ${firstboot_sentinel}-reboot ]; then + rm ${firstboot_sentinel}-reboot + kill -INT 1 + fi +fi + echo '' date exit 0 --------------060902050507040600000606--