From owner-svn-src-all@FreeBSD.ORG Tue Oct 22 16:13:17 2013 Return-Path: Delivered-To: svn-src-all@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 DDB79251; Tue, 22 Oct 2013 16:13:16 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C9BAD2567; Tue, 22 Oct 2013 16:13:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9MGDGSx099378; Tue, 22 Oct 2013 16:13:16 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9MGDF7w099373; Tue, 22 Oct 2013 16:13:15 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <201310221613.r9MGDF7w099373@svn.freebsd.org> From: Colin Percival Date: Tue, 22 Oct 2013 16:13:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r256917 - in stable/9: etc etc/defaults share/man/man5 share/man/man8 sys/sys X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Oct 2013 16:13:17 -0000 Author: cperciva Date: Tue Oct 22 16:13:15 2013 New Revision: 256917 URL: http://svnweb.freebsd.org/changeset/base/256917 Log: MFC r256775,r256776: Add support for "first boot" rc.d scripts. Document this new functionality in rc.conf(5) and rc(8). Bump __FreeBSD_version so that ports can make use of this. Modified: stable/9/etc/defaults/rc.conf stable/9/etc/rc stable/9/share/man/man5/rc.conf.5 stable/9/share/man/man8/rc.8 stable/9/sys/sys/param.h Directory Properties: stable/9/etc/ (props changed) stable/9/share/man/man5/ (props changed) stable/9/share/man/man8/ (props changed) stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/9/etc/defaults/rc.conf ============================================================================== --- stable/9/etc/defaults/rc.conf Tue Oct 22 16:09:44 2013 (r256916) +++ stable/9/etc/defaults/rc.conf Tue Oct 22 16:13:15 2013 (r256917) @@ -613,6 +613,9 @@ quotacheck_flags="-a" # Check all file s 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). Modified: stable/9/etc/rc ============================================================================== --- stable/9/etc/rc Tue Oct 22 16:09:44 2013 (r256916) +++ stable/9/etc/rc Tue Oct 22 16:13:15 2013 (r256917) @@ -82,10 +82,15 @@ if [ `/sbin/sysctl -n security.jail.jail 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 @@ case ${local_startup} in *) 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 @@ for _rc_elem in ${files}; do 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 Modified: stable/9/share/man/man5/rc.conf.5 ============================================================================== --- stable/9/share/man/man5/rc.conf.5 Tue Oct 22 16:09:44 2013 (r256916) +++ stable/9/share/man/man5/rc.conf.5 Tue Oct 22 16:13:15 2013 (r256917) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 12, 2013 +.Dd October 19, 2013 .Dt RC.CONF 5 .Os .Sh NAME @@ -3629,6 +3629,23 @@ and if is set to .Dq Li YES , this specifies a list of additional iBCS2 loaders to enable. +.It Va firstboot_sentinel +.Pq Vt str +This variable specifies the full path to a +.Dq first boot +sentinel file. +If a file exists with this path, +.Pa rc.d +scripts with the +.Dq firstboot +keyword will be run on startup and the sentinel file will be deleted +after the boot process completes. +The sentinel file must be located on a writable file system which is +mounted no later than +.Va early_late_divider +to function properly. +The default is +.Pa /firstboot . .It Va linux_enable .Pq Vt bool Set to Modified: stable/9/share/man/man8/rc.8 ============================================================================== --- stable/9/share/man/man8/rc.8 Tue Oct 22 16:09:44 2013 (r256916) +++ stable/9/share/man/man8/rc.8 Tue Oct 22 16:13:15 2013 (r256917) @@ -35,7 +35,7 @@ .\" @(#)rc.8 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd November 17, 2009 +.Dd October 19, 2013 .Dt RC 8 .Os .Sh NAME @@ -129,6 +129,13 @@ and add (only allow vnet-enabled jails) to the list of KEYWORDS to skip in .Xr rcorder 8 . .It +If the file +.Va ${firstboot_sentinel} +does not exist, add +.Dq Li firstboot +to the list of KEYWORDS to skip in +.Xr rcorder 8 . +.It Invoke .Xr rcorder 8 to order the files in @@ -156,6 +163,11 @@ Stop processing when the script that is .Va $early_late_divider has been run. .It +Check again to see if the file +.Va ${firstboot_sentinel} +exists (in case it is located on a newly mounted file system) +and adjust the list of KEYWORDs to skip appropriately. +.It Re-run .Xr rcorder 8 , this time including the scripts in the @@ -164,6 +176,13 @@ directories. Ignore everything up to the .Va $early_late_divider , then start executing the scripts as described above. +.It +If the file +.Va ${firstboot_sentinel} +exists, delete it. +If the file +.Va ${firstboot_sentinel}-reboot +also exists (because it was created by a script), then delete it and reboot. .El .Ss Operation of Nm rc.shutdown .Bl -enum Modified: stable/9/sys/sys/param.h ============================================================================== --- stable/9/sys/sys/param.h Tue Oct 22 16:09:44 2013 (r256916) +++ stable/9/sys/sys/param.h Tue Oct 22 16:13:15 2013 (r256917) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 902503 /* Master, propagated to newvers */ +#define __FreeBSD_version 902504 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,