Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # A script to automate the download and installation of rEFInd on Linux.
- # This script must be run with sudo or as root.
- #
- # MODIFICATION 2: Corrected the flag for specifying the EFI partition.
- # The correct flag is "--usedefault {device}" not "--device {device}".
- # --- Configuration ---
- REFIND_VERSION="0.14.2"
- DOWNLOAD_URL="https://sourceforge.net/projects/refind/files/${REFIND_VERSION}/refind-bin-${REFIND_VERSION}.zip/download"
- TEMP_DIR="/tmp/refind-install-$$"
- EFI_DEVICE="/dev/sda1" # Your confirmed EFI partition
- # --- Functions ---
- # Function to check for root privileges
- check_root() {
- if [ "$EUID" -ne 0 ]; then
- echo "Error: This script must be run as root. Please use sudo."
- exit 1
- fi
- }
- # Function to check for UEFI boot mode
- check_uefi() {
- if [ ! -d "/sys/firmware/efi" ]; then
- echo "Error: System not booted in UEFI mode. rEFInd requires UEFI."
- exit 1
- fi
- }
- # Function for cleanup
- cleanup() {
- echo "Cleaning up temporary files..."
- rm -rf "$TEMP_DIR"
- }
- # --- Main Script Logic ---
- # Ensure script exits if any command fails
- set -e
- # Trap CTRL+C and other signals for cleanup
- trap cleanup EXIT
- # 1. Initial Checks
- check_root
- check_uefi
- echo "rEFInd Installer for Linux (Acer Specific - Corrected)"
- echo "----------------------------------------------------"
- echo "Targeting EFI Partition: $EFI_DEVICE"
- # 2. Check/Install Dependencies
- if ! command -v curl &> /dev/null || ! command -v unzip &> /dev/null; then
- echo "curl and/or unzip not found. Attempting to install..."
- if command -v apt-get &> /dev/null; then
- apt-get update
- apt-get install -y curl unzip
- else
- echo "Error: Cannot automatically install dependencies. Please install curl and unzip manually."
- exit 1
- fi
- fi
- # 3. Download and Extract rEFInd
- mkdir -p "$TEMP_DIR"
- cd "$TEMP_DIR"
- echo "Downloading rEFInd version $REFIND_VERSION..."
- curl -L -o refind.zip "$DOWNLOAD_URL"
- echo "Extracting archive..."
- unzip -q refind.zip
- # Find the extracted directory name
- EXTRACTED_DIR=$(ls -d refind-bin-*/)
- # 4. Run the official rEFInd installation script
- cd "$EXTRACTED_DIR"
- echo "Running the official refind-install script on $EFI_DEVICE..."
- # THIS IS THE CORRECTED COMMAND:
- ./refind-install --usedefault $EFI_DEVICE
- if [ $? -eq 0 ]; then
- echo ""
- echo -e "\e[32m rEFInd has been installed successfully! \e[0m"
- echo "On next boot, rEFInd should appear as the default boot manager."
- else
- echo ""
- echo -e "\e[31m The refind-install script reported an error. \e[0m"
- fi
- # Cleanup is handled by the trap at the beginning
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment