#!/usr/bin/env bash

if [[ $EUID -ne 0 ]]; then
	echo -e "\033[91m limine-scan must be run with root privileges.\033[0m" >&2
	exit 1
fi

# Check if limine-entry-tool exists
if ! command -v limine-entry-tool &>/dev/null; then
	echo -e "ERROR: limine-entry-tool not found." >&2
	exit 1
fi

# Run tools
limine-entry-tool --scan
exit_code="$?"
if [[ $exit_code -ne 0 ]]; then
	exit "$exit_code"
fi
# enroll config
if command -v limine-enroll-config &>/dev/null; then
	limine-enroll-config
fi
