forked from evolix/ansible-roles
fail2ban: SQLite purge script didn't vacuum as expected + error when vacuum cannot be done
This commit is contained in:
parent
fe66ad9c4f
commit
b30b7c884a
|
@ -24,6 +24,7 @@ The **patch** part is incremented if multiple releases happen the same month
|
||||||
* certbot: Fix HAProxy renewal hook
|
* certbot: Fix HAProxy renewal hook
|
||||||
* keepalived: Fix tasks that use file instead of copy
|
* keepalived: Fix tasks that use file instead of copy
|
||||||
* memcached: Fix conditions not properly writen (installation was always in multi-instance mode)
|
* memcached: Fix conditions not properly writen (installation was always in multi-instance mode)
|
||||||
|
* fail2ban: SQLite purge script didn't vacuum as expected + error when vacuum cannot be done
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,15 @@
|
||||||
# Juin - Decembre 2022 : #64088
|
# Juin - Decembre 2022 : #64088
|
||||||
# Purge pour Stretch et Buster
|
# Purge pour Stretch et Buster
|
||||||
|
|
||||||
/usr/bin/ionice -c3 /usr/bin/sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "DELETE FROM bans WHERE datetime('now', '-{{ fail2ban_dbpurgeage_default }}') > datetime(timeofban, 'unixepoch');"
|
/usr/bin/ionice -c3 /usr/bin/sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 ".timeout 5000; DELETE FROM bans WHERE datetime('now', '-{{ fail2ban_dbpurgeage_default }}') > datetime(timeofban, 'unixepoch');"
|
||||||
|
|
||||||
place_dispo=$( df -h /var/lib/fail2ban/fail2ban.sqlite3 --output="avail" -h --block-size=1 |tail -n1 )
|
place_dispo="$(df /var/lib/fail2ban/fail2ban.sqlite3 --output="avail" --block-size=1 | tail -n1)"
|
||||||
place_pris=$( echo $(("$(stat --format %s /var/lib/fail2ban/fail2ban.sqlite3 ) * 2" )) )
|
place_pris="$(stat --format %s /var/lib/fail2ban/fail2ban.sqlite3)"
|
||||||
|
|
||||||
if [ $place_pris -lt $place_dispo ]
|
if [ "$place_pris" -lt "$place_dispo" ]
|
||||||
then
|
then
|
||||||
/usr/bin/ionice -c3 /usr/bin/sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "VACUUM;"
|
/usr/bin/ionice -c3 /usr/bin/sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 "VACUUM;"
|
||||||
|
else
|
||||||
|
>&2 echo "Fail2ban SQLite VACUUM not done because /var lacks of space (VACUUM may use twice the database size)."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue