Compare commits

..

No commits in common. "98cc0b0d8078b3eff5337c7cfd277bc2a2a3c20f" and "79178b9ca8a8a4b19956f52607c820b1fe921ad7" have entirely different histories.

5 changed files with 0 additions and 84 deletions

View file

@ -85,7 +85,6 @@ UID | GID | Container | Notes
95 | 95 | shiori | Shiori bookmark system, built from source 95 | 95 | shiori | Shiori bookmark system, built from source
999 | 994 | certbot | The same user & group as fabio, because file permissions 999 | 994 | certbot | The same user & group as fabio, because file permissions
2100 | 2100 | redis | 2100 | 2100 | redis |
10000 | 10000 | imap-download | Uses fetchmail to download emails and extract attachments
## Development Notes ## Development Notes

View file

@ -1,29 +0,0 @@
ARG REPO_LOCATION
# ARG BASE_VERSION
FROM ${REPO_LOCATION}minideb
RUN install_packages ca-certificates fetchmail procmail inotify-tools mpack
RUN mkdir /srv/home \
&& ln -s /mnt/fetchmailrc /srv/home/.fetchmailrc \
&& mkdir /tmp/maildir
ENV HOME /srv/home
COPY ./procmail.conf /srv/procmail.conf
COPY ./run.sh /srv/run.sh
VOLUME /mnt/fetchmailrc
VOLUME /mnt/output
# Example fetchmailrc file:
#
# poll starbeamrainbowlabs.com protocol IMAP
# user "user@example.com" with pass "PASSWORD_HERE"
# idle
# ssl
USER 10000:10000
ENTRYPOINT [ "/srv/run.sh" ]

View file

@ -1,5 +0,0 @@
CORRECTHOME=/tmp/maildir
MAILDIR=$CORRECTHOME/
:0
Mail/

View file

@ -1,48 +0,0 @@
#!/usr/bin/env bash
temp_dir="$(mktemp --tmpdir -d "imap-download-XXXXXXX")";
on_exit() {
rm -rf "${temp_dir}";
}
trap on_exit EXIT;
do_fetchmail() {
fetchmail --mda "/usr/bin/procmail -m /srv/procmail.conf";
}
log_msg() {
echo "$(date -u +"%Y-%m-%d %H:%M:%S") imap-download: $*";
}
dir_newmail="/tmp/maildir/Mail/new";
target_dir="/mnt/output";
do_attachments() {
while :; do # : = infinite loop
# Wait for an update
# inotifywait's non-0 exit code forces an exit for some reason :-/
inotifywait -qr --event create --format '%:e %f' "${dir_newmail}";
while read -r filename; do
log_msg "Processing email ${filename}";
# Move the email to a temporary directory for processing
mv "${filename}" "${temp_dir}";
# Unpack the attachments
munpack -C "${temp_dir}" "${filename}";
# Delete the original email file and any description files
rm "${filename}";
find "${temp_dir}" -iname '*.desc' -delete;
# Move the attachment files to the output directory
while read -r attachment; do
log_msg "Extracted attachment ${attachment}";
mv "${attachment}" "${target_dir}";
done < <(find "${temp_dir}" -type f);
done < <(find "${dir_newmail}" -type f);
done
}
do_fetchmail &
do_attachments

View file

@ -1 +0,0 @@
docker