IMPROVEMENT: Enhanced installation verification and error visibility
Improves package manager installation logging and error reporting in install_clamav_only() and install_rkhunter_only() functions. Changes: 1. Capture full installation output to temporary log files 2. Explicitly check package manager exit codes 3. Display full output on success (tail -5/-3) 4. Display extended output on failure (tail -10) with warning 5. Clean up temporary log files after use Benefits: - Users can see installation output and diagnose failures - Non-zero exit codes from package managers are visible - Installation logs preserved for debugging if needed - More transparent error handling for yum/apt-get operations Example: Before: yum install -y clamav 2>&1 | tail -5 (exit code hidden) After: Check exit code, show appropriate output on success/failure Status: ✓ Syntax validated, improved error visibility
This commit is contained in:
@@ -524,11 +524,25 @@ install_clamav_only() {
|
||||
|
||||
if command -v yum &>/dev/null; then
|
||||
echo "Using yum package manager..."
|
||||
yum install -y clamav clamav-daemon clamav-update 2>&1 | tail -5
|
||||
local install_log="/tmp/clamav-install-$$.log"
|
||||
if yum install -y clamav clamav-daemon clamav-update > "$install_log" 2>&1; then
|
||||
tail -5 "$install_log"
|
||||
else
|
||||
echo -e "${YELLOW}Installation returned non-zero exit code${NC}"
|
||||
tail -10 "$install_log"
|
||||
fi
|
||||
rm -f "$install_log"
|
||||
elif command -v apt-get &>/dev/null; then
|
||||
echo "Using apt package manager..."
|
||||
apt-get update > /dev/null 2>&1
|
||||
apt-get install -y clamav clamav-daemon 2>&1 | tail -5
|
||||
local install_log="/tmp/clamav-install-$$.log"
|
||||
if apt-get install -y clamav clamav-daemon > "$install_log" 2>&1; then
|
||||
tail -5 "$install_log"
|
||||
else
|
||||
echo -e "${YELLOW}Installation returned non-zero exit code${NC}"
|
||||
tail -10 "$install_log"
|
||||
fi
|
||||
rm -f "$install_log"
|
||||
else
|
||||
echo -e "${RED}✗ No compatible package manager found${NC}"
|
||||
echo ""
|
||||
@@ -576,11 +590,25 @@ install_rkhunter_only() {
|
||||
if command -v yum &>/dev/null; then
|
||||
echo "Using yum package manager..."
|
||||
yum install -y epel-release 2>&1 > /dev/null || true
|
||||
yum install -y rkhunter 2>&1 | tail -3
|
||||
local install_log="/tmp/rkhunter-install-$$.log"
|
||||
if yum install -y rkhunter > "$install_log" 2>&1; then
|
||||
tail -3 "$install_log"
|
||||
else
|
||||
echo -e "${YELLOW}Installation returned non-zero exit code${NC}"
|
||||
tail -10 "$install_log"
|
||||
fi
|
||||
rm -f "$install_log"
|
||||
elif command -v apt-get &>/dev/null; then
|
||||
echo "Using apt package manager..."
|
||||
apt-get update > /dev/null 2>&1
|
||||
apt-get install -y rkhunter 2>&1 | tail -3
|
||||
local install_log="/tmp/rkhunter-install-$$.log"
|
||||
if apt-get install -y rkhunter > "$install_log" 2>&1; then
|
||||
tail -3 "$install_log"
|
||||
else
|
||||
echo -e "${YELLOW}Installation returned non-zero exit code${NC}"
|
||||
tail -10 "$install_log"
|
||||
fi
|
||||
rm -f "$install_log"
|
||||
else
|
||||
echo -e "${RED}✗ No compatible package manager found${NC}"
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user