source: src-sh/pc-extractoverlay/ports-overlay/usr/local/etc/grub.d/00_header @ 4930125

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 4930125 was 4930125, checked in by Kris Moore <kris@…>, 13 months ago

Opps, fix timeout to 0 when doing HIDDEN boot

  • Property mode set to 100755
File size: 7.6 KB
Line 
1#! /bin/sh
2set -e
3
4# grub-mkconfig helper script.
5# Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.
6#
7# GRUB is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# GRUB is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
19
20transform="s,x,x,"
21
22prefix="/usr/local"
23exec_prefix="${prefix}"
24datarootdir="${prefix}/share"
25grub_lang=`echo $LANG | cut -d . -f 1`
26
27export TEXTDOMAIN=grub
28export TEXTDOMAINDIR="/usr/local/share/locale"
29
30. "${datarootdir}/grub/grub-mkconfig_lib"
31
32# Do this as early as possible, since other commands might depend on it.
33# (e.g. the `loadfont' command might need lvm or raid modules)
34for i in ${GRUB_PRELOAD_MODULES} ; do
35  echo "insmod $i"
36done
37
38if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
39if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
40if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
41if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=auto ; fi
42
43# Check if we have more than one BE, and need to show the menu by default
44beNum=`beadm list 2>/dev/null | grep -v 'Mountpoint' | wc -l | awk '{print $1}'`
45if [ $beNum -gt 1 ] ; then GRUB_HIDDEN_TIMEOUT=""; fi
46
47if [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fi
48if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fi
49if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi
50
51cat << EOF
52if [ -s \$prefix/grubenv ]; then
53  load_env
54fi
55EOF
56if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
57    cat <<EOF
58if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
59   set default="${GRUB_DEFAULT_BUTTON}"
60else
61   set default="${GRUB_DEFAULT}"
62fi
63EOF
64else
65    cat <<EOF
66set default="${GRUB_DEFAULT}"
67EOF
68fi
69cat <<EOF
70
71if [ x"\${feature_menuentry_id}" = xy ]; then
72  menuentry_id_option="--id"
73else
74  menuentry_id_option=""
75fi
76
77export menuentry_id_option
78
79if [ "\${prev_saved_entry}" ]; then
80  set saved_entry="\${prev_saved_entry}"
81  save_env saved_entry
82  set prev_saved_entry=
83  save_env prev_saved_entry
84  set boot_once=true
85fi
86
87function savedefault {
88  if [ -z "\${boot_once}" ]; then
89    saved_entry="\${chosen}"
90    save_env saved_entry
91  fi
92}
93
94function load_video {
95EOF
96if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
97    cat <<EOF
98  insmod ${GRUB_VIDEO_BACKEND}
99EOF
100else
101# If all_video.mod isn't available load all modules available
102# with versions prior to introduction of all_video.mod
103cat <<EOF
104  if [ x\$feature_all_video_module = xy ]; then
105    insmod all_video
106  else
107    insmod efi_gop
108    insmod efi_uga
109    insmod ieee1275_fb
110    insmod vbe
111    insmod vga
112    insmod video_bochs
113    insmod video_cirrus
114  fi
115EOF
116fi
117cat <<EOF
118}
119
120EOF
121
122serial=0;
123gfxterm=0;
124for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
125    if [ xserial = "x$x" ]; then
126        serial=1;
127    fi
128    if [ xgfxterm = "x$x" ]; then
129        gfxterm=1;
130    fi
131done
132
133if [ "x$serial" = x1 ]; then
134    if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
135        grub_warn "$(gettext "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used.")"
136        GRUB_SERIAL_COMMAND=serial
137    fi
138    echo "${GRUB_SERIAL_COMMAND}"
139fi
140
141if [ "x$gfxterm" = x1 ]; then
142    if [ -n "$GRUB_FONT" ] ; then
143       # Make the font accessible
144       prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT}"`
145    cat << EOF
146if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; then
147EOF
148    else
149        for dir in "${pkgdatadir}" "`echo '/boot/grub' | sed "s,//*,/,g"`" /usr/share/grub ; do
150            for basename in unicode unifont ascii; do
151                path="${dir}/${basename}.pf2"
152                if is_path_readable_by_grub "${path}" > /dev/null ; then
153                    font_path="${path}"
154                else
155                    continue
156                fi
157                break 2
158            done
159        done
160        if [ -n "${font_path}" ] ; then
161    cat << EOF
162if [ x\$feature_default_font_path = xy ] ; then
163   font=unicode
164else
165EOF
166                # Make the font accessible
167                prepare_grub_to_access_device `${grub_probe} --target=device "${font_path}"`
168    cat << EOF
169    font="`make_system_path_relative_to_its_root "${font_path}"`"
170fi
171
172if loadfont \$font ; then
173EOF
174            else
175    cat << EOF
176if loadfont unicode ; then
177EOF
178            fi
179        fi
180
181    cat << EOF
182  set gfxmode=${GRUB_GFXMODE}
183  load_video
184  insmod gfxterm
185EOF
186
187# Gettext variables and module
188if [ "x${LANG}" != "xC" -a "x${grub_lang}" != "xen_US" ] ; then
189  cat << EOF
190  set locale_dir=\$prefix/locale
191  set lang=${grub_lang}
192  insmod gettext
193EOF
194fi
195
196cat <<EOF
197fi
198EOF
199fi
200
201case x${GRUB_TERMINAL_INPUT} in
202  x)
203    # Just use the native terminal
204  ;;
205  x*)
206    cat << EOF
207terminal_input ${GRUB_TERMINAL_INPUT}
208EOF
209  ;;
210esac
211
212case x${GRUB_TERMINAL_OUTPUT} in
213  x)
214    # Just use the native terminal
215  ;;
216  x*)
217    cat << EOF
218terminal_output ${GRUB_TERMINAL_OUTPUT}
219EOF
220  ;;
221esac
222
223if [ "x$gfxterm" = x1 ]; then
224    if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
225        && is_path_readable_by_grub "$GRUB_THEME"; then
226        gettext_printf "Found theme: %s\n" "$GRUB_THEME" >&2
227
228        prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"`
229        cat << EOF
230insmod gfxmenu
231EOF
232        themedir="`dirname "$GRUB_THEME"`"
233        for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do
234            if [ -f "$x" ]; then
235                cat << EOF
236loadfont (\$root)`make_system_path_relative_to_its_root $x`
237EOF
238            fi
239        done
240        if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; then
241            cat << EOF
242insmod jpeg
243EOF
244        fi
245        if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then
246            cat << EOF
247insmod png
248EOF
249        fi
250        if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then
251            cat << EOF
252insmod tga
253EOF
254        fi
255           
256        cat << EOF
257set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
258export theme
259EOF
260    elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \
261            && is_path_readable_by_grub "$GRUB_BACKGROUND"; then
262        gettext_printf "Found background: %s\n" "$GRUB_BACKGROUND" >&2
263        case "$GRUB_BACKGROUND" in
264            *.png)         reader=png ;;
265            *.tga)         reader=tga ;;
266            *.jpg|*.jpeg)  reader=jpeg ;;
267            *)             gettext "Unsupported image format" >&2; echo >&2; exit 1 ;;
268        esac
269        prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"`
270        cat << EOF
271insmod $reader
272background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
273EOF
274    fi
275fi
276
277make_timeout ()
278{
279    if [ "x${1}" != "x" ] ; then
280        if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
281            verbose=
282        else
283            verbose=" --verbose"
284        fi
285        cat << EOF
286if sleep$verbose --interruptible ${1} ; then
287  if keystatus --shift; then
288    set timeout=-1
289  else
290    set timeout=0
291  fi
292fi
293EOF
294    else
295        cat << EOF
296set timeout=${2}
297EOF
298    fi
299}
300
301if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
302    cat <<EOF
303if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
304EOF
305make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}"
306echo else
307make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
308echo fi
309else
310make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
311fi
312
313if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ] && [ "x$GRUB_BUTTON_CMOS_CLEAN" = "xyes" ]; then
314    cat <<EOF
315cmosclean $GRUB_BUTTON_CMOS_ADDRESS
316EOF
317fi
318
319# Play an initial tune
320if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
321  echo "play ${GRUB_INIT_TUNE}"
322fi
323
324if [ "x${GRUB_BADRAM}" != "x" ] ; then
325  echo "badram ${GRUB_BADRAM}"
326fi
Note: See TracBrowser for help on using the repository browser.