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:
Developer
2026-04-21 22:08:16 -04:00
parent 622f100250
commit d8d7505c63
+32 -4
View File
@@ -524,11 +524,25 @@ install_clamav_only() {
if command -v yum &>/dev/null; then if command -v yum &>/dev/null; then
echo "Using yum package manager..." 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 elif command -v apt-get &>/dev/null; then
echo "Using apt package manager..." echo "Using apt package manager..."
apt-get update > /dev/null 2>&1 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 else
echo -e "${RED}✗ No compatible package manager found${NC}" echo -e "${RED}✗ No compatible package manager found${NC}"
echo "" echo ""
@@ -576,11 +590,25 @@ install_rkhunter_only() {
if command -v yum &>/dev/null; then if command -v yum &>/dev/null; then
echo "Using yum package manager..." echo "Using yum package manager..."
yum install -y epel-release 2>&1 > /dev/null || true 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 elif command -v apt-get &>/dev/null; then
echo "Using apt package manager..." echo "Using apt package manager..."
apt-get update > /dev/null 2>&1 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 else
echo -e "${RED}✗ No compatible package manager found${NC}" echo -e "${RED}✗ No compatible package manager found${NC}"
echo "" echo ""