summaryrefslogtreecommitdiff
path: root/packages/altboot/files/altboot-menu/Advanced/70-setKernel
blob: 6192232a736ebf5e579a80916473c8b1ffdc7195 (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
58
59
60
61
62
63
64
65
66
67
# !/bin/sh
M_TITLE="Choose kernel for next boot"



# Only kernel 2.6 offers kexec support
uname -r | grep -q "^2.6" || exit 0

run_module() {
	
	test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
	
	test -z "$KEXEC_KERNEL_DIR" && KEXEC_KERNEL_DIR="/boot"	
	test -x "$KEXEC_BIN" || mdie "kexec-tools not found [$KEXEC_BIN]"
	
	# Mount /proc, etc
	# init_rootfs
	
	if test `ls -1 $KEXEC_KERNEL_DIR | grep -v "kexec.cfg" | wc -l | tr -d " "` -gt 1
	then
		echo -e "\nSelect the kernel for use of the next boot:\n"	
		
		cnt=1 ; reset_pref "kexec_klist"
		for k in `ls -1 $KEXEC_KERNEL_DIR/zImage* | grep -v "kexec.cfg" `
		do
			echo -e "\t[$cnt] $k"
			set_pref "kexec_klist" "$cnt" "$k" 
						
			let cnt=$cnt+1
		done 
		
		echo ""
		
		while true
		do
			echo -n "Select a kernel: "
			read junk
			
			#echo_pref kexec_klist
			
			get_pref "kexec_klist" "$junk" KEXEC_SELECTED_KERNEL && break

		done		
	else
		KEXEC_SELECTED_KERNEL="`ls -1 $KEXEC_KERNEL_DIR/zImage* | grep -v "kexec.cfg" `"
	fi
	
	echo -e "\nUsing [$KEXEC_SELECTED_KERNEL]"
	
	if ! test -e "$KEXEC_SELECTED_KERNEL.kexec.cfg" 
	then
		echo -e "\nWARNING: This kernel has not been configured."
		echo -e "It will only boot correctly if CMDLINE is compiled in.\n"
	fi
				
	export USE_KEXEC_ON_NEXT_BOOT=yes
	export KEXEC_SELECTED_KERNEL		
	show_menu
}



case "$1" in
title)	echo "$M_TITLE";;
run)	run_module;;
esac