Unverified Commit f0f23a40 authored by Robin Obůrka's avatar Robin Obůrka
Browse files

Delete some old mess

parent e9c539a4
......@@ -25,8 +25,5 @@ DATE=$(date -d "$CLEAN_DAYS days ago" "+'%Y-%m-%d'")
echo "DELETE FROM router_registrationcode WHERE date < $DATE;"
echo "DELETE FROM biflows WHERE COALESCE(start_in, start_out) < $DATE;"
echo "DELETE FROM ssh_sessions WHERE start_time < $DATE;"
echo "LOCK TABLE fake_blacklist_cache IN SHARE MODE;" # We don't want to conflict with any other updates running
echo "DELETE FROM fake_blacklist_cache;"
echo "INSERT INTO fake_blacklist_cache (server, remote, client, score, timestamp) SELECT server, remote, client, score, timestamp FROM fake_blacklist_cache_fill;"
echo 'COMMIT;'
) | psql -U "$DBCLEANER" -d "$DB" $DBPARAMS
#!/bin/sh
set -e
. ./dbconfig
LOCK_DIR=/tmp/refresh_blacklist_cache.lock
if ! mkdir "$LOCK_DIR" ; then
echo "Already running?" 2>&1
exit 1
fi
trap 'rm -rf "$LOCK_DIR"' EXIT INT QUIT TERM ABRT
(
echo "BEGIN;"
echo "LOCK TABLE fake_blacklist_cache IN SHARE MODE;" # We don't want to conflict with any other updates running
echo "DELETE FROM fake_blacklist_cache;"
echo "INSERT INTO fake_blacklist_cache (server, remote, client, score, timestamp) SELECT server, remote, client, score, timestamp FROM fake_blacklist_cache_fill;"
echo 'COMMIT;'
) | psql -U "$DBFLOWTAGGER" -d "$DB" $DBPARAMS
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment