X-Git-Url: https://git.madduck.net/etc/mailfilter.git/blobdiff_plain/3a35a72b02f689e9ed9ec92f45f084f761d5c8b5..90e7c2b254d33d781ed8f9932713a2edbb775fae:/bin/release-delayed-messages diff --git a/bin/release-delayed-messages b/bin/release-delayed-messages index 6a057c9..cdb6da4 100755 --- a/bin/release-delayed-messages +++ b/bin/release-delayed-messages @@ -1,12 +1,18 @@ #!/bin/sh set -eu -MAILDIR=$HOME/.maildir +DELAYED_QUEUE=$HOME/.maildir/.delayed -SQLITE=/usr/bin/sqlite3 -DELAYED_QUEUE_DB=$HOME/.var/procmail/delayed-queue.sqlite +DIR="${0%/*}" -QUERY="update messages set release_ts = strftime('%s', 'now') - 10 where filename like '.delayed/%'" +VAR=$HOME/.var/procmail +ME="${0##*/}" +LOCKFILE="$VAR/.$ME.lock" +trap "rm -f $LOCKFILE" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 +if ! lockfile -0 -r0 -l 3600 "$LOCKFILE" 2>/dev/null; then + echo "E: another $ME process is already running over that Maildir." >&2 + exit 1 +fi -$SQLITE $DELAYED_QUEUE_DB "$QUERY" -exec $HOME/.etc/mailfilter/bin/process-delayed-queue +"$DIR"/list-postponed-messages --all "$DELAYED_QUEUE" \ + | exec xargs "$DIR"/resubmit --list