linux-tools/modules/fail2ban/__init__.py

23 lines
605 B
Python
Raw Normal View History

2020-08-01 00:32:41 +02:00
import subprocess
from shutil import copyfile
2020-08-02 13:58:47 +02:00
from print_helpers import print_bold
2020-08-01 00:32:41 +02:00
def run():
subprocess.call("apt install fail2ban -y", shell=True)
try:
ufw_is_installed = subprocess.check_output("which ufw", shell=True).decode().strip()
2020-08-02 13:58:47 +02:00
print_bold(f"ufw is already installed in {ufw_is_installed}")
2020-08-01 00:32:41 +02:00
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
}