-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_fail2ban.sh
26 lines (20 loc) · 1013 Bytes
/
init_fail2ban.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
grep "FAIL2BAN_INSTALLED" ${rcfile} 1>/dev/null
if [[ $? -eq 1 ]]; then
print_yellow "To get help, consult: https://www.linode.com/docs/guides/using-fail2ban-to-secure-your-server-a-tutorial/"
dnf install -y epel-release > /dev/null 2>&1
print_green "[dnf] installed epel-release"
dnf install -y fail2ban > /dev/null 2>&1
print_green "[dnf] installed fail2ban"
systemctl enable --now fail2ban > /dev/null 2>&1
print_green "[systemctl] enabled and started fail2ban"
print_green "[script] Beginning Fail2Ban Configuration"
cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
print_green "[script] Copyied fail2ban config"
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
print_green "[script] Copyied fail2ban jail config"
sed -i 's/backend = auto/backend = systemd/g' /etc/fail2ban/jail.local
print_green "[sed] Changed backend from auto to systemd in /etc/fail2ban/jail.local"
print_green "[script] executed successfully"
echo "FAIL2BAN_INSTALLED" >> ${rcfile}
fi