Merge branch 'makefile' into haiku
[grub2/phcoder.git] / util / grub.d / 00_header.in
blobd8fa4165daa0c659c96a3299e91d84761fe89494
1 #! /bin/sh -e
3 # update-grub helper script.
4 # Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
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
9 # (at your option) any later version.
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.
16 # You should have received a copy of the GNU General Public License
17 # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 transform="@program_transform_name@"
21 prefix=@prefix@
22 exec_prefix=@exec_prefix@
23 libdir=@libdir@
24 grub_prefix=`echo /boot/grub | sed ${transform}`
26 . ${libdir}/grub/grub-mkconfig_lib
28 # Do this as early as possible, since other commands might depend on it.
29 # (e.g. the `loadfont' command might need lvm or raid modules)
30 for i in ${GRUB_PRELOAD_MODULES} ; do
31 echo "insmod $i"
32 done
34 if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
35 if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
36 if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi
38 cat << EOF
39 set default=${GRUB_DEFAULT}
40 set timeout=${GRUB_TIMEOUT}
41 EOF
43 case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
44 serial:* | *:serial)
45 if ! test -e ${grub_prefix}/serial.mod ; then
46 echo "Serial terminal not available on this platform." >&2 ; exit 1
49 if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
50 grub_warn "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used."
51 GRUB_SERIAL_COMMAND=serial
53 echo "${GRUB_SERIAL_COMMAND}"
55 esac
57 case x${GRUB_TERMINAL_INPUT} in
59 # Just use the native terminal
61 x*)
62 cat << EOF
63 if terminal_input ${GRUB_TERMINAL_INPUT} ; then true ; else
64 # For backward compatibility with versions of terminal.mod that don't
65 # understand terminal_input
66 terminal ${GRUB_TERMINAL_INPUT}
68 EOF
70 esac
72 case x${GRUB_TERMINAL_OUTPUT} in
73 xgfxterm)
74 # Make the font accessible
75 prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}`
77 # Pick a video backend
78 video_backend=
79 for i in vbe ; do
80 if test -e ${grub_prefix}/$i.mod ; then
81 video_backend=$i
82 break
84 done
85 if ! [ "${video_backend}" ] ; then
86 echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
89 cat << EOF
90 if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
91 set gfxmode=${GRUB_GFXMODE}
92 insmod gfxterm
93 insmod ${video_backend}
94 if terminal_output gfxterm ; then true ; else
95 # For backward compatibility with versions of terminal.mod that don't
96 # understand terminal_output
97 terminal gfxterm
103 # Just use the native terminal
106 cat << EOF
107 if terminal_output ${GRUB_TERMINAL_OUTPUT} ; then true ; else
108 # For backward compatibility with versions of terminal.mod that don't
109 # understand terminal_output
110 terminal ${GRUB_TERMINAL_OUTPUT}
114 esac