2019-05-10 15:41:24 +02:00
|
|
|
#!/usr/bin/env bash
|
2018-07-29 23:02:34 +02:00
|
|
|
|
|
|
|
read -r -p "Are you sure you want to reset learned hashes from Rspamd (fuzzy, bayes, neural)? [y/N] " response
|
|
|
|
response=${response,,} # tolower
|
|
|
|
if [[ "$response" =~ ^(yes|y)$ ]]; then
|
|
|
|
echo "Working, please wait..."
|
|
|
|
REDIS_ID=$(docker ps -qf name=redis-mailcow)
|
|
|
|
RSPAMD_ID=$(docker ps -qf name=rspamd-mailcow)
|
|
|
|
|
|
|
|
if [ -z ${REDIS_ID} ] || [ -z ${RSPAMD_ID} ]; then
|
|
|
|
echo "Cannot determine Redis or Rspamd container ID"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Stopping Rspamd container"
|
|
|
|
docker stop ${RSPAMD_ID}
|
|
|
|
echo "LUA will return nil when it succeeds or print a warning/error when it fails."
|
|
|
|
echo "Deleting all RS* keys - if any"
|
2024-11-19 16:10:52 +02:00
|
|
|
docker exec -it ${REDIS_ID} redis-cli -a ${REDISPASS} --no-auth-warning EVAL "for _,k in ipairs(redis.call('keys', ARGV[1])) do redis.call('del', k) end" 0 'RS*'
|
2018-07-29 23:02:34 +02:00
|
|
|
echo "Deleting all BAYES* keys - if any"
|
2024-11-19 16:10:52 +02:00
|
|
|
docker exec -it ${REDIS_ID} redis-cli -a ${REDISPASS} --no-auth-warning EVAL "for _,k in ipairs(redis.call('keys', ARGV[1])) do redis.call('del', k) end" 0 'BAYES*'
|
2018-07-29 23:02:34 +02:00
|
|
|
echo "Deleting all learned* keys - if any"
|
2024-11-19 16:10:52 +02:00
|
|
|
docker exec -it ${REDIS_ID} redis-cli -a ${REDISPASS} --no-auth-warning EVAL "for _,k in ipairs(redis.call('keys', ARGV[1])) do redis.call('del', k) end" 0 'learned*'
|
2018-07-29 23:02:34 +02:00
|
|
|
echo "Deleting all fuzzy* keys - if any"
|
2024-11-19 16:10:52 +02:00
|
|
|
docker exec -it ${REDIS_ID} redis-cli -a ${REDISPASS} --no-auth-warning EVAL "for _,k in ipairs(redis.call('keys', ARGV[1])) do redis.call('del', k) end" 0 'fuzzy*'
|
2018-07-29 23:02:34 +02:00
|
|
|
echo "Deleting all tRFANN* keys - if any"
|
2024-11-19 16:10:52 +02:00
|
|
|
docker exec -it ${REDIS_ID} redis-cli -a ${REDISPASS} --no-auth-warning EVAL "for _,k in ipairs(redis.call('keys', ARGV[1])) do redis.call('del', k) end" 0 'tRFANN*'
|
2018-07-29 23:02:34 +02:00
|
|
|
echo "Starting Rspamd container"
|
|
|
|
docker start ${RSPAMD_ID}
|
|
|
|
fi
|
|
|
|
fi
|