From 314aa6738ed6ec7c7dcccf65b44d39bb2b2eb268 Mon Sep 17 00:00:00 2001 From: jjorstad2 Date: Sun, 2 Nov 2025 22:03:05 +0000 Subject: [PATCH] Update install_perccli.sh --- install_perccli.sh | 55 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/install_perccli.sh b/install_perccli.sh index 119d3f9..f6e0cf9 100644 --- a/install_perccli.sh +++ b/install_perccli.sh @@ -10,7 +10,7 @@ PERCCLI_URL="https://dl.dell.com/FOLDER13074167M/1/PERCCLI_7.3208.0_Linux_A01.ta ARCHIVE_NAME="PERCCLI_7.3208.0_Linux_A01.tar.gz" TEMP_DIR="perccli_install_temp" # Default path for the executable, will be updated dynamically if necessary -EXECUTABLE_PATH="/opt/MegaRAID/perccli/perccli" +EXECUTABLE_PATH="" SYMLINK_PATH="/usr/local/bin/perccli" echo "Starting PERCCLI installation script..." @@ -116,35 +116,56 @@ if [ $INSTALL_SUCCESS -eq 0 ]; then echo "" echo "5. Installation successful. Performing final setup and cleanup." - # NEW DYNAMIC PATH DISCOVERY: Try dpkg, then fall back to filesystem search for common binaries - ACTUAL_EXECUTABLE_PATH=$(dpkg -L perccli 2>/dev/null | grep "/perccli$" | head -n 1) + # --- ULTIMATE DYNAMIC PATH DISCOVERY --- + # Loop through all files installed by the 'perccli' package and stop at the first one that is executable. + + echo "Attempting to find the executable by checking all files installed by 'perccli'..." + + # Get the list of all files installed by the package + INSTALLED_FILES=$(dpkg -L perccli 2>/dev/null) + + # Iterate and find the executable file + for FILE_PATH in $INSTALLED_FILES; do + # Check if the path is a regular file and is executable + if [ -f "$FILE_PATH" ] && [ -x "$FILE_PATH" ]; then + EXECUTABLE_PATH="$FILE_PATH" + break + fi + done + + # Fallback: If no executable file was found, find the largest file that might be the binary + if [ -z "$EXECUTABLE_PATH" ]; then + echo "WARNING: No executable file found in the package list. Re-checking for common binaries and applying permissions if necessary..." + + # Aggressive search for non-executable files that are likely the binary + # We search in common places for files that look like binaries and are NOT directories. + POTENTIAL_BINARY=$(find /opt /usr/local/sbin /usr/sbin /usr/bin -type f \( -name perccli -o -name storcli -o -name MegaCli \) 2>/dev/null | head -n 1) - # If dpkg failed or found path is not a file, perform aggressive search for common names - if [ -z "$ACTUAL_EXECUTABLE_PATH" ] || [ ! -f "$ACTUAL_EXECUTABLE_PATH" ]; then - echo "WARNING: Expected binary 'perccli' not found. Performing aggressive search for 'storcli' or 'MegaCli'..." - # CRITICAL FIX: Search for the actual vendor executable names in common directories - ACTUAL_EXECUTABLE_PATH=$(find /opt /usr/local/sbin /usr/sbin /usr/bin -name perccli -type f -o -name storcli -type f -o -name MegaCli -type f 2>/dev/null | head -n 1) + if [ -n "$POTENTIAL_BINARY" ]; then + EXECUTABLE_PATH="$POTENTIAL_BINARY" + # Since it wasn't executable before, we assume it needs permission + echo "Found non-executable potential binary: $EXECUTABLE_PATH. Applying execute permissions." + chmod +x "$EXECUTABLE_PATH" + fi fi + # --- END ULTIMATE DYNAMIC PATH DISCOVERY --- + # Finalize path or fail - if [ -n "$ACTUAL_EXECUTABLE_PATH" ] && [ -f "$ACTUAL_EXECUTABLE_PATH" ]; then - EXECUTABLE_PATH="$ACTUAL_EXECUTABLE_PATH" + if [ -n "$EXECUTABLE_PATH" ] && [ -f "$EXECUTABLE_PATH" ]; then echo "Dynamically found executable at: $EXECUTABLE_PATH" else - echo "FATAL ERROR: Could not locate *any* related binary (perccli, storcli, or MegaCli) after successful package setup." - echo "Please manually run: find / -name '*cli' -type f" - INSTALL_SUCCESS=1 # Set installation to fail state to skip chmod/symlink + echo "FATAL ERROR: Could not locate *any* related binary after checking all installed files." + echo "The package installation is likely broken due to the RPM conversion process." + INSTALL_SUCCESS=1 # Set installation to fail state to skip cleanup/symlink fi # Proceed with cleanup and symlinking only if the executable was found if [ $INSTALL_SUCCESS -eq 0 ]; then - # CRITICAL FIX: Ensure the executable has permissions (Fixes 'Permission denied') - chmod +x "$EXECUTABLE_PATH" - echo "Applied execute permission to $EXECUTABLE_PATH." # Add symbolic link to the path (Fixes 'command not found') - # Symlink is always named 'perccli' but points to the actual binary (perccli, storcli, or MegaCli) + # Symlink is always named 'perccli' but points to the actual binary if [ ! -L "$SYMLINK_PATH" ] || [ -L "$SYMLINK_PATH" ] && [ "$(readlink -f "$SYMLINK_PATH")" != "$EXECUTABLE_PATH" ]; then ln -sf "$EXECUTABLE_PATH" "$SYMLINK_PATH" echo "Created symbolic link at $SYMLINK_PATH pointing to $EXECUTABLE_PATH."