From owner-svn-src-all@freebsd.org Sun Apr 10 01:25:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A880EB081C7; Sun, 10 Apr 2016 01:25:13 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5F8D21AD1; Sun, 10 Apr 2016 01:25:13 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3A1PCNT090575; Sun, 10 Apr 2016 01:25:12 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3A1PC3A090573; Sun, 10 Apr 2016 01:25:12 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201604100125.u3A1PC3A090573@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sun, 10 Apr 2016 01:25:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r297772 - head/sbin/reboot X-SVN-Group: head 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.21 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: Sun, 10 Apr 2016 01:25:13 -0000 Author: markj Date: Sun Apr 10 01:25:12 2016 New Revision: 297772 URL: https://svnweb.freebsd.org/changeset/base/297772 Log: nextboot(8): add a -a option for appending to a configuration. By default, a nextboot invocation will clobber any existing nextboot configuration. MFC after: 2 weeks Relnotes: yes Modified: head/sbin/reboot/nextboot.8 head/sbin/reboot/nextboot.sh Modified: head/sbin/reboot/nextboot.8 ============================================================================== --- head/sbin/reboot/nextboot.8 Sun Apr 10 01:24:27 2016 (r297771) +++ head/sbin/reboot/nextboot.8 Sun Apr 10 01:25:12 2016 (r297772) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 17, 2015 +.Dd April 9, 2016 .Dt NEXTBOOT 8 .Os .Sh NAME @@ -32,6 +32,7 @@ .Nd "specify an alternate kernel and boot flags for the next reboot" .Sh SYNOPSIS .Nm +.Op Fl a .Op Fl e Ar variable=value .Op Fl f .Op Fl k Ar kernel @@ -53,6 +54,12 @@ configuration. .Pp The options are as follows: .Bl -tag -width ".Fl o Ar options" +.It Fl a +This option causes +.Nm +to append to an existing configuration in +.Pa /boot/nextboot.conf . +By default any existing configuration is overwritten. .It Fl D Invoking .Nm Modified: head/sbin/reboot/nextboot.sh ============================================================================== --- head/sbin/reboot/nextboot.sh Sun Apr 10 01:24:27 2016 (r297771) +++ head/sbin/reboot/nextboot.sh Sun Apr 10 01:25:12 2016 (r297772) @@ -26,6 +26,7 @@ # # $FreeBSD$ +append="NO" delete="NO" kenv= force="NO" @@ -48,12 +49,17 @@ add_kenv() } display_usage() { - echo "Usage: nextboot [-e variable=value] [-f] [-k kernel] [-o options]" - echo " nextboot -D" + cat <<-EOF + Usage: nextboot [-e variable=value] [-f] [-k kernel] [-o options] + nextboot -D + EOF } -while getopts "De:fk:o:" argument ; do +while getopts "aDe:fk:o:" argument ; do case "${argument}" in + a) + append="YES" + ;; D) delete="YES" ;; @@ -106,7 +112,19 @@ df -Tn "/boot/" 2>/dev/null | while read EOF done -cat > ${nextboot_file} << EOF +set -e + +nextboot_tmp=$(mktemp $(dirname ${nextboot_file})/nextboot.XXXXXX) + +if [ ${append} = "YES" -a -f ${nextboot_file} ]; then + cp -f ${nextboot_file} ${nextboot_tmp} +fi + +cat >> ${nextboot_tmp} << EOF nextboot_enable="YES" $kenv EOF + +fsync ${nextboot_tmp} + +mv ${nextboot_tmp} ${nextboot_file}