99_zzz-portable-efi.in 1.6 KB
Newer Older
udeved's avatar
udeved committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/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