Created
March 23, 2015 16:29
-
-
Save strohel/42bd1a6cf87eb3f2167b to your computer and use it in GitHub Desktop.
/usr/local/sbin/shl_install_efi_stub.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DEFAULT_ARGS='pcie_aspm=force' | |
KERNEL_ARGS="${KERNEL_ARGS:-${DEFAULT_ARGS}}" | |
for file in /boot/vmlinuz-*; do | |
if [ "$file" == '/boot/vmlinuz-*' ]; then | |
echo "Nothing to do" | |
continue | |
fi | |
version="${file:14}" | |
dest="/boot/EFI/Gentoo/vmlinuz-$version.efi" | |
echo "Working on $file, version $version, destination $dest" | |
if [ -e "$dest" ]; then | |
EFIBOOTMGR=0 | |
else | |
EFIBOOTMGR=1 | |
fi | |
if ! cp -vf "$file" "$dest"; then | |
echo "Failed to copy $file to $dest, skipping this kernel" | |
continue | |
fi | |
if [ "$EFIBOOTMGR" != "1" ]; then | |
rm -vf "$file" | |
echo "File $dest existed before, skipping efibootmgr" | |
continue | |
fi | |
if efibootmgr -c -d /dev/sda -p 1 -L "Gentoo Linux $version" \ | |
-l '\EFI\Gentoo\'"vmlinuz-$version.efi" \ | |
-u "${KERNEL_ARGS}" | |
then | |
rm -vf "$file" | |
else | |
echo "efibootmgr failed, not removing $file" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment