Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker commands to check if Fail2ban or CrowdSec containers are running #24

Merged
merged 3 commits into from
Feb 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check if docker is running before check containers running Fail2ban o…
…r CrowdSec
alvarosaavedrau committed Jan 13, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 4acd58cdf17607678f2be251e5343a1505c05aa0
24 changes: 18 additions & 6 deletions vps-audit.sh
Original file line number Diff line number Diff line change
@@ -214,9 +214,15 @@ if dpkg -l | grep -q "fail2ban"; then
fi

# Check docker container running fail2ban
if docker ps -a | awk '{print $2}' | grep "fail2ban"; then
IPS_INSTALLED=1
docker ps | grep -q "fail2ban" && IPS_ACTIVE=1
if command -v docker >/dev/null 2>&1; then
if systemctl is-active --quiet docker; then
if docker ps -a | awk '{print $2}' | grep "fail2ban" >/dev/null 2>&1; then
IPS_INSTALLED=1
docker ps | grep -q "fail2ban" && IPS_ACTIVE=1
fi
else
check_security "Intrusion Prevention" "WARN" "Docker is instaleld but not running - cannot check for Fail2ban containers"
fi
fi

if dpkg -l | grep -q "crowdsec"; then
@@ -225,9 +231,15 @@ if dpkg -l | grep -q "crowdsec"; then
fi

# Check docker container running crowdsec
if docker ps -a | awk '{print $2}' | grep "crowdsec"; then
IPS_INSTALLED=1
docker ps | grep -q "crowdsec" && IPS_ACTIVE=1
if command -v docker >/dev/null 2>&1; then
if systemctl is-active --quiet docker; then
if docker ps -a | awk '{print $2}' | grep "crowdsec" >/dev/null 2>&1; then
IPS_INSTALLED=1
docker ps | grep -q "crowdsec" && IPS_ACTIVE=1
fi
else
check_security "Intrusion Prevention" "WARN" "Docker is instaleld but not running - cannot check for CrowdSec containers"
fi
fi

case "$IPS_INSTALLED$IPS_ACTIVE" in