Update install_perccli.sh
This commit is contained in:
parent
98e109c21d
commit
8e51780d1d
|
|
@ -1,23 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ------------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------------------------
|
||||||
# Script to download, extract, and install the Dell PERCCLI utility on a Linux system.
|
# Script to download, extract, convert, and install the Dell PERCCLI utility.
|
||||||
# Note: This script requires 'wget' and 'tar'. It assumes execution as 'root' (no 'sudo' needed).
|
# Optimized for Debian-based systems (like Proxmox) that need to convert the RPM package.
|
||||||
|
# Note: This script assumes execution as 'root' (no 'sudo' needed).
|
||||||
# ------------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# --- Configuration ---
|
# --- Configuration ---
|
||||||
PERCCLI_URL="https://dl.dell.com/FOLDER13074167M/1/PERCCLI_7.3208.0_Linux_A01.tar.gz"
|
PERCCLI_URL="https://dl.dell.com/FOLDER13074167M/1/PERCCLI_7.3208.0_Linux_A01.tar.gz"
|
||||||
ARCHIVE_NAME="PERCCLI_7.3208.0_Linux_A01.tar.gz"
|
ARCHIVE_NAME="PERCCLI_7.3208.0_Linux_A01.tar.gz"
|
||||||
TEMP_DIR="perccli_install_temp"
|
TEMP_DIR="perccli_install_temp"
|
||||||
|
EXECUTABLE_PATH="/opt/MegaRAID/perccli/perccli"
|
||||||
|
SYMLINK_PATH="/usr/local/bin/perccli"
|
||||||
|
|
||||||
echo "Starting PERCCLI installation script..."
|
echo "Starting PERCCLI installation script..."
|
||||||
echo "Target URL: $PERCCLI_URL"
|
echo "Target URL: $PERCCLI_URL"
|
||||||
|
|
||||||
# 1. Download the archive
|
# 1. Download the archive
|
||||||
echo "1. Downloading $ARCHIVE_NAME..."
|
echo "1. Downloading $ARCHIVE_NAME..."
|
||||||
# Using wget to download the file, adding a User-Agent to prevent 403 errors on some servers
|
# Using wget with User-Agent to prevent 403 errors
|
||||||
wget --no-check-certificate --user-agent="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1)" "$PERCCLI_URL" -O "$ARCHIVE_NAME"
|
wget --no-check-certificate --user-agent="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1)" "$PERCCLI_URL" -O "$ARCHIVE_NAME"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "ERROR: Failed to download the file. Check your network connection and ensure 'wget' is installed, or try a different User-Agent."
|
echo "ERROR: Failed to download the file. Check your network connection and ensure 'wget' is installed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Download complete."
|
echo "Download complete."
|
||||||
|
|
@ -25,7 +28,6 @@ echo "Download complete."
|
||||||
# 2. Extract the archive
|
# 2. Extract the archive
|
||||||
echo "2. Extracting the archive..."
|
echo "2. Extracting the archive..."
|
||||||
mkdir -p "$TEMP_DIR"
|
mkdir -p "$TEMP_DIR"
|
||||||
# Extracting the tar.gz file into the temporary directory
|
|
||||||
tar -xzf "$ARCHIVE_NAME" -C "$TEMP_DIR"
|
tar -xzf "$ARCHIVE_NAME" -C "$TEMP_DIR"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "ERROR: Failed to extract the archive. The file may be incomplete or corrupted."
|
echo "ERROR: Failed to extract the archive. The file may be incomplete or corrupted."
|
||||||
|
|
@ -34,9 +36,8 @@ if [ $? -ne 0 ]; then
|
||||||
fi
|
fi
|
||||||
echo "Extraction complete to $TEMP_DIR."
|
echo "Extraction complete to $TEMP_DIR."
|
||||||
|
|
||||||
# 3. Locate the installation package
|
# 3. Locate the installation package (Prioritizing RPM since the official package is RPM)
|
||||||
# Prioritizing .deb files, but since the previous run found an .rpm, the script is prepared to convert it.
|
PACKAGE_FILE=$(find "$TEMP_DIR" -type f \( -name "*.rpm" -o -name "*.deb" \) | head -n 1)
|
||||||
PACKAGE_FILE=$(find "$TEMP_DIR" -type f \( -name "*.deb" -o -name "*.rpm" \) | head -n 1)
|
|
||||||
|
|
||||||
if [ -z "$PACKAGE_FILE" ]; then
|
if [ -z "$PACKAGE_FILE" ]; then
|
||||||
echo "ERROR: Could not find any .deb or .rpm installation package within the archive."
|
echo "ERROR: Could not find any .deb or .rpm installation package within the archive."
|
||||||
|
|
@ -46,10 +47,10 @@ fi
|
||||||
|
|
||||||
echo "3. Found package file: $PACKAGE_FILE"
|
echo "3. Found package file: $PACKAGE_FILE"
|
||||||
|
|
||||||
# 4. Install the package using the appropriate command (no 'sudo' needed as running as root)
|
# 4. Install the package
|
||||||
echo "4. Attempting to install the package."
|
echo "4. Attempting to install the package."
|
||||||
|
|
||||||
INSTALL_SUCCESS=0
|
INSTALL_SUCCESS=1 # Default to failure
|
||||||
|
|
||||||
if [[ "$PACKAGE_FILE" == *.deb ]]; then
|
if [[ "$PACKAGE_FILE" == *.deb ]]; then
|
||||||
echo "Detected native DEB package. Trying to install with 'dpkg -i'..."
|
echo "Detected native DEB package. Trying to install with 'dpkg -i'..."
|
||||||
|
|
@ -57,65 +58,72 @@ if [[ "$PACKAGE_FILE" == *.deb ]]; then
|
||||||
dpkg -i "$PACKAGE_FILE"
|
dpkg -i "$PACKAGE_FILE"
|
||||||
INSTALL_SUCCESS=$?
|
INSTALL_SUCCESS=$?
|
||||||
else
|
else
|
||||||
echo "ERROR: 'dpkg' command not found. Please ensure the Debian package manager is available."
|
echo "ERROR: 'dpkg' command not found. Cannot proceed."
|
||||||
INSTALL_SUCCESS=1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [[ "$PACKAGE_FILE" == *.rpm ]]; then
|
elif [[ "$PACKAGE_FILE" == *.rpm ]]; then
|
||||||
echo "Detected RPM package. This system appears to be Debian-based (Proxmox), so we will attempt to use 'alien' to convert it to a DEB package for installation."
|
echo "Detected RPM package. As this is a Debian-based system (Proxmox), we will use 'alien' to convert it to a DEB package."
|
||||||
|
|
||||||
if command -v dpkg >/dev/null 2>&1; then
|
if command -v dpkg >/dev/null 2>&1; then
|
||||||
if command -v alien >/dev/null 2>&1; then
|
if command -v alien >/dev/null 2>&1; then
|
||||||
echo "Attempting to convert $PACKAGE_FILE to .deb using 'alien'..."
|
echo "Attempting to convert $PACKAGE_FILE to .deb using 'alien --scripts' to ensure post-install setup runs..."
|
||||||
# Convert the RPM to DEB. The resulting .deb file will be created in the current directory.
|
# CRITICAL FIX: Use --scripts to prevent skipping post-installation setup
|
||||||
alien -d "$PACKAGE_FILE"
|
alien -d --scripts "$PACKAGE_FILE"
|
||||||
|
|
||||||
# Check the return code of the alien conversion
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Conversion successful. Searching for generated .deb file..."
|
echo "Conversion successful. Searching for generated .deb file..."
|
||||||
# FIX: Alien renames files, typically changing hyphens to underscores.
|
|
||||||
# Isolate the base package name (e.g., 'perccli' from the full name).
|
|
||||||
PACKAGE_NAME_ROOT=$(basename "$PACKAGE_FILE" | cut -d'-' -f1)
|
|
||||||
|
|
||||||
# Search for any .deb file in the current directory starting with the package name root and an underscore.
|
# Robustly search for the .deb file generated by alien
|
||||||
|
PACKAGE_NAME_ROOT=$(basename "$PACKAGE_FILE" | cut -d'-' -f1)
|
||||||
NEW_DEB_FILE=$(find . -maxdepth 1 -name "${PACKAGE_NAME_ROOT}_*.deb" | head -n 1)
|
NEW_DEB_FILE=$(find . -maxdepth 1 -name "${PACKAGE_NAME_ROOT}_*.deb" | head -n 1)
|
||||||
|
|
||||||
if [ -f "$NEW_DEB_FILE" ]; then
|
if [ -f "$NEW_DEB_FILE" ]; then
|
||||||
echo "Found converted file: $NEW_DEB_FILE. Installing..."
|
echo "Found converted file: $NEW_DEB_FILE. Installing..."
|
||||||
|
# Using dpkg -i to install the generated package
|
||||||
dpkg -i "$NEW_DEB_FILE"
|
dpkg -i "$NEW_DEB_FILE"
|
||||||
INSTALL_SUCCESS=$?
|
INSTALL_SUCCESS=$?
|
||||||
# Clean up the converted .deb file regardless of final install success
|
# Clean up the converted .deb file
|
||||||
rm -f "$NEW_DEB_FILE"
|
rm -f "$NEW_DEB_FILE"
|
||||||
else
|
else
|
||||||
echo "ERROR: Conversion succeeded, but could not locate the newly created .deb file for installation (Searched for: ${PACKAGE_NAME_ROOT}_*.deb)."
|
echo "ERROR: Conversion succeeded, but could not locate the newly created .deb file for installation."
|
||||||
INSTALL_SUCCESS=1
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "ERROR: 'alien' conversion failed. Please check the 'alien' output above for details."
|
echo "ERROR: 'alien' conversion failed. Please check the 'alien' output above for details."
|
||||||
INSTALL_SUCCESS=1
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "ERROR: 'alien' command not found. This tool is required to convert the RPM package for your system."
|
echo "ERROR: 'alien' command not found. This tool is required to convert the RPM package for your system."
|
||||||
echo "Please run: apt update && apt install alien -y"
|
echo "Please run: apt update && apt install alien -y"
|
||||||
INSTALL_SUCCESS=1
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "FATAL ERROR: 'dpkg' (Debian Package Manager) is not found. Cannot proceed with installation."
|
echo "FATAL ERROR: 'dpkg' (Debian Package Manager) is not found. Cannot proceed with installation."
|
||||||
INSTALL_SUCCESS=1
|
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "ERROR: Found file $PACKAGE_FILE is neither .deb nor .rpm. Manual installation is required."
|
|
||||||
INSTALL_SUCCESS=1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 5. Cleanup and Verification
|
# 5. Final Setup and Cleanup
|
||||||
# The cleanup step now correctly checks the INSTALL_SUCCESS status.
|
|
||||||
if [ $INSTALL_SUCCESS -eq 0 ]; then
|
if [ $INSTALL_SUCCESS -eq 0 ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "5. Installation successful. Cleaning up temporary files."
|
echo "5. Installation successful. Performing final setup and cleanup."
|
||||||
|
|
||||||
|
# CRITICAL FIX: Ensure the executable has permissions (Fixes 'Permission denied')
|
||||||
|
if [ -f "$EXECUTABLE_PATH" ]; then
|
||||||
|
chmod +x "$EXECUTABLE_PATH"
|
||||||
|
echo "Applied execute permission to $EXECUTABLE_PATH."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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 -f "$ARCHIVE_NAME"
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf "$TEMP_DIR"
|
||||||
echo "PERCCLI tool should now be available."
|
echo "PERCCLI tool is installed and configured. Cleaning up temporary files."
|
||||||
echo "Verify installation by running: perccli /c0 show"
|
|
||||||
|
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."
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue