diff options
author | gjb <gjb@FreeBSD.org> | 2016-04-11 15:24:59 +0000 |
---|---|---|
committer | gjb <gjb@FreeBSD.org> | 2016-04-11 15:24:59 +0000 |
commit | e0e3598ce13850597a66fd28d102b36881f7d610 (patch) | |
tree | f5194d1ce3fa45b67cf63080fc519fec83abc57a /sbin/reboot | |
parent | cbc3bd9845ba5fd58e8132f9565cfbc41433938d (diff) | |
parent | 26836fccd261358467b3d92e77ff4695af286de9 (diff) | |
download | FreeBSD-src-e0e3598ce13850597a66fd28d102b36881f7d610.zip FreeBSD-src-e0e3598ce13850597a66fd28d102b36881f7d610.tar.gz |
MFH
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sbin/reboot')
-rw-r--r-- | sbin/reboot/nextboot.8 | 9 | ||||
-rw-r--r-- | sbin/reboot/nextboot.sh | 26 |
2 files changed, 30 insertions, 5 deletions
diff --git a/sbin/reboot/nextboot.8 b/sbin/reboot/nextboot.8 index df46a0c..d006c3f 100644 --- a/sbin/reboot/nextboot.8 +++ b/sbin/reboot/nextboot.8 @@ -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 diff --git a/sbin/reboot/nextboot.sh b/sbin/reboot/nextboot.sh index 655e533..a90fdeb 100644 --- a/sbin/reboot/nextboot.sh +++ b/sbin/reboot/nextboot.sh @@ -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 _fs _type _other ; do 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} |