diff options
author | Eric Wong <e@80x24.org> | 2014-04-26 07:42:25 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2014-04-26 07:42:25 +0000 |
commit | 095880dfd8a5df380c5a5ce155c779a22a9765dc (patch) | |
tree | 2ca2d51e5ff89084a973a3ec53d4ac212a71fcc0 /scripts | |
parent | d713c17e29976cdb038ad0fa30b229674738abc8 (diff) | |
download | public-inbox-095880dfd8a5df380c5a5ce155c779a22a9765dc.tar.gz |
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')
-rwxr-xr-x | scripts/edit-sa-prefs | 38 |
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 @@ +#!/bin/sh +# 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 +then + rm user_prefs.edit.$$ + echo >&2 "we are already editing user_prefs.edit" + exit 1 +fi + +rm user_prefs.edit.$$ + +${VISUAL-vi} user_prefs.edit + +if diff -u user_prefs user_prefs.edit +then + rm -f user_prefs.edit + echo 'no changes' + exit 0 +fi + +# check until we're good or $EDITOR fails +while ! spamassassin -p user_prefs.edit --lint +do + echo >&2 "respawning editor, press Enter to continue" + read ignored_var + ${VISUAL-vi} user_prefs.edit +done + +# atomically replace user_prefs +mv user_prefs.edit user_prefs +echo '~/.spamassassin/user_prefs updated' |