add fail2ban scripts

This commit is contained in:
Kovasky Buezo
2024-03-21 14:48:17 -04:00
parent cec0093439
commit cfba8ee2b8
3 changed files with 11 additions and 4 deletions

20
fail2ban/action.d/entryPoint.py Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/python3
"""
Creates a virtual environment, installs dependencies, and then calls modifyBanList.py
"""
import os
import sys
if len(sys.argv) < 3:
print("Usage: ./entryPoint.py <ip> <add|del>")
sys.exit(1)
venv_dir = 'env'
if not os.path.exists(venv_dir):
os.system(f"{sys.executable} -m venv {venv_dir}")
os.system(f"{os.path.join(venv_dir, 'bin', 'pip')} install --upgrade requests ipaddress")
os.system(f"{os.path.join(venv_dir, 'bin', 'python')} /data/action.d/modifyBanList.py {sys.argv[1]} {sys.argv[2]}")