linux-tools/modules/fail2ban/__init__.py

21 lines
562 B
Python
Raw Normal View History

2020-08-01 00:32:41 +02:00
import subprocess
from shutil import copyfile
def run():
subprocess.call("apt install fail2ban -y", shell=True)
try:
ufw_is_installed = subprocess.check_output("which ufw", shell=True).decode().strip()
print(f"ufw is already installed in {ufw_is_installed}")
except subprocess.CalledProcessError:
subprocess.call("sudo apt install ufw -y", shell=True)
subprocess.call("ufw allow ssh && ufw enable", shell=True)
copyfile("./modules/fail2ban/jail.local", "/etc/fail2ban/jail.local")
functions = {
"run": run
}