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")