]>
Commit | Line | Data |
---|---|---|
ebd97f6e | 1 | #! /bin/sh -e |
2 | ||
1ebbe064 | 3 | # grub-mkconfig helper script. |
3b6f7ab7 | 4 | # Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. |
ebd97f6e | 5 | # |
5a79f472 | 6 | # GRUB is free software: you can redistribute it and/or modify |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation, either version 3 of the License, or | |
ebd97f6e | 9 | # (at your option) any later version. |
10 | # | |
5a79f472 | 11 | # GRUB is distributed in the hope that it will be useful, |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
ebd97f6e | 15 | # |
16 | # You should have received a copy of the GNU General Public License | |
5a79f472 | 17 | # along with GRUB. If not, see <http://www.gnu.org/licenses/>. |
ebd97f6e | 18 | |
52768e37 | 19 | transform="@program_transform_name@" |
20 | ||
42c71976 | 21 | prefix=@prefix@ |
22 | exec_prefix=@exec_prefix@ | |
23 | libdir=@libdir@ | |
52768e37 | 24 | grub_prefix=`echo /boot/grub | sed ${transform}` |
a239a5e9 CPE |
25 | locale_dir=`echo /boot/grub/locale | sed ${transform}` |
26 | grub_lang=`echo $LANG | cut -d _ -f 1` | |
42c71976 | 27 | |
18ade780 | 28 | . ${libdir}/grub/grub-mkconfig_lib |
ebd97f6e | 29 | |
1eb8c802 | 30 | # Do this as early as possible, since other commands might depend on it. |
16ac430e | 31 | # (e.g. the `loadfont' command might need lvm or raid modules) |
1eb8c802 | 32 | for i in ${GRUB_PRELOAD_MODULES} ; do |
33 | echo "insmod $i" | |
34 | done | |
35 | ||
ebd97f6e | 36 | if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi |
242f0731 | 37 | if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi |
ebd97f6e | 38 | if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi |
d5a7dc5b | 39 | if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi |
ebd97f6e | 40 | |
41 | cat << EOF | |
42356b4d CW |
42 | if [ -s \$prefix/grubenv ]; then |
43 | load_env | |
44 | fi | |
36cd6dd1 | 45 | set default="${GRUB_DEFAULT}" |
242f0731 | 46 | if [ \${prev_saved_entry} ]; then |
b967a04d | 47 | set saved_entry=\${prev_saved_entry} |
242f0731 | 48 | save_env saved_entry |
b967a04d | 49 | set prev_saved_entry= |
242f0731 | 50 | save_env prev_saved_entry |
b445cfaa | 51 | set boot_once=true |
242f0731 | 52 | fi |
5c23bb0f CW |
53 | |
54 | function savedefault { | |
55 | if [ -z \${boot_once} ]; then | |
56 | saved_entry=\${chosen} | |
57 | save_env saved_entry | |
58 | fi | |
59 | } | |
c0f90770 | 60 | EOF |
61 | ||
d5631db0 VS |
62 | serial=0; |
63 | gfxterm=0; | |
64 | for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do | |
65 | if [ xserial = "x$x" ]; then | |
66 | serial=1; | |
67 | fi | |
68 | if [ xgfxterm = "x$x" ]; then | |
69 | gfxterm=1; | |
70 | fi | |
71 | done | |
72 | ||
73 | if [ "x$serial" = x1 ]; then | |
651c29b7 | 74 | if ! test -e ${grub_prefix}/serial.mod ; then |
d5631db0 | 75 | echo "Serial terminal not available on this platform." >&2 ; exit 1 |
651c29b7 | 76 | fi |
77 | ||
78 | if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then | |
d5631db0 VS |
79 | grub_warn "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used." |
80 | GRUB_SERIAL_COMMAND=serial | |
651c29b7 | 81 | fi |
82 | echo "${GRUB_SERIAL_COMMAND}" | |
6c529df7 | 83 | fi |
651c29b7 | 84 | |
d5631db0 | 85 | if [ "x$gfxterm" = x1 ]; then |
972e2f7a | 86 | # Make the font accessible |
87 | prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}` | |
52768e37 | 88 | |
972e2f7a | 89 | cat << EOF |
1e901a75 | 90 | if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then |
d5a7dc5b | 91 | set gfxmode=${GRUB_GFXMODE} |
3b3f6629 | 92 | insmod gfxterm |
3b76e68b | 93 | insmod ${GRUB_VIDEO_BACKEND} |
eb1c9594 | 94 | EOF |
d5631db0 | 95 | if [ x$GRUB_THEME != x ] && [ -f $GRUB_THEME ] \ |
eb1c9594 | 96 | && is_path_readable_by_grub $GRUB_THEME; then |
d5631db0 VS |
97 | echo "Found theme: $GRUB_THEME" >&2 |
98 | prepare_grub_to_access_device `${grub_probe} --target=device $GRUB_THEME` | sed -e "s/^/ /" | |
99 | cat << EOF | |
6419c43e | 100 | insmod gfxmenu |
d64795c0 VS |
101 | EOF |
102 | themedir="`dirname $GRUB_THEME`" | |
103 | for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do | |
104 | if [ -f "$x" ]; then | |
105 | cat << EOF | |
106 | loadfont (\$root)`make_system_path_relative_to_its_root $x` | |
107 | EOF | |
108 | fi | |
109 | done | |
110 | if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ]; then | |
111 | cat << EOF | |
112 | insmod jpeg | |
113 | EOF | |
114 | fi | |
115 | if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then | |
116 | cat << EOF | |
117 | insmod png | |
118 | EOF | |
119 | fi | |
120 | if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then | |
121 | cat << EOF | |
122 | insmod tga | |
123 | EOF | |
124 | fi | |
125 | ||
126 | cat << EOF | |
6419c43e | 127 | set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME` |
d7c43ba1 MV |
128 | EOF |
129 | elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \ | |
130 | && is_path_readable_by_grub "$GRUB_BACKGROUND"; then | |
131 | echo "Found background: $GRUB_BACKGROUND" >&2 | |
132 | case "$GRUB_BACKGROUND" in | |
133 | *.png) reader=png ;; | |
134 | *.tga) reader=tga ;; | |
135 | *.jpg|*.jpeg) reader=jpeg ;; | |
136 | *) echo "Unsupported image format" >&2; exit 1 ;; | |
137 | esac | |
138 | prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"` | sed -e "s/^/ /" | |
139 | cat << EOF | |
140 | insmod $reader | |
141 | background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"` | |
d5631db0 VS |
142 | EOF |
143 | fi | |
144 | cat << EOF | |
145 | fi | |
3b6f7ab7 | 146 | EOF |
eb1c9594 | 147 | fi |
d5631db0 VS |
148 | |
149 | case x${GRUB_TERMINAL_INPUT} in | |
150 | x) | |
151 | # Just use the native terminal | |
152 | ;; | |
153 | x*) | |
eb1c9594 | 154 | cat << EOF |
d5631db0 VS |
155 | if terminal_input ${GRUB_TERMINAL_INPUT} ; then true ; else |
156 | # For backward compatibility with versions of terminal.mod that don't | |
157 | # understand terminal_input | |
158 | terminal ${GRUB_TERMINAL_INPUT} | |
3b3f6629 | 159 | fi |
ebd97f6e | 160 | EOF |
6193defe | 161 | ;; |
d5631db0 VS |
162 | esac |
163 | ||
164 | case x${GRUB_TERMINAL_OUTPUT} in | |
52768e37 | 165 | x) |
166 | # Just use the native terminal | |
167 | ;; | |
168 | x*) | |
6c529df7 | 169 | cat << EOF |
170 | if terminal_output ${GRUB_TERMINAL_OUTPUT} ; then true ; else | |
171 | # For backward compatibility with versions of terminal.mod that don't | |
172 | # understand terminal_output | |
173 | terminal ${GRUB_TERMINAL_OUTPUT} | |
174 | fi | |
175 | EOF | |
6193defe | 176 | ;; |
177 | esac | |
9a10df16 | 178 | |
203ffbfa | 179 | # Gettext variables and module |
0648f857 | 180 | if [ "x${LANG}" != "xC" ] ; then |
94fabf58 | 181 | prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir}) |
0648f857 | 182 | cat << EOF |
94fabf58 | 183 | set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir}) |
a239a5e9 | 184 | set lang=${grub_lang} |
a2c1332b | 185 | insmod gettext |
203ffbfa | 186 | EOF |
0648f857 | 187 | fi |
203ffbfa | 188 | |
9a10df16 | 189 | if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then |
a2c1332b | 190 | if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then |
9a10df16 | 191 | verbose= |
192 | else | |
193 | verbose=" --verbose" | |
194 | fi | |
195 | cat << EOF | |
196 | if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then | |
197 | set timeout=${GRUB_TIMEOUT} | |
198 | fi | |
199 | EOF | |
200 | else | |
201 | cat << EOF | |
202 | set timeout=${GRUB_TIMEOUT} | |
203 | EOF | |
204 | fi | |
0a39de87 ST |
205 | |
206 | # Play an initial tune | |
207 | if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then | |
208 | cat << EOF | |
209 | insmod play | |
210 | play ${GRUB_INIT_TUNE} | |
211 | EOF | |
212 | fi |