summaryrefslogtreecommitdiff
path: root/packages/altboot/files/altboot-menu/Advanced/80-configure-kexec
blob: e294df683f3a107a155ee447f0c87c76f3d1b332 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# !/bin/sh
M_TITLE="Configure kexec CMDLINE"



# 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 "\nPlease select the kernel you want to configure:\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
			
			get_pref "kexec_klist" "$junk" KEXEC_KERNEL && break

		done				
	else
		KEXEC_KERNEL="`ls -1 $KEXEC_KERNEL_DIR/zImage* | grep -v "kexec.cfg" `"
	fi
	
	echo -e "\nUsing [$KEXEC_KERNEL]"
	
	configure_rootdev
	configure_roottype
	configure_verbose
	configure_custom

	CMDLINE="console=ttyS0,115200n8 console=tty1 dyntick=enable fbcon=rotate:1 noinitrd root=$KERNEL_ROOTDEV rootfstype=$KERNEL_ROOTFSTYPE $KERNEL_VERBOSE $KERNEL_CUSTOM"
	
	echo -en "\nWriting CMDLINE to $KEXEC_KERNEL.kexec.cfg..."
	echo "$CMDLINE" > $KEXEC_KERNEL.kexec.cfg && echo ok || mdie FAILED
	
	show_menu
}

configure_rootdev() {

	echo -e "\nPlease choose a root device (root=*):\n"
	
	cnt=1 ; reset_pref "kexec_rootdev"
	for root in /dev/mtdblock2 /dev/hda1 "Manual Entry"
	do
		echo -e "\t[$cnt] $root"
		set_pref kexec_rootdev "$cnt" "$root"
		let cnt=cnt+1
	done
	
	echo ""
	
	while true
	do
		echo -n "Select a root device: "
		read junk
		
		get_pref kexec_rootdev "$junk" KERNEL_ROOTDEV && break
	done
	
	if test "$KERNEL_ROOTDEV" = "Manual Entry"
	then
		echo ""
		
		KERNEL_ROOTDEV=""
		
		while test -z "$KERNEL_ROOTDEV"
		do
			while true
			do
				echo -n "Enter the root device: "
				read junk
				test -n "$junk" && break
			done

			echo -en "\nIs [$junk] correct? [Y|n] "
			read junk2
			while true
			do
				if test "$junk2" = y -o "$junk2" = Y -o -z "$junk2"
				then
					KERNEL_ROOTDEV="$junk"
					break
				fi
				
				break
			done
		done
	fi 
	
	echo "Using [$KERNEL_ROOTDEV] as root device"
}

configure_roottype() {

	echo -e "\nPlease choose a rootfs type (rootfs=*):\n"
	
	cnt=1 ; reset_pref "kexec_rootfstype"
	for root in jffs2 ext2 ext3 "Manual Entry"
	do
		echo -e "\t[$cnt] $root"
		set_pref kexec_rootfstype "$cnt" "$root"
		let cnt=cnt+1
	done
	
	echo ""
	
	while true
	do
		echo -n "Select a rootfs type: "
		read junk
		
		get_pref kexec_rootfstype "$junk" KERNEL_ROOTFSTYPE && break
	done
	
	if test "$KERNEL_ROOTFSTYPE" = "Manual Entry"
	then
		echo ""
		
		KERNEL_ROOTFSTYPE=""
		
		while test -z "$KERNEL_ROOTFSTYPE"
		do
			while true
			do
				echo -n "Enter the rootfs type: "
				read junk
				test -n "$junk" && break
			done

			echo -en "\nIs [$junk] correct? [Y|n] "
			read junk2
			while true
			do
				if test "$junk2" = y -o "$junk2" = Y -o -z "$junk2"
				then
					KERNEL_ROOTFSTYPE="$junk"
					break
				fi
				
				break
			done
		done
	fi 
	
	echo "Using [$KERNEL_ROOTFSTYPE] as rootfs type"
}

configure_verbose() {
	echo -e "\nDo you want to see kernel messages? ([quiet | debug]):\n"
	
	echo -e "\t[1] Yes"
	echo -e "\t[2] No"
		
	echo ""
	
	while true
	do
		echo -n "Select one of the above: "
		read junk
		
		test "$junk" = 1 -o "$junk" = 2 && break
	done
	
	test "$junk" = 1 && KERNEL_VERBOSE="debug" || KERNEL_VERBOSE="quiet"
	
}

configure_custom() {
	echo -e "\nDo you want to set custom kernel options?\n"

	echo -e "\t[1] Yes"
	echo -e "\t[2] No"
		
	echo ""
	
	while true
	do
		echo -n "Select one of the above: "
		read junk
		
		test "$junk" = 1 -o "$junk" = 2 && break
	done
	
	if test "$junk" = 1
	then
		
		echo ""
		
		KERNEL_CUSTOM=""
		
		while test -z "$KERNEL_CUSTOM"
		do
			while true
			do
				echo -n "Enter kernel options: "
				read junk
				test -n "$junk" && break
			done

			echo -en "\nIs [$junk] correct? [Y|n] "
			read junk2
			while true
			do
				if test "$junk2" = y -o "$junk2" = Y -o -z "$junk2"
				then
					KERNEL_CUSTOM="$junk"
					break
				fi
				
				break
			done
		done
	fi 
	
	echo "Using [$KERNEL_CUSTOM] as custom kernel options"
	
}

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