Date: Mon, 14 Oct 2013 12:11:13 -0700 From: Colin Percival <cperciva@freebsd.org> To: Ian Lepore <ian@FreeBSD.org> Cc: FreeBSD current <freebsd-current@FreeBSD.org>, freebsd-rc@FreeBSD.org, Nick Hibma <nick@van-laarhoven.org> Subject: Re: RFC: support for "first boot" rc.d scripts Message-ID: <525C41D1.3040204@freebsd.org> In-Reply-To: <1381770007.42859.82.camel@revolution.hippie.lan> References: <525B258F.3030403@freebsd.org> <41F1219E-4DCC-4B04-A1DC-40038809556B@van-laarhoven.org> <525C210A.2000306@freebsd.org> <1381770007.42859.82.camel@revolution.hippie.lan>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
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
[-- Attachment #2 --]
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?525C41D1.3040204>
