Browse Source

Handle fail2ban logging

Bob Mottram 8 years ago
parent
commit
c62e88f29f
1 changed files with 11 additions and 0 deletions
  1. 11
    0
      src/freedombone-logging

+ 11
- 0
src/freedombone-logging View File

@@ -40,6 +40,10 @@ if [ ! "$1" ]; then
40 40
 fi
41 41
 
42 42
 if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
43
+    if [ -f /etc/fail2ban/fail2ban.conf ]; then
44
+        sed -i 's|loglevel.*|loglevel = 3|g' /etc/fail2ban/fail2ban.conf
45
+        sed -i 's|logtarget.*|logtarget = /var/log/fail2ban.log|g' /etc/fail2ban/fail2ban.conf
46
+    fi
43 47
     if [ -d /etc/tor ]; then
44 48
         sed -i 's|#Log notice file.*|Log notice file /var/log/tor.log|g' /etc/tor/torrc
45 49
         sed -i 's|Log notice file.*|Log notice file /var/log/tor.log|g' /etc/tor/torrc
@@ -149,6 +153,10 @@ else
149 153
         fi
150 154
         sed -i 's|log_error =.*|log_error = /dev/null|g' /etc/mysql/my.cnf
151 155
     fi
156
+    if [ -f /etc/fail2ban/fail2ban.conf ]; then
157
+        sed -i 's|loglevel.*|loglevel = 1|g' /etc/fail2ban/fail2ban.conf
158
+        sed -i 's|logtarget.*|logtarget = /dev/null|g' /etc/fail2ban/fail2ban.conf
159
+    fi
152 160
 fi
153 161
 
154 162
 if [ -d /etc/nginx ]; then
@@ -176,5 +184,8 @@ fi
176 184
 if [ -d /var/www/radicale ]; then
177 185
     systemctl restart radicale
178 186
 fi
187
+if [ -d /etc/fail2ban ]; then
188
+    systemctl restart fail2ban
189
+fi
179 190
 
180 191
 exit 0