about summary refs log tree commit homepage
path: root/scripts
diff options
authorEric Wong <e@80x24.org>2014-04-26 07:42:25 +0000
committerEric Wong <e@80x24.org>2014-04-26 07:42:25 +0000
commit095880dfd8a5df380c5a5ce155c779a22a9765dc (patch)
tree2ca2d51e5ff89084a973a3ec53d4ac212a71fcc0 /scripts
parentd713c17e29976cdb038ad0fa30b229674738abc8 (diff)
While we're at it, add a script for easy editing of user prefs.
We need some human-maintained rules based on the spam we get.
It's an imperfect world, but I'd _much_ rather deal with the
occassional spam than require signup/registration to post.
Diffstat (limited to 'scripts')
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/edit-sa-prefs b/scripts/edit-sa-prefs
new file mode 100755
index 00000000..acaed610
--- /dev/null
+++ b/scripts/edit-sa-prefs
@@ -0,0 +1,38 @@
+# Copyright (C) 2014, Eric Wong <e@80x24.org>
+# License: GPLv3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>
+# edit and atomically update ~/.spamasassin/user_prefs safely
+set -e
+cd ~/.spamassassin
+cp user_prefs user_prefs.edit.$$ # don't care if we clobber old files
+# non-blocking lock
+if ! ln user_prefs.edit.$$ user_prefs.edit
+        rm user_prefs.edit.$$
+        echo >&2 "we are already editing user_prefs.edit"
+        exit 1
+rm user_prefs.edit.$$
+${VISUAL-vi} user_prefs.edit
+if diff -u user_prefs user_prefs.edit
+        rm -f user_prefs.edit
+        echo 'no changes'
+        exit 0
+# check until we're good or $EDITOR fails
+while ! spamassassin -p user_prefs.edit --lint
+        echo >&2 "respawning editor, press Enter to continue"
+        read ignored_var
+        ${VISUAL-vi} user_prefs.edit
+# atomically replace user_prefs
+mv user_prefs.edit user_prefs
+echo '~/.spamassassin/user_prefs updated'