commit 4f2333dfa759a3ddc6d8cbfb679763f3a4fc2e59
parent f385eff087138ac8a22ac0f97084fa668c4b823d
Author: parazyd <parazyd@dyne.org>
Date: Wed, 28 Feb 2018 01:24:21 +0100
Add rpsieve and filters.txt.
Diffstat:
5 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
@@ -15,7 +15,7 @@ install: all
sed "s,SHAREPREFIX,$(SHAREPREFIX),g" < bin/rpinit > $(DESTDIR)$(PREFIX)/bin/rpinit
chmod 755 $(DESTDIR)$(PREFIX)/bin/rpinit
mkdir -p $(DESTDIR)$(SHAREPREFIX)
- cp -r rplib mutt $(DESTDIR)$(SHAREPREFIX)
+ cp -r rplib mutt misc $(DESTDIR)$(SHAREPREFIX)
chmod 755 $(DESTDIR)$(SHAREPREFIX)
uninstall:
diff --git a/bin/rpabook b/bin/rpabook
@@ -40,10 +40,10 @@ for i in $@; do
comp "$1"
exit $?
;;
- *)
+ -h)
usage
;;
esac
done
-abook --datafile "$profile/whitelist.abook"
+abook --datafile "$profile/whitelist.abook" "$@"
diff --git a/bin/rpinit b/bin/rpinit
@@ -138,6 +138,8 @@ setupmutt "$profile"
touch "$profile/whitelist.abook"
chmod 600 "$profile/whitelist.abook"
+cp "$shareprefix/misc/filters.txt" "$profile"
+
ln -snf "$shareprefix/rplib" "./rplib"
git init
diff --git a/bin/rpsieve b/bin/rpsieve
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+profile="${RPPROFILE:-$HOME/.rp/default}"
+. "$HOME"/.rp/rplib/common.sh
+
+
+[ -f "$profile/filters.txt" ] || edie "no filters.txt file"
+
+ebegin "regenerating filters.sieve"
+
+ebegin "adding skel"
+cat <<EOF > "$profile/filters.sieve"
+# mailbox supports fileinto :create
+require ["fileinto","mailbox","variables"];
+
+# bounces
+if header :contains "Sender" "mailman-bounce" {
+ fileinto :create "zz.bounces";
+ stop;
+}
+
+# own filters
+EOF
+
+ebegin "adding To:"
+grep '^to' "$profile/filters.txt" | while read line; do
+ cat <<EOF >> "$profile/filters.sieve"
+if header :contains ["To","Cc"] "$(echo $line | awk '{print $2}')" { fileinto :create "$(echo $line | awk '{print $4}')"; stop; }
+EOF
+done
+
+ebegin "adding From:"
+grep '^from' "$profile/filters.txt" | while read line; do
+ cat <<EOF >> "$profile/filters.sieve"
+if header :contains "From" "$(echo $line | awk '{print $2}')" { fileinto :create "$(echo $line | awk '{print $4}')"; stop; }
+EOF
+done
+
+ebegin "adding rpabook whitelist"
+cat <<EOF >> "$profile/filters.sieve"
+
+# INBOX
+if header :contains "From" [
+EOF
+
+grep '^email' "$profile/whitelist.abook" | \
+ sed -e 's/^email=/"/' -e 's/$/",/' | head -c -2 >> "$profile/filters.sieve"
+
+
+ebegin "finalizing"
+cat <<EOF >> "$profile/filters.sieve"
+
+]
+{ fileinto :create "INBOX"; stop; }
+
+# spam
+if header :is "X-Spam-Flag" "YES" { fileinto :create "zz.spam"; stop; }
+
+fileinto :create "unsorted";
+EOF
diff --git a/misc/filters.txt b/misc/filters.txt
@@ -0,0 +1,14 @@
+# filter configuration for rp
+# this file is parsed by rpsieve and generates filters.sieve
+
+from twitter.com save zz.social
+from facebookmail.com save zz.social
+from feedback@slack.com save zz.spam
+
+
+# mailinglists
+
+to heads@lists.dyne.org save dyne.heads
+to unsystem@lists.dyne.org save dyne.unsystem
+from gerrit@coreboot.org save coreboot.gerrit
+to gopher-project@other.debian.org save debian.gopher-project