-
Notifications
You must be signed in to change notification settings - Fork 1
/
grub.template
193 lines (168 loc) · 5.52 KB
/
grub.template
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
set check_signatures=%%SIGN%%
trust --skip-sig $prefix/BootMgr.gpg
insmod all_video
insmod part_msdos
insmod part_gpt
insmod gzio
insmod ext2
insmod png
insmod gfxterm
loadfont $prefix/fonts/ascii.pf2
loadfont $prefix/fonts/DejaVuSans10.pf2
loadfont $prefix/fonts/DejaVuSans12.pf2
loadfont $prefix/fonts/DejaVuSans-Bold14.pf2
loadfont $prefix/fonts/euro.pf2
loadfont $prefix/fonts/unicode.pf2
font=unicode
search --no-floppy --fs-uuid --set=root %%UUIDROOT%%
export root
set locale_dir=$prefix/locale
set lang=%%LANG%%
insmod gettext
set gfxmode=auto
terminal_output gfxterm
set theme=$prefix/themes/theme.txt
export theme
set timeout_style=%%STYLE%%
set timeout=%%TIMEOUT%%
%%ROOTUSR%%
%%USER%%
set superusers="root"
export superusers
HDROOT=%%HDROOT%%
OPTIONS="%%KERNELOPTS%%"
OPTRESCUE="%%KERNELRESCUE%%"
# find last kernel
for FKERNEL in ls ($root)/vmlinuz-*.x86_64; do
unset KCURRENTVERSION
unset KCURRENTMAJOR
unset KCURRENTMINOR
unset KCURRENTPATCH
regexp --set FKERN ".*/vmlinuz-([0-9]{1,}.[0-9]{1,}.[0-9]{1,}-[0-9]{1,}.*.x86_64)" $FKERNEL
if test -z $KLAST; then
KLAST=$FKERN
regexp --set KLASTVERSION ".*/vmlinuz-([0-9]{1,2}).*.x86_64" $FKERNEL
regexp --set KLASTMAJOR ".*/vmlinuz-[0-9]{1,2}.([0-9]{1,2}).*.x86_64" $FKERNEL
regexp --set KLASTMINOR ".*/vmlinuz-[0-9]{1,2}.[0-9]{1,2}.([0-9]{1,2}).*.x86_64" $FKERNEL
regexp --set KLASTPATCH ".*/vmlinuz-[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}.([0-9]{3,}).*.x86_64" $FKERNEL
else
regexp --set KCURRENTVERSION ".*/vmlinuz-([0-9]{1,2}).*.x86_64" $FKERNEL
if test $KCURRENTVERSION -gt $KLASTVERSION; then
KLAST=$FKERN
continue
fi
regexp --set KCURRENTMAJOR ".*/vmlinuz-[0-9]{1,2}.([0-9]{1,2}).*.x86_64" $FKERNEL
if test $KCURRENTMAJOR -gt $KLASTMAJOR; then
KLAST=$FKERN
continue
fi
regexp --set KCURRENTMINOR ".*/vmlinuz-[0-9]{1,2}.[0-9]{1,2}.([0-9]{1,2}).*.x86_64" $FKERNEL
if test $KCURRENTMINOR -gt $KLASTMINOR; then
KLAST=$FKERN
continue
fi
regexp --set KCURRENTPATCH ".*/vmlinuz-[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}.([0-9]{3,}).*.x86_64" $FKERNEL
if test $KCURRENTPATCH -gt $KLASTPATCH; then
KLAST=$FKERN
continue
fi
fi
done
# find previous kernel
for FKERNEL in ls ($root)/vmlinuz-*.x86_64; do
unset KCURRENTVERSION
unset KCURRENTMAJOR
unset KCURRENTMINOR
unset KCURRENTPATCH
regexp --set FKERN ".*/vmlinuz-([0-9]{1,}.[0-9]{1,}.[0-9]{1,}-[0-9]{1,}.*.x86_64)" $FKERNEL
if test $FKERN == $KLAST; then continue; fi
if test -z $KPREV; then
KPREV=$FKERN
regexp --set KLASTVERSION ".*/vmlinuz-([0-9]{1,2}).*.x86_64" $FKERNEL
regexp --set KLASTMAJOR ".*/vmlinuz-[0-9]{1,2}.([0-9]{1,2}).*.x86_64" $FKERNEL
regexp --set KLASTMINOR ".*/vmlinuz-[0-9]{1,2}.[0-9]{1,2}.([0-9]{1,2}).*.x86_64" $FKERNEL
regexp --set KLASTPATCH ".*/vmlinuz-[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}.([0-9]{3,}).*.x86_64" $FKERNEL
else
regexp --set KCURRENTVERSION ".*/vmlinuz-([0-9]{1,2}).*.x86_64" $FKERNEL
if test $KCURRENTVERSION -gt $KLASTVERSION; then
KPREV=$FKERN
continue
fi
regexp --set KCURRENTMAJOR ".*/vmlinuz-[0-9]{1,2}.([0-9]{1,2}).*.x86_64" $FKERNEL
if test $KCURRENTMAJOR -gt $KLASTMAJOR; then
KPREV=$FKERN
continue
fi
regexp --set KCURRENTMINOR ".*/vmlinuz-[0-9]{1,2}.[0-9]{1,2}.([0-9]{1,2}).*.x86_64" $FKERNEL
if test $KCURRENTMINOR -gt $KLASTMINOR; then
KPREV=$FKERN
continue
fi
regexp --set KCURRENTPATCH ".*/vmlinuz-[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}.([0-9]{3,}).*.x86_64" $FKERNEL
if test $KCURRENTPATCH -gt $KLASTPATCH; then
KPREV=$FKERN
continue
fi
fi
done
export HDROOT
export OPTIONS
export OPTRESCUE
export KLAST
export KPREV
export KRESCUE
if [ "$KLAST" ]; then
menuentry "Fedora $KLAST" --class default --class %%OS%% --class gnu-linux --unrestricted --id=1 {
linuxefi /vmlinuz-$KLAST root=$HDROOT $OPTIONS
initrdefi /initramfs-$KLAST.img
}
fi
if [ "$KPREV" ]; then
menuentry "Fedora $KPREV (previous kernel)" --class latest --class %%OS%% --class gnu-linux --users superusers --id=2 {
linuxefi /vmlinuz-$KPREV root=$HDROOT $OPTIONS
initrdefi /initramfs-$KPREV.img
}
fi
submenu "Admin Access (restricted)" --class recovery --users superusers --id=3 {
if [ "$KLAST" ]; then
menuentry "Fedora $KLAST (recovery mode)" --class default --class %%OS%% --class gnu-linux --unrestricted --id=4 {
linuxefi /vmlinuz-$KLAST root=$HDROOT $OPTRESCUE
initrdefi /initramfs-$KLAST.img
}
fi
if [ "$KPREV" ]; then
menuentry "Fedora $KPREV (testing, recovery mode)" --class latest --class %%OS%% --class gnu-linux --unrestricted --id=5 {
linuxefi /vmlinuz-$KPREV root=$HDROOT $OPTRESCUE
initrdefi /initramfs-$KPREV.img
}
fi
if [ "$KRESCUE" ]; then
menuentry "Fedora $KRESCUE (legacy, recovery mode)" --class old --class %%OS%% --class gnu-linux --users unrestricted --id=6 {
linuxefi /vmlinuz-$KRESCUE root=$HDROOT $OPTRESCUE
initrdefi /initramfs-$KRESCUE.img
}
fi
menuentry "System Setup" --class UEFI --unrestricted --id=7 {
fwsetup
}
menuentry "Restart" --class reboot --unrestricted --id=8 {
reboot
}
menuentry "Halt" --class poweroff --unrestricted --id=9 {
halt
}
}
##menuentry "Windows" --class windows --class useless --users %%WITHUSER%% --id=10 {
## insmod part_gpt
## insmod fat
## insmod ntfs
## parttool ${root} hidden-
## search --no-floppy --fs-uuid --set=root %%WINROOTID%%
## chainloader /EFI/Microsoft/Boot/bootmgfw.efi
##}
menuentry "Restart" --class reboot --unrestricted --id=11 {
reboot
}
menuentry "Halt" --class poweroff --unrestricted --id=12 {
halt
}