summaryrefslogtreecommitdiffstats
path: root/sbin/reboot/nextboot.sh
blob: 56e53f60a1a974f48c9a975a455c3fe2e4262824 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/sh
#
# Copyright 2002. Gordon Tetlow.
# gordon@FreeBSD.org
#
# $FreeBSD$

delete="NO"
force="NO"
nextboot_file="/boot/nextboot.conf"

display_usage() {
	echo "Usage: nextboot [-f] [-o options] -k kernel"
	echo "       nextboot -D"
}

while getopts "Dfk:o:" argument ; do
	case "${argument}" in
	D)
		delete="YES"
		;;
	f)
		force="YES"
		;;
	k)
		kernel="${OPTARG}"
		;;
	o)
		kernel_options="${OPTARG}"
		;;
	*)
		display_usage
		exit 1
		;;
	esac
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
OpenPOWER on IntegriCloud