50 lines
1.6 KiB
Bash
Executable File
50 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# grub-mkconfig helper script.
|
|
#
|
|
# Copyright © 2014 Niall Walsh <niallwalsh@celtux.org>
|
|
#
|
|
# This program 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 2
|
|
# of the License, or (at your option) any later version.
|
|
#
|
|
# This program 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.
|
|
|
|
set -e
|
|
|
|
MT_EFI_STANDALONE=""
|
|
MT_EFI_PORTABLE_PATH="/boot/efi/EFI/BOOT"
|
|
|
|
# override tool behaviour through /etc/default/grub2-fll-standalone
|
|
if [ -r /etc/default/grub2-portable-efi ]; then
|
|
. /etc/default/grub2-portable-efi
|
|
fi
|
|
|
|
patt='[[:space:]]-o[[:space:]]\+/boot/grub/grub.cfg'
|
|
# do nothing if disabled or grub-mkconfig is generating /boot/grub/grub.cfg
|
|
( [ "${MT_EFI_STANDALONE}" != "disable" ] && \
|
|
ps x | grep 'grub-mkconfig[[:space:]]' | grep -q -e "${patt}[[:space:]]" -e "${patt}$" ) || exit
|
|
|
|
beeb="${MT_EFI_PORTABLE_PATH}"
|
|
if [ -e "${beeb}" ]; then
|
|
# do not do anything to a beeb we didn't create
|
|
[ ! -e "${beeb}/fullstory" ] && exit
|
|
else
|
|
# create beeb and mark it as ours
|
|
mkdir -p "${beeb}"
|
|
touch "${beeb}/fullstory"
|
|
fi
|
|
|
|
for platform in i386-efi x86_64-efi ; do
|
|
filename="bootx64"
|
|
[ "${platform}" = "i386-efi" ] && filename="bootia32"
|
|
[ -e /usr/lib/grub/${platform} ] && grub-mkstandalone \
|
|
-o ${beeb}/${filename}.efi --compress=xz -O ${platform} \
|
|
/boot/grub/grub.cfg=/boot/grub/grub.cfg.new 2>&1 > /dev/null
|
|
done
|
|
|