From owner-freebsd-rc@FreeBSD.ORG Sun Oct 13 22:59:21 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 CB086358 for ; Sun, 13 Oct 2013 22:59:21 +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 7A2822BDB for ; Sun, 13 Oct 2013 22:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info; h=from:mime-version:to:subject:content-type; s=smtpapi; bh=fSnyVSMbFX3vfIXJk1NRyvLxeho=; b=Ne0LvsVNdYfUQPDkN9/4k6IkorX1q wF+KANV118eM949QzPousgHH+pxWLYr4YOemmLTMpELu7c0b5Rgw0B174YUi4w7Z BauucggFMKpuNQVgdp6J/szIp9aq02oFL27XkBjLt6YlexZeGPLdBLzzZ1kjTlQn 09fft1GIEXrj7M= Received: by filter-151.sjc1.sendgrid.net with SMTP id filter-151.10611.525B25C32 Sun, 13 Oct 2013 22:59:15 +0000 (GMT) Received: from mail.tarsnap.com (unknown [10.60.208.13]) by mi19 (SG) with ESMTP id 141b40b77ab.19b5.197931b for ; Sun, 13 Oct 2013 22:59:12 +0000 (UTC) Received: (qmail 51882 invoked from network); 13 Oct 2013 22:59:11 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by ec2-107-20-205-189.compute-1.amazonaws.com with ESMTP; 13 Oct 2013 22:59:11 -0000 Received: (qmail 4131 invoked from network); 13 Oct 2013 22:58:23 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by clamshell.daemonology.net with SMTP; 13 Oct 2013 22:58:23 -0000 Message-ID: <525B258F.3030403@freebsd.org> Date: Sun, 13 Oct 2013 15:58:23 -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: FreeBSD current , freebsd-rc@freebsd.org Subject: RFC: support for "first boot" rc.d scripts X-Enigmail-Version: 1.5.2 Content-Type: multipart/mixed; boundary="------------040902090405000607020909" X-SG-EID: ChUA/E68MWtQtYrYVmEHIGuqNmShXrFL3cq8iGM7RqXluu9jXtSBeGG351/b4LCb5kF5zBSNqPpCDG8PLU55yC4koZHVwTPG1/YMpY+7LTXlgRiGkXsrERFsWo7htvaRr6DuyI/M00xQ0d55llvNhBzg+H7HHB3XqQNkaoFg0js= 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: Sun, 13 Oct 2013 22:59:22 -0000 This is a multi-part message in MIME format. --------------040902090405000607020909 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi all, I've attached a very simple patch which makes /etc/rc: 1. Skip any rc.d scripts with the "firstboot" keyword if /var/db/firstboot does not exist, 2. If /var/db/firstboot and /var/db/firstboot-reboot exist after running rc.d scripts, reboot. 3. Delete /var/db/firstboot (and firstboot-reboot) after the first boot. The purpose of this is to support "run on first boot" rc.d scripts. These can be useful for both virtual machines and embedded systems; unlike conventional desktops and servers, these may have a lengthy gap between "installing" and "turning on" the system. As examples of what such scripts could do: * In Amazon EC2, I use a "first boot" script to download an SSH public key from EC2 so that users can log in to newly provisioned EC2 instances. * Now that (starting from 10.0-BETA1) it is possible to use FreeBSD Update to update everything on EC2 instances, I'm planning on writing a script which runs 'freebsd-update fetch install' when the system first boots, and then reboots if there were updates installed. (I imagine this would be useful to other embedded / VM providers too.) * Once packages are provided (properly) for 10.0 I'd like to allow people to specify a list of packages they want installed onto an EC2 instance and have them downloaded and installed when the EC2 instance launches. I'd like to get this into HEAD in the near future in the hope that I can convince re@ that this is a simple enough (and safe enough) change to merge before 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 --------------040902090405000607020909 Content-Type: text/plain; charset=us-ascii; name="firstboot.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="firstboot.patch" Index: etc/rc =================================================================== --- etc/rc (revision 256432) +++ etc/rc (working copy) @@ -81,6 +81,9 @@ skip="$skip -s nojailvnet" fi fi +if ! [ -e /var/db/firstboot ]; 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 /var/db/firstboot ]; then + rm /var/db/firstboot + if [ -e /var/db/firstboot-reboot ]; then + rm /var/db/firstboot-reboot + kill -INT 1 + fi +fi echo '' date exit 0 --------------040902090405000607020909--