aboutsummaryrefslogtreecommitdiff
path: root/modules/grub2/files/grub.cfg
blob: 5ed7fff569b8517dd635a7470a2be9ae89f6dc4c (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
function try_user_config {
	set root="${1}"
	for dir in boot grub grub2 boot/grub boot/grub2; do
		for name in libreboot_ autoboot_ librecore_ coreboot_ ''; do
			if [ -f /"${dir}"/"${name}"grub.cfg ]; then
                unset superusers
				configfile /"${dir}"/"${name}"grub.cfg
			fi
		done
	done
}

function search_grub {
	for i in 0 1; do
		# raw devices
		try_user_config "(${1}${i})"
		for part in 1 2 3 4 5; do
			# MBR/GPT partitions
			try_user_config "(${1}${i},${part})"
		done
	done
}

function try_isolinux_config {
	set root="${1}"
	for dir in '' /boot; do
		if [ -f "${dir}"/isolinux/isolinux.cfg ]; then
			syslinux_configfile -i "${dir}"/isolinux/isolinux.cfg
		elif [ -f "${dir}"/syslinux/syslinux.cfg ]; then
			syslinux_configfile -s "${dir}"/syslinux/syslinux.cfg
		fi
	done
}

function search_isolinux {
	for i in 0 1; do
		# raw devices
		try_isolinux_config "(${1}${i})"
		for part in 1 2 3 4 5; do
			# MBR/GPT partitions
			try_isolinux_config "(${1}${i},${part})"
		done
	done
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}


if loadfont (cbfsdisk)/font.pf2 ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_US
  insmod gettext
fi

terminal_input console
terminal_output gfxterm
gfxpayload=keep

if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=1
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi

insmod png
if background_image (cbfsdisk)/background.png; then
	true
fi

#Scan for OS on internal HDD
insmod regexp
insmod ahci
insmod part_msdos
for x in (ahci*,*) ; do
	if [ -f "$x/netbsd" ] ; then
		menuentry "Load NetBSD from $x" $x { 
			root=$2
			knetbsd /netbsd
		}
	fi
done

for x in (usb*,*) ; do
	if [ -f "$x/netbsd" ] ; then
		menuentry "Load NetBSD from $x" $x { 
			root=$2
			knetbsd /netbsd
		}
	fi
done

for x in (ahci*,*) ; do
	if [ -f "$x/grub/grub.cfg" ] ; then
		menuentry "Load Config from $x" $x { 
			root=$2
			configfile /grub/grub.cfg
		}
	fi
	if [ -f "$x/boot/grub/grub.cfg" ] ; then
		menuentry "Load Config from $x" $x {
			root=$2
			configfile /boot/grub/grub.cfg
		}
	fi
done

for x in (usb*,*) ; do
	if [ -f "$x/grub/grub.cfg" ] ; then
		menuentry "Load Config from $x" $x { 
			root=$2
			configfile /grub/grub.cfg
		}
	fi
	if [ -f "$x/boot/grub/grub.cfg" ] ; then
		menuentry "Load Config from $x" $x {
			root=$2
			configfile /boot/grub/grub.cfg
		}
	fi
done


menuentry 'Search ISOLINUX menu (AHCI)  [a]' --hotkey='a' {
	search_isolinux ahci
}

menuentry 'Search ISOLINUX menu (USB)  [u]' --hotkey='u' {
	search_isolinux usb
}

menuentry 'Search ISOLINUX menu (CD/DVD)  [d]' --hotkey='d' {
	insmod ata
	for dev in ata0 ata1 ata2 ata3 ahci1; do
		try_isolinux_config "(${dev})"
	done
}

menuentry 'Search for GRUB2 configuration on external media  [s]' --hotkey='s' {
	search_grub usb
}

menuentry 'nvramcui' {
	chainloader (cbfsdisk)/img/nvramcui
}

menuentry 'coreinfo' {
	chainloader (cbfsdisk)/img/coreinfo
}

menuentry 'Memtest86+' {
	chainloader (cbfsdisk)/img/memtest
}

menuentry 'tint' {
	chainloader (cbfsdisk)/img/tint
}

menuentry 'Poweroff  [p]' --hotkey='p' {
	halt
}

menuentry 'Reboot  [r]' --hotkey='r' {
	reboot
}