From owner-freebsd-current@FreeBSD.ORG Mon Oct 14 19:12:07 2013 Return-Path: Delivered-To: freebsd-current@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 1AA3C5AD for ; Mon, 14 Oct 2013 19:12:07 +0000 (UTC) (envelope-from bounces+73574-dfb6-freebsd-current=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 C86432016 for ; Mon, 14 Oct 2013 19:12:06 +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=gxGTAjlIQXnVU2nkFXqhxHbw/7I=; b=ZIAYAc0OHHePv+A9ln NU8GvX7bLDiFa6rJtFKYiu3DGlC9TO8o9o6n4YJTEpkDF8lF/cmAm9h0ZFanfobX Or5bg3vWL5YCBrPyA/CsaUQx3FImsP/vXsVy9S+QmVK1N4yO4Bs/n5LJ4ASDSR0X NuEIC34S9U03vY9rtGYIGa/ig= Received: by mf92 with SMTP id mf92.885.525C4205F Mon, 14 Oct 2013 19:12:05 +0000 (GMT) Received: from mail.tarsnap.com (unknown [10.60.208.15]) by mi20 (SG) with ESMTP id 141b861e636.6203.15402f4 for ; Mon, 14 Oct 2013 19:12:05 +0000 (UTC) Received: (qmail 93492 invoked from network); 14 Oct 2013 19:12:04 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by ec2-107-20-205-189.compute-1.amazonaws.com with ESMTP; 14 Oct 2013 19:12:04 -0000 Received: (qmail 17355 invoked from network); 14 Oct 2013 19:11:13 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by clamshell.daemonology.net with SMTP; 14 Oct 2013 19:11:13 -0000 Message-ID: <525C41D1.3040204@freebsd.org> Date: Mon, 14 Oct 2013 12:11:13 -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="------------030903020801090603020103" X-SG-EID: XhyBwObMhraAR+zdwMupjQ6BIqbhdEfc+6p+uBxS7S/F6tz08zFvYUkvTz9x4wtiZLvmVMY7SO3laMEiLE9Ua9Xxm/8D6Ipt49ZPGGr5Ir1u110b+BueSybNM4Zc+Dvfw0GdNedQ32C9rTnRhSe14rpeAL884xU6IO6JajXIr9o= Cc: FreeBSD current , freebsd-rc@FreeBSD.org, Nick Hibma X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Oct 2013 19:12:07 -0000 This is a multi-part message in MIME format. --------------030903020801090603020103 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 10/14/13 10:00, Ian Lepore wrote: > On Mon, 2013-10-14 at 09:51 -0700, Colin Percival wrote: >> Yes, it's hard to store state on diskless systems... but I figured >> that anyone building a diskless system would know to not create a >> "run firstboot scripts" marker. And not all embedded systems are >> diskless... > > 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). Indeed... the way my patch currently does things, it looks for the firstboot sentinel at the start of /etc/rc, which means it *has* to be on /. Making the path an rcvar is a good idea (updated patch attached) but we still need some way to re-probe for that file after mounting extra filesystems. > Note that I'm not asking for any changes here, just babbling. Babbling is good. Between us we might babble a useful solution. ;-) -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid --------------030903020801090603020103 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) @@ -81,6 +81,9 @@ skip="$skip -s nojailvnet" fi fi +if ! [ -e ${firstboot_sentinel} ]; then + skip="$skip -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 @@ -116,6 +119,13 @@ run_rc_script ${_rc_elem} ${_boot} done +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 --------------030903020801090603020103--