summaryrefslogtreecommitdiff
path: root/sfeed_maildir
blob: b6dc0eef4c91e97c37ce3d07aa48676fe95b011d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
# Uses procmail to format mbox to maildir, see procmailrc.example.
# Copy procmailrc.example to $procmailconfig (see below).
# Depends on: procmail, formail, sfeed_mbox.

maildir="$HOME/feeds"
feedsdir="$HOME/.sfeed/feeds"
procmailconfig="$HOME/.sfeed/procmailrc"

# message-id cache to prevent duplicates.
mkdir -p "${maildir}/.cache"

if ! test -r "${procmailconfig}"; then
	echo "Procmail configuration file \"${procmailconfig}\" does not exist or is not readable." >&2
	echo "See procmailrc.example for an example." >&2
	exit 1
fi

find "${feedsdir}" -type f -exec printf '%s\n' {} \; | while read -r d; do
	(name=$(basename "${d}")
	mkdir -p "${maildir}/${name}/cur"
	mkdir -p "${maildir}/${name}/new"
	mkdir -p "${maildir}/${name}/tmp"
	printf 'Mailbox %s\n' "${name}"
	sfeed_mbox "${d}" | formail -s procmail "${procmailconfig}") &
done
wait