]> git.madduck.net Git - etc/mailfilter.git/blob - bin/process-delayed-queue

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

process tickle submissions with delayed queue
[etc/mailfilter.git] / bin / process-delayed-queue
1 #!/bin/sh
2 set -eu
3
4 MAILDIR=$HOME/.maildir
5
6 SQLITE=/usr/bin/sqlite3
7 RESUBMIT=$HOME/.etc/mailfilter/bin/resubmit
8
9 DELAYED_QUEUE_DB=$HOME/.var/procmail/delayed-queue.sqlite
10
11 QUERY='select * from messages where release_ts < strftime("%s", "now")'
12
13 $SQLITE -column $DELAYED_QUEUE_DB "$QUERY" | while read msgid basefile ts; do
14
15   file="$MAILDIR/$basefile"
16   files="$file ${file}:2,"
17
18   basename="${file##*/}"
19   dirname="${file%/*}"
20   case "${dirname##*/}" in
21     cur)
22       files="$files ${file}:2,S"
23       file="${dirname%/cur}/new/$basename"
24       files="$files $file ${file}:2,"
25       ;;
26     new)
27       file="${dirname%/new}/cur/$basename"
28       files="$files ${file}:2, ${file}:2,S"
29       ;;
30   esac
31
32   found=0
33   for file in $files; do
34     if [ -f "$file" ]; then
35       $RESUBMIT "$file"
36       echo "I: resubmitted $msgid"
37       found=1
38       break
39     fi
40   done
41
42   $SQLITE $DELAYED_QUEUE_DB "delete from messages where msgid = '$msgid'"
43
44   if [ $found -eq 0 ]; then
45     echo "E: message $msgid not found in $basefile" >&2
46   fi
47
48 done