[Midnightbsd-cvs] src [6674] trunk/sbin/reboot: support setting up an alternate kernel env on nextboot
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Jun 15 12:44:15 EDT 2014
Revision: 6674
http://svnweb.midnightbsd.org/src/?rev=6674
Author: laffer1
Date: 2014-06-15 12:44:15 -0400 (Sun, 15 Jun 2014)
Log Message:
-----------
support setting up an alternate kernel env on nextboot
Modified Paths:
--------------
trunk/sbin/reboot/nextboot.8
trunk/sbin/reboot/nextboot.sh
Modified: trunk/sbin/reboot/nextboot.8
===================================================================
--- trunk/sbin/reboot/nextboot.8 2014-06-15 16:42:05 UTC (rev 6673)
+++ trunk/sbin/reboot/nextboot.8 2014-06-15 16:44:15 UTC (rev 6674)
@@ -24,7 +24,7 @@
.\"
.\" $MidnightBSD$
.\"
-.Dd November 4, 2002
+.Dd November 19, 2012
.Dt NEXTBOOT 8
.Os
.Sh NAME
@@ -32,15 +32,17 @@
.Nd "specify an alternate kernel and boot flags for the next reboot"
.Sh SYNOPSIS
.Nm
+.Op Fl e Ar variable=value
.Op Fl f
+.Op Fl k Ar kernel
.Op Fl o Ar options
-.Fl k Ar kernel
.Nm
.Fl D
.Sh DESCRIPTION
The
.Nm
-utility allows specifying an alternate kernel and/or boot flags for the
+utility allows specifying some combination of an alternate kernel, boot flags
+and kernel environment for the
next time the machine is booted.
Once the
.Xr loader 8
@@ -58,6 +60,11 @@
option removes an existing
.Nm
configuration.
+.It Fl e Ar variable=value
+This option adds the provided variable and value to the kernel environment.
+The value is quoted when written to the
+.Nm
+configuration.
.It Fl f
This
option disables the sanity checking which checks if the kernel really exists
Modified: trunk/sbin/reboot/nextboot.sh
===================================================================
--- trunk/sbin/reboot/nextboot.sh 2014-06-15 16:42:05 UTC (rev 6673)
+++ trunk/sbin/reboot/nextboot.sh 2014-06-15 16:44:15 UTC (rev 6674)
@@ -1,32 +1,80 @@
#! /bin/sh
#
-# Copyright 2002. Gordon Tetlow.
-# gordon at FreeBSD.org
+# Copyright (c) 2002 Gordon Tetlow. All rights reserved.
+# Copyright (c) 2012 Sandvine Incorporated. All rights reserved.
#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
# $MidnightBSD$
delete="NO"
+kenv=
force="NO"
nextboot_file="/boot/nextboot.conf"
+add_kenv()
+{
+ local var value
+
+ var=$1
+ # strip literal quotes if passed in
+ value=${2%\"*}
+ value=${value#*\"}
+
+ if [ -n "${kenv}" ]; then
+ kenv="${kenv}
+"
+ fi
+ kenv="${kenv}${var}=\"${value}\""
+}
+
display_usage() {
- echo "Usage: nextboot [-f] [-o options] -k kernel"
+ echo "Usage: nextboot [-e variable=value] [-f] [-k kernel] [-o options]"
echo " nextboot -D"
}
-while getopts "Dfk:o:" argument ; do
+while getopts "De:fk:o:" argument ; do
case "${argument}" in
D)
delete="YES"
;;
+ e)
+ var=${OPTARG%%=*}
+ value=${OPTARG#*=}
+ if [ -z "$var" -o -z "$value" ]; then
+ display_usage
+ exit 1
+ fi
+ add_kenv "$var" "$value"
+ ;;
f)
force="YES"
;;
k)
kernel="${OPTARG}"
+ add_kenv kernel "$kernel"
;;
o)
- kernel_options="${OPTARG}"
+ add_kenv kernel_options "${OPTARG}"
;;
*)
display_usage
@@ -40,12 +88,12 @@
exit 0
fi
-if [ "xxx${kernel}" = "xxx" ]; then
+if [ -z "${kenv}" ]; then
display_usage
exit 1
fi
-if [ ${force} = "NO" -a ! -d /boot/${kernel} ]; then
+if [ -n "${kernel}" -a ${force} = "NO" -a ! -d /boot/${kernel} ]; then
echo "Error: /boot/${kernel} doesn't exist. Use -f to override."
exit 1
fi
@@ -60,6 +108,5 @@
cat > ${nextboot_file} << EOF
nextboot_enable="YES"
-kernel="${kernel}"
-kernel_options="${kernel_options}"
+$kenv
EOF
More information about the Midnightbsd-cvs
mailing list