2002-05-24 04:06:03 +00:00
|
|
|
#! /bin/sh
|
|
|
|
#
|
|
|
|
# Copyright 2002. Gordon Tetlow.
|
|
|
|
# gordon@FreeBSD.org
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
|
|
|
|
delete="NO"
|
|
|
|
force="NO"
|
|
|
|
nextboot_file="/boot/nextboot.conf"
|
2006-01-16 16:18:54 +00:00
|
|
|
kernel=""
|
2002-05-24 04:06:03 +00:00
|
|
|
|
|
|
|
display_usage() {
|
|
|
|
echo "Usage: nextboot [-f] [-o options] -k kernel"
|
|
|
|
echo " nextboot -D"
|
|
|
|
}
|
|
|
|
|
2006-01-16 16:18:54 +00:00
|
|
|
# Parse args, do not use getopt because we don't want to rely on /usr
|
|
|
|
while test $# -gt 0; do
|
|
|
|
case $1 in
|
|
|
|
-D)
|
2002-05-24 04:06:03 +00:00
|
|
|
delete="YES"
|
|
|
|
;;
|
2006-01-16 16:18:54 +00:00
|
|
|
-f)
|
2002-05-24 04:06:03 +00:00
|
|
|
force="YES"
|
|
|
|
;;
|
2006-01-16 16:18:54 +00:00
|
|
|
-k)
|
|
|
|
if test $# -lt 2; then
|
|
|
|
echo "$0: option $1 must specify kernel"
|
|
|
|
display_usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
kernel="$2"
|
|
|
|
shift
|
2002-05-24 04:06:03 +00:00
|
|
|
;;
|
2006-01-16 16:18:54 +00:00
|
|
|
-o)
|
|
|
|
if test $# -lt 2; then
|
|
|
|
echo "$0: option $1 must specify boot options"
|
|
|
|
display_usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
kernel_options="$2"
|
|
|
|
shift
|
2002-05-24 04:06:03 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
display_usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2006-01-16 16:18:54 +00:00
|
|
|
shift
|
2002-05-24 04:06:03 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${delete} = "YES" ]; then
|
|
|
|
rm -f ${nextboot_file}
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "xxx${kernel}" = "xxx" ]; then
|
|
|
|
display_usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${force} = "NO" -a ! -d /boot/${kernel} ]; then
|
|
|
|
echo "Error: /boot/${kernel} doesn't exist. Use -f to override."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat > ${nextboot_file} << EOF
|
|
|
|
nextboot_enable="YES"
|
|
|
|
kernel="${kernel}"
|
|
|
|
kernel_options="${kernel_options}"
|
|
|
|
EOF
|