#!/bin/bash

set -e

gzip -t ${2} 2>/dev/null && gzip -dc ${2} >${2/vmlinuz/vmlinux} || mv ${2} ${2/vmlinuz/vmlinux}

ln -sfr $(dirname ${2/vmlinuz/vmlinux})/* /boot
for fn in $(find $(dirname ${2}) -type f); do ln -sfr ${fn} /boot/$(sed 's/.*\/\([a-zA-Z\.]*\)-.*/\1/' <<< ${fn}); done

fn=mkefimenu
if [[ -f /usr/local/sbin/${fn} ]]; then
	/usr/local/sbin/${fn} -c -k ${1}
  echo -e "${BOLD}${fn}${RESET}: [ ${GREEN}info${RESET} ]: done"
else
  echo -e "${BOLD}${fn}${RESET}: [ ${BROWN}${BOLD}warn${RESET} ]: not found" >&2
fi

exit 0
