Changeset View
Changeset View
Standalone View
Standalone View
head/sbin/reboot/nextboot.sh
Show All 27 Lines | |||||
# | # | ||||
# $FreeBSD$ | # $FreeBSD$ | ||||
append="NO" | append="NO" | ||||
delete="NO" | delete="NO" | ||||
kenv= | kenv= | ||||
force="NO" | force="NO" | ||||
nextboot_file="/boot/nextboot.conf" | nextboot_file="/boot/nextboot.conf" | ||||
zfs= | |||||
add_kenv() | add_kenv() | ||||
{ | { | ||||
local var value | local var value | ||||
var=$1 | var=$1 | ||||
# strip literal quotes if passed in | # strip literal quotes if passed in | ||||
value=${2%\"*} | value=${2%\"*} | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | if [ -z "${kenv}" ]; then | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
if [ -n "${kernel}" -a ${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." | echo "Error: /boot/${kernel} doesn't exist. Use -f to override." | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
df -Tn "/boot/" 2>/dev/null | while read _fs _type _other ; do | zfs=$(df -Tn "/boot/" 2>/dev/null | while read _fs _type _other ; do | ||||
[ "zfs" = "${_type}" ] || continue | [ "zfs" = "${_type}" ] || continue | ||||
cat 1>&2 <<-EOF | echo "${_fs%/ROOT/*}" | ||||
WARNING: loader(8) has only R/O support for ZFS | done) | ||||
nextboot.conf will NOT be reset in case of kernel boot failure | |||||
EOF | |||||
done | |||||
set -e | set -e | ||||
nextboot_tmp=$(mktemp $(dirname ${nextboot_file})/nextboot.XXXXXX) | nextboot_tmp=$(mktemp $(dirname ${nextboot_file})/nextboot.XXXXXX) | ||||
if [ ${append} = "YES" -a -f ${nextboot_file} ]; then | if [ -n ${zfs} ]; then | ||||
cp -f ${nextboot_file} ${nextboot_tmp} | zfsbootcfg -z ${zfs} -n freebsd:nvstore -k nextboot_enable -v YES | ||||
fi | |||||
cat >> ${nextboot_tmp} << EOF | cat >> ${nextboot_tmp} << EOF | ||||
$kenv | |||||
EOF | |||||
else | |||||
cat >> ${nextboot_tmp} << EOF | |||||
nextboot_enable="YES" | nextboot_enable="YES" | ||||
$kenv | $kenv | ||||
EOF | EOF | ||||
fi | |||||
fsync ${nextboot_tmp} | fsync ${nextboot_tmp} | ||||
mv ${nextboot_tmp} ${nextboot_file} | mv ${nextboot_tmp} ${nextboot_file} |