aboutsummaryrefslogtreecommitdiffstats
path: root/main/syslinux/update-extlinux
blob: 8a5509b9e37193fa04761fe8c90c2954ee898fc1 (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
#!/bin/sh

default=0
timeout=5
verbose=0

# read in extlinux settings
source /etc/extlinux.conf

everbose() {
	if [ "$verbose" = "0" ]; then
		return
	fi

	echo $*
}

everbose "Updating extlinux configuration."

if [ "x$root" = "x" ]; then
	everbose "WARNING: Root device not specified, determining automatically."
	everbose -n "Root device is: "
	export `blkid -o export /dev/root`
	root=UUID=$UUID
	everbose $root
fi

everbose "Installing mboot.c32 to /boot."
cp /usr/share/syslinux/mboot.c32 /boot

everbose "Installing menu.c32 to /boot."
cp /usr/share/syslinux/menu.c32 /boot

rtimeout=$((${timeout}\*10))
# vesa menu has been requested?
if [ "$fancy_menu" = "1" ]; then
	everbose "Installing vesamenu.c32 to /boot."
	cp /usr/share/syslinux/vesamenu.c32 /boot

	echo "DEFAULT vesamenu.c32" > /boot/extlinux.conf.new
	echo "PROMPT 0" >> /boot/extlinux.conf.new
	echo "MENU TITLE Alpine/$(uname -s) Boot Menu" >> /boot/extlinux.conf.new
	if [ "$hidden" = "1" ]; then
		echo "MENU HIDDEN" >> /boot/extlinux.conf.new
	fi
	echo "MENU AUTOBOOT Alpine will be booted automatically in # seconds." >> /boot/extlinux.conf.new
	echo "TIMEOUT $rtimeout" >> /boot/extlinux.conf.new
else
	echo "DEFAULT menu.c32" > /boot/extlinux.conf.new
	echo "PROMPT 0" >> /boot/extlinux.conf.new
	echo "MENU TITLE Alpine/$(uname -s) Boot Menu" >> /boot/extlinux.conf.new
	if [ "$hidden" = "1" ]; then
		echo "MENU HIDDEN" >> /boot/extlinux.conf.new
	fi
	echo "MENU AUTOBOOT Alpine will be booted automatically in # seconds." >> /boot/extlinux.conf.new
	echo "TIMEOUT $rtimeout" >> /boot/extlinux.conf.new
fi

lst=0
for kernel in $(find /boot -name vmlinuz-* -type f); do
	tag=$(basename $kernel | cut -b9-)
	everbose "Found kernel: $kernel"

	if [ -f "/boot/initramfs-$tag" ]; then
		everbose "Found initramfs: /boot/initramfs-$tag"
		initramfs="initrd=initramfs-$tag"
	fi

	echo "LABEL $lst" >> /boot/extlinux.conf.new
	if [ "$lst" = "$default" ]; then
		echo "  MENU DEFAULT" >> /boot/extlinux.conf.new
	fi
	echo "  MENU LABEL Linux $tag" >> /boot/extlinux.conf.new
	echo "  KERNEL $(basename $kernel)" >> /boot/extlinux.conf.new
	echo "  APPEND $initramfs root=$root modules=$modules $default_kernel_opts" >> /boot/extlinux.conf.new
	lst=$(($lst + 1))
done

if [ -f "/boot/memtest" ]; then
	everbose "Found memtest86+: /boot/memtest"
	echo "LABEL $lst" >> /boot/extlinux.conf.new
	echo "  MENU LABEL Memtest86+" >> /boot/extlinux.conf.new
        echo "  KERNEL memtest" >> /boot/extlinux.conf.new
        lst=$(($lst + 1))
fi

everbose "$lst entries found."

mv /boot/extlinux.conf.new /boot/extlinux.conf