public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Helper] Add script to reset all learns in Rspamd
681a51b3
helper-scripts/reset-learns.sh | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100755 helper-scripts/reset-learns.sh
Diff
diff --git a/helper-scripts/reset-learns.sh b/helper-scripts/reset-learns.sh
new file mode 100755
index 00000000..647c0e85
--- /dev/null
+++ b/helper-scripts/reset-learns.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+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"
+ docker exec -it ${REDIS_ID} redis-cli EVAL "for _,k in ipairs(redis.call('keys', ARGV[1])) do redis.call('del', k) end" 0 'RS*'
+ echo "Deleting all BAYES* keys - if any"
+ docker exec -it ${REDIS_ID} redis-cli EVAL "for _,k in ipairs(redis.call('keys', ARGV[1])) do redis.call('del', k) end" 0 'BAYES*'
+ echo "Deleting all learned* keys - if any"
+ docker exec -it ${REDIS_ID} redis-cli EVAL "for _,k in ipairs(redis.call('keys', ARGV[1])) do redis.call('del', k) end" 0 'learned*'
+ echo "Deleting all fuzzy* keys - if any"
+ docker exec -it ${REDIS_ID} redis-cli EVAL "for _,k in ipairs(redis.call('keys', ARGV[1])) do redis.call('del', k) end" 0 'fuzzy*'
+ echo "Deleting all tRFANN* keys - if any"
+ docker exec -it ${REDIS_ID} redis-cli EVAL "for _,k in ipairs(redis.call('keys', ARGV[1])) do redis.call('del', k) end" 0 'tRFANN*'
+ echo "Starting Rspamd container"
+ docker start ${RSPAMD_ID}
+ fi
+fi