#!/bin/bash

if [ x`df -T /boot/efi | tail -n +2 | awk '{print $2}'` != x"hfsplus" ]; then
   exit
fi

if [ -f /boot/efi/EFI/redhat/grub.efi ]; then
   ln -f /boot/efi/EFI/redhat/grub.efi /boot/efi/System/Library/CoreServices/boot.efi;
   ln -sf ../../../EFI/redhat/grub.conf /boot/efi/System/Library/CoreServices/boot.conf;
   hfs-bless /boot/efi/EFI/redhat/grub.efi   
   if [ -f /usr/share/pixmaps/bootloader/fedora.vol ]; then
      cp /usr/share/pixmaps/bootloader/fedora.vol /boot/efi/EFI/redhat/.disk_label;
   fi
elif [ -f /boot/efi/EFI/redhat/grub2-efi/grub.efi ]; then
   ln -f /boot/efi/EFI/redhat/grub2-efi/grub.efi /boot/efi/System/Library/CoreServices/boot.efi;
   ln -sf ../../../EFI/redhat/grub2-efi/grub.cfg /boot/efi/System/Library/CoreServices/boot.cfg;
   hfs-bless /boot/efi/EFI/redhat/grub2-efi/grub.efi
   if [ -f /usr/share/pixmaps/bootloader/fedora.vol ]; then
      cp /usr/share/pixmaps/bootloader/fedora.vol /boot/efi/EFI/redhat/.disk_label;
   fi
fi

if [ -f /usr/share/pixmaps/bootloader/fedora.icns ]; then
   cp /usr/share/pixmaps/bootloader/fedora.icns /boot/efi/.VolumeIcon.icns;
fi;

