]> git.proxmox.com Git - grub2.git/blame - util/grub.d/00_header.in
GRUB_BACKGROUND support.
[grub2.git] / util / grub.d / 00_header.in
CommitLineData
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 19transform="@program_transform_name@"
20
42c71976 21prefix=@prefix@
22exec_prefix=@exec_prefix@
23libdir=@libdir@
52768e37 24grub_prefix=`echo /boot/grub | sed ${transform}`
a239a5e9
CPE
25locale_dir=`echo /boot/grub/locale | sed ${transform}`
26grub_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 32for i in ${GRUB_PRELOAD_MODULES} ; do
33 echo "insmod $i"
34done
35
ebd97f6e 36if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
242f0731 37if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
ebd97f6e 38if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
d5a7dc5b 39if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi
ebd97f6e 40
41cat << EOF
42356b4d
CW
42if [ -s \$prefix/grubenv ]; then
43 load_env
44fi
36cd6dd1 45set default="${GRUB_DEFAULT}"
242f0731 46if [ \${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 52fi
5c23bb0f
CW
53
54function savedefault {
55 if [ -z \${boot_once} ]; then
56 saved_entry=\${chosen}
57 save_env saved_entry
58 fi
59}
c0f90770 60EOF
61
d5631db0
VS
62serial=0;
63gfxterm=0;
64for 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
71done
72
73if [ "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 83fi
651c29b7 84
d5631db0 85if [ "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 90if 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 94EOF
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
101EOF
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`
107EOF
108 fi
109 done
110 if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ]; then
111 cat << EOF
112 insmod jpeg
113EOF
114 fi
115 if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then
116 cat << EOF
117 insmod png
118EOF
119 fi
120 if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then
121 cat << EOF
122 insmod tga
123EOF
124 fi
125
126 cat << EOF
6419c43e 127 set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
d7c43ba1
MV
128EOF
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
142EOF
143 fi
144 cat << EOF
145fi
3b6f7ab7 146EOF
eb1c9594 147fi
d5631db0
VS
148
149case x${GRUB_TERMINAL_INPUT} in
150 x)
151 # Just use the native terminal
152 ;;
153 x*)
eb1c9594 154 cat << EOF
d5631db0
VS
155if 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 159fi
ebd97f6e 160EOF
6193defe 161 ;;
d5631db0
VS
162esac
163
164case x${GRUB_TERMINAL_OUTPUT} in
52768e37 165 x)
166 # Just use the native terminal
167 ;;
168 x*)
6c529df7 169 cat << EOF
170if 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}
174fi
175EOF
6193defe 176 ;;
177esac
9a10df16 178
203ffbfa 179# Gettext variables and module
0648f857 180if [ "x${LANG}" != "xC" ] ; then
94fabf58 181 prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir})
0648f857 182 cat << EOF
94fabf58 183set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir})
a239a5e9 184set lang=${grub_lang}
a2c1332b 185insmod gettext
203ffbfa 186EOF
0648f857 187fi
203ffbfa 188
9a10df16 189if [ "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
196if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then
197 set timeout=${GRUB_TIMEOUT}
198fi
199EOF
200else
201 cat << EOF
202set timeout=${GRUB_TIMEOUT}
203EOF
204fi
0a39de87
ST
205
206# Play an initial tune
207if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
208 cat << EOF
209insmod play
210play ${GRUB_INIT_TUNE}
211EOF
212fi