#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see .
transform="s,x,x,"
prefix="/usr/local"
exec_prefix="${prefix}"
datarootdir="${prefix}/share"
grub_lang=`echo $LANG | cut -d . -f 1`
export TEXTDOMAIN=grub
export TEXTDOMAINDIR="/usr/local/share/locale"
. "${datarootdir}/grub/grub-mkconfig_lib"
# Set indicator that we haven't written device access yet
haveDevAccess=0
# Work-around for systems with GPTID enabled still
echo "insmod part_gpt"
# Do this as early as possible, since other commands might depend on it.
# (e.g. the `loadfont' command might need lvm or raid modules)
for i in ${GRUB_PRELOAD_MODULES} ; do
echo "insmod $i"
done
if [ -e "/root/beadm.install" ] ; then
BEADM="/root/beadm.install"
else
BEADM="beadm"
fi
if [ "x${GRUB_DEFAULT}" = "x" ] ; then
GRUB_DEFAULT=0
fi
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=auto ; fi
# Check if we have more than one BE, and need to show the menu by default
beNum=`$BEADM list 2>/dev/null | grep -v 'Mountpoint' | wc -l | awk '{print $1}'`
if [ $beNum -gt 1 ] ; then GRUB_HIDDEN_TIMEOUT=""; fi
if [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fi
if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fi
if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi
cat << EOF
if [ -s \$prefix/grubenv ]; then
load_env
fi
EOF
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
cat < /dev/null ; then
font_path="${path}"
else
continue
fi
break 2
done
done
if [ -n "${font_path}" ] ; then
cat << EOF
if [ x\$feature_default_font_path = xy ] ; then
font=unicode
else
EOF
# Make the font accessible
if [ $haveDevAccess -ne 1 ] ; then
haveDevAccess=1
prepare_grub_to_access_device `${grub_probe} --target=device "${font_path}"`
fi
cat << EOF
font="`make_system_path_relative_to_its_root "${font_path}"`"
fi
if loadfont \$font ; then
EOF
else
cat << EOF
if loadfont unicode ; then
EOF
fi
fi
cat << EOF
if [ x"\${grub_platform}" = xpc ] ; then
set gfxmode=${GRUB_GFXMODE}
load_video
insmod gfxterm
else
# EFI
insmod efi_gop
insmod gfxterm
insmod font
insmod videotest
insmod videoinfo
set gfxmode=${GRUB_GFXMODE}
fi
EOF
# Gettext variables and module
if [ "x${LANG}" != "xC" -a "x${grub_lang}" != "xen_US" ] ; then
cat << EOF
set locale_dir=\$prefix/locale
set lang=${grub_lang}
insmod gettext
EOF
fi
cat <&2
if [ $haveDevAccess -ne 1 ] ; then
haveDevAccess=1
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"`
fi
cat << EOF
insmod gfxmenu
EOF
themedir="`dirname "$GRUB_THEME"`"
for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do
if [ -f "$x" ]; then
cat << EOF
loadfont (\$root)`make_system_path_relative_to_its_root $x`
EOF
fi
done
if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; then
cat << EOF
insmod jpeg
EOF
fi
if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then
cat << EOF
insmod png
EOF
fi
if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then
cat << EOF
insmod tga
EOF
fi
cat << EOF
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
export theme
EOF
elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \
&& is_path_readable_by_grub "$GRUB_BACKGROUND"; then
gettext_printf "Found background: %s\n" "$GRUB_BACKGROUND" >&2
case "$GRUB_BACKGROUND" in
*.png) reader=png ;;
*.tga) reader=tga ;;
*.jpg|*.jpeg) reader=jpeg ;;
*) gettext "Unsupported image format" >&2; echo >&2; exit 1 ;;
esac
if [ $haveDevAccess -ne 1 ] ; then
haveDevAccess=1
prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"`
fi
cat << EOF
insmod $reader
background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
EOF
fi
fi
make_timeout ()
{
if [ "x${1}" != "x" ] ; then
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
verbose=
else
verbose=" --verbose"
fi
cat << EOF
echo "Hold Left-Shift for menu.."
if sleep$verbose --interruptible ${1} ; then
if keystatus --shift; then
set timeout=-1
else
set timeout=0
fi
fi
EOF
else
cat << EOF
set timeout=${2}
EOF
fi
}
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
cat <