View difference between Paste ID: chSwjBHd and dJmqtSQC
SHOW: | | - or go back to the newest paste.
1
#!/bin/bash
2
3
countdown=5
4
5
default=0
6
7
title[0]="Arch Linux"
8
kernel[0]="ArchLinux.image"
9
cmdline[0]="root=/dev/mmcblk0p2 rootfstype=ext3 rootwait"
10
11
title[1]="OpenELEC"
12
kernel[1]="OpenELEC.image"
13
cmdline[1]="root=/dev/ram0 rdinit=/init boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p3 ssh debugging"
14
15
title[2]="Debian"
16
kernel[2]="ArchLinux.image"
17
cmdline[2]="root=/dev/mmcblk0p4 rootfstype=ext4 rootwait"
18
19
title[3]="USB (sda1)"
20
kernel[3]="ArchLinux.image"
21
cmdline[3]="root=/dev/sda1 rootwait"
22
23
version=0.1
24
25
tempfile=$( tempfile 2>/dev/null ) || tempfile=/tmp/choice$$
26
trap "rm -f $tempfile" 0 1 2 5 15
27
28
echo "4 1 1 7" > /proc/sys/kernel/printk
29
dialog --backtitle "XECLoader $version" --pause "Starting ${title[$default]}... \nPress Ok to start now.\nPress Cancel to select." 10 40 $countdown
30
	
31
if [ $? -eq 0 ]; then
32
	clear
33
	kexec -l "/mnt/kernels/${kernel[$default]}" --command-line="$( cat /proc/cmdline ) ${cmdline[$default]}"
34
	kexec -e
35
	else
36
	for (( i=0; i<${#title[@]}; i++ )); do
37
			options[2*i]=$i
38
			options[2*i+1]="${title[$i]}"
39
	done
40
		dialog --backtitle "XECLoader $version" --menu "Select system or cancel to launch a shell." 20 50 20 "${options[@]}" 2> $tempfile
41
		if [ $? -eq 0 ]; then
42
			dialog --backtitle "XECLoader $version" --infobox "Starting ${title[$( cat  $tempfile )]}..." 4 40;
43
			kexec -l "/mnt/kernels/${kernel[$( cat  $tempfile )]}" --command-line="$( cat /proc/cmdline ) ${cmdline[$( cat  $tempfile )]}"
44
			rm $tempfile
45
			kexec -e
46
		else
47
			/bin/bash
48
		fi
49
fi