Update install_perccli.sh

This commit is contained in:
jjorstad2 2025-11-02 21:58:04 +00:00
parent 33e58463d9
commit 9a4641b638
1 changed files with 37 additions and 25 deletions

View File

@ -116,39 +116,51 @@ if [ $INSTALL_SUCCESS -eq 0 ]; then
echo "" echo ""
echo "5. Installation successful. Performing final setup and cleanup." echo "5. Installation successful. Performing final setup and cleanup."
# NEW DYNAMIC PATH DISCOVERY: Find where dpkg actually put the executable # NEW DYNAMIC PATH DISCOVERY: Try dpkg, then fall back to filesystem search
ACTUAL_EXECUTABLE_PATH=$(dpkg -L perccli 2>/dev/null | grep "/perccli$" | head -n 1) ACTUAL_EXECUTABLE_PATH=$(dpkg -L perccli 2>/dev/null | grep "/perccli$" | head -n 1)
# If dpkg failed or found path is not a file, search common installation directories
if [ -z "$ACTUAL_EXECUTABLE_PATH" ] || [ ! -f "$ACTUAL_EXECUTABLE_PATH" ]; then
echo "WARNING: dpkg path discovery failed. Performing filesystem search for 'perccli'..."
# Search common paths: /opt, /usr/local/sbin, /usr/sbin, /usr/bin
ACTUAL_EXECUTABLE_PATH=$(find /opt /usr/local/sbin /usr/sbin /usr/bin -name perccli -type f 2>/dev/null | head -n 1)
fi
# Finalize path or fail
if [ -n "$ACTUAL_EXECUTABLE_PATH" ] && [ -f "$ACTUAL_EXECUTABLE_PATH" ]; then if [ -n "$ACTUAL_EXECUTABLE_PATH" ] && [ -f "$ACTUAL_EXECUTABLE_PATH" ]; then
EXECUTABLE_PATH="$ACTUAL_EXECUTABLE_PATH" EXECUTABLE_PATH="$ACTUAL_EXECUTABLE_PATH"
echo "Dynamically found executable at: $EXECUTABLE_PATH" echo "Dynamically found executable at: $EXECUTABLE_PATH"
else else
echo "WARNING: Could not reliably determine the installed executable path using dpkg. Assuming default: $EXECUTABLE_PATH" echo "FATAL ERROR: Could not locate 'perccli' binary after successful package setup."
echo "Please manually run: find / -name perccli -type f"
INSTALL_SUCCESS=1 # Set installation to fail state to skip chmod/symlink
fi fi
# CRITICAL FIX: Ensure the executable has permissions (Fixes 'Permission denied')
if [ -f "$EXECUTABLE_PATH" ]; then # 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" chmod +x "$EXECUTABLE_PATH"
echo "Applied execute permission to $EXECUTABLE_PATH." echo "Applied execute permission to $EXECUTABLE_PATH."
# Add symbolic link to the path (Fixes 'command not found')
if [ ! -L "$SYMLINK_PATH" ]; then
ln -s "$EXECUTABLE_PATH" "$SYMLINK_PATH"
echo "Created symbolic link at $SYMLINK_PATH."
fi
rm -f "$ARCHIVE_NAME"
rm -rf "$TEMP_DIR"
echo "PERCCLI tool is installed and configured. Cleaning up temporary files."
echo "---"
echo "Verification Command:"
echo "perccli /c0 show"
echo "---"
else else
echo "FATAL ERROR: Executable not found at $EXECUTABLE_PATH. Cannot apply permissions or create symlink." # If dynamic discovery failed, we skip cleanup and leave temporary files for debugging.
# Keep INSTALL_SUCCESS=0 if files are missing, just report the error and attempt cleanup echo "Installation failed due to missing files. Temporary files retained."
fi fi
# Add symbolic link to the path (Fixes 'command not found')
if [ ! -L "$SYMLINK_PATH" ] && [ -f "$EXECUTABLE_PATH" ]; then
ln -s "$EXECUTABLE_PATH" "$SYMLINK_PATH"
echo "Created symbolic link at $SYMLINK_PATH."
fi
rm -f "$ARCHIVE_NAME"
rm -rf "$TEMP_DIR"
echo "PERCCLI tool is installed and configured. Cleaning up temporary files."
echo "---"
echo "Verification Command:"
echo "perccli /c0 show"
echo "---"
else else
echo "" echo ""
echo "5. Installation failed. The archive '$ARCHIVE_NAME' and temporary directory '$TEMP_DIR' are retained for manual debugging." echo "5. Installation failed. The archive '$ARCHIVE_NAME' and temporary directory '$TEMP_DIR' are retained for manual debugging."