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
echo "=== Service Status ===" 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 case $DISTRO in
opensuse) 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 esac
fi
# Always check docker if installed # Docker
if [[ "${INSTALL_DOCKER:-false}" == "true" ]]; then if [[ "${INSTALL_DOCKER:-false}" == "true" ]]; then
services_to_check="$services_to_check docker" services_to_check+=("docker")
fi fi
# Check netdata if installed # Netdata
if [[ "${INSTALL_NETDATA:-false}" == "true" ]]; then if [[ "${INSTALL_NETDATA:-false}" == "true" ]]; then
services_to_check="$services_to_check netdata" services_to_check+=("netdata")
fi 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 if systemctl is-active --quiet "$service" 2>/dev/null; then
echo "$service: Active" echo "$service: Active"
else else
@@ -334,11 +339,16 @@ perform_health_check() {
echo echo
echo "=== Security Status ===" 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 if systemctl is-active --quiet fail2ban; then
echo "✅ Fail2ban: Active" echo "✅ Fail2ban: Active"
else else
echo "❌ Fail2ban: Inactive" echo "❌ Fail2ban: Inactive"
fi fi
else
echo " Fail2ban: Not configured"
fi
echo echo
echo "=== Docker Status ===" echo "=== Docker Status ==="