X-Git-Url: https://git.madduck.net/etc/mailfilter.git/blobdiff_plain/8d18b671d3e6e0c871f6cc81cf6ddc58589f35ce..077b14fe096740e5a2cb4fc9d489d2712d3c8fe5:/bin/release-delayed-messages diff --git a/bin/release-delayed-messages b/bin/release-delayed-messages index fd381d3..73c6b3b 100755 --- a/bin/release-delayed-messages +++ b/bin/release-delayed-messages @@ -1,12 +1,19 @@ #!/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') 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 + trap - 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 + 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