fix: Resolve shellcheck SC2155 warnings in health check script
Some checks failed
Test / test (push) Has been cancelled

Separate variable declaration and assignment to avoid masking return values.
This follows shellcheck best practices for error handling.

Changes:
- Separate declaration/assignment for container_name (line 59-60)
- Separate declaration/assignment for status (line 67-69)
- Separate declaration/assignment for health (line 68-70)
- Separate declaration/assignment for exit_code (line 86-87)

All 4 SC2155 warnings are now resolved.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Gui-Gos
2026-01-04 13:19:45 +01:00
parent 8cd871c61d
commit cfb4f7e6d0

View File

@@ -56,15 +56,18 @@ print_section() {
# Function to check service
check_service() {
local service=$1
local container_name=$(docker ps -a --format '{{.Names}}' | grep -E "${WAZUH_PREFIX}.*${service}" | head -1)
local container_name
container_name=$(docker ps -a --format '{{.Names}}' | grep -E "${WAZUH_PREFIX}.*${service}" | head -1)
if [ -z "$container_name" ]; then
echo -e "${RED}✗ Container not found${NC}"
return 1
fi
local status=$(docker inspect --format='{{.State.Status}}' "$container_name" 2>/dev/null)
local health=$(docker inspect --format='{{.State.Health.Status}}' "$container_name" 2>/dev/null || echo "no healthcheck")
local status
local health
status=$(docker inspect --format='{{.State.Status}}' "$container_name" 2>/dev/null)
health=$(docker inspect --format='{{.State.Health.Status}}' "$container_name" 2>/dev/null || echo "no healthcheck")
echo -ne " $service: "
@@ -80,7 +83,8 @@ check_service() {
return 1
fi
elif [ "$status" = "exited" ]; then
local exit_code=$(docker inspect --format='{{.State.ExitCode}}' "$container_name" 2>/dev/null)
local exit_code
exit_code=$(docker inspect --format='{{.State.ExitCode}}' "$container_name" 2>/dev/null)
if [ "$exit_code" = "0" ]; then
echo -e "${GREEN}✓ Exited successfully (code 0)${NC}"
return 0