Fix Health Check to only check services that were actually installed/configured

This commit is contained in:
Mărcziem ™
2025-10-06 11:35:32 +02:00
parent 8b0f8b3e96
commit 55f69640ea

View File

@@ -292,27 +292,32 @@ perform_health_check() {
echo
echo "=== Service Status ==="
# Check services based on distribution
# Check services based on what was configured/installed
local services_to_check=("ssh" "sshd")
# Samba services
if [[ "${INSTALL_SAMBA:-true}" == "true" ]]; then
case $DISTRO in
opensuse)
services_to_check="sshd smb nmb fail2ban"
services_to_check+=("smb" "nmb")
;;
*)
services_to_check="ssh sshd smb nmb fail2ban"
services_to_check+=("smbd" "nmbd")
;;
esac
fi
# Always check docker if installed
# Docker
if [[ "${INSTALL_DOCKER:-false}" == "true" ]]; then
services_to_check="$services_to_check docker"
services_to_check+=("docker")
fi
# Check netdata if installed
# Netdata
if [[ "${INSTALL_NETDATA:-false}" == "true" ]]; then
services_to_check="$services_to_check netdata"
services_to_check+=("netdata")
fi
for service in $services_to_check; do
for service in "${services_to_check[@]}"; do
if systemctl is-active --quiet "$service" 2>/dev/null; then
echo "$service: Active"
else
@@ -334,11 +339,16 @@ perform_health_check() {
echo
echo "=== Security Status ==="
# Check Fail2ban if SSH was configured (which includes Fail2ban)
if [[ "${CONFIGURE_SSH:-true}" == "true" ]]; then
if systemctl is-active --quiet fail2ban; then
echo "✅ Fail2ban: Active"
else
echo "❌ Fail2ban: Inactive"
fi
else
echo " Fail2ban: Not configured"
fi
echo
echo "=== Docker Status ==="