rss2email: Add service for RSS feeds to email

This is a basic implementation on top of the venerable `rss2email`
script, and is intended to be driven by a timer and the
`rss2email-subscribe` service, which manages the subscribed feeds.
This commit is contained in:
Alex Palaistras 2021-09-26 14:12:59 +01:00
parent 1e1e16e421
commit 14a53e567d
12 changed files with 120 additions and 0 deletions

View File

@ -0,0 +1,19 @@
FROM debian:bullseye-slim
ARG VERSION=4a088c7efe1c76fa1ebe842adc8e2a796df8f313
RUN apt-get update -y && apt-get install -y --no-install-recommends \
ca-certificates git gettext gosu \
python3 python3-setuptools python3-feedparser python3-html2text python3-bs4
RUN git clone https://github.com/rss2email/rss2email /tmp/rss2email && \
cd /tmp/rss2email && git reset --hard ${VERSION} && \
python3 setup.py install && \
rm -Rf /tmp/rss2email
RUN addgroup --system --gid 10000 rss2email
RUN adduser --system --uid 10000 --ingroup rss2email --home /var/lib/rss2email rss2email
COPY container/config /etc/rss2email
COPY container/run-rss2email /run-rss2email
ENTRYPOINT ["/run-rss2email"]

View File

@ -0,0 +1,16 @@
[DEFAULT]
from = ${RSS2EMAIL_FROM}
to = ${RSS2EMAIL_TO}
user-agent = rss2email/1.0
use-publisher-email = True
date-header = True
html-mail = True
post-process = rss2email.post_process.prettify process
email-protocol = smtp
smtp-auth = True
smtp-username = ${RSS2EMAIL_SMTP_USERNAME}
smtp-password = ${RSS2EMAIL_SMTP_PASSWORD}
smtp-server = ${RSS2EMAIL_SMTP_HOST}
smtp-port = ${RSS2EMAIL_SMTP_PORT}
smtp-ssl = True
verbose = info

View File

@ -0,0 +1,16 @@
#!/bin/sh
# Create configuration file from collected templates.
mkdir -p /etc/rss2email
envsubst < /etc/rss2email/rss2email.conf.template > /etc/rss2email/rss2email.conf
if test -n "$(ls -A /etc/rss2email/conf.d)"; then
cat /etc/rss2email/conf.d/*.conf >> /etc/rss2email/rss2email.conf
fi
# Correct permissions for data files.
mkdir -p /var/lib/rss2email
chown -R rss2email:rss2email /var/lib/rss2email
# Run entrypoint under specific user.
gosu rss2email /usr/local/bin/r2e --config /etc/rss2email/rss2email.conf --data /var/lib/rss2email/data.json "$@"

View File

@ -0,0 +1,9 @@
# Options for RSS-to-Email.
RSS2EMAIL_FROM=${RSS2EMAIL_FROM}
RSS2EMAIL_TO=${RSS2EMAIL_TO}
# Options for SMTP delivery mechanism.
RSS2EMAIL_SMTP_HOST=${POSTFIX_HOST}
RSS2EMAIL_SMTP_PORT=587
RSS2EMAIL_SMTP_USERNAME=${POSTFIX_LOCAL_SMTP_USERNAME}
RSS2EMAIL_SMTP_PASSWORD=${POSTFIX_LOCAL_SMTP_PASSWORD}

View File

@ -0,0 +1,12 @@
variant: fcos
version: 1.3.0
storage:
trees:
- path: /etc/systemd/system
local: service/rss2email/systemd/
systemd:
units:
- name: rss2email.service
enabled: true
- name: rss2email.timer
enabled: true

View File

@ -0,0 +1,18 @@
[Unit]
Description=RSS Feed Subscription for %I
[Service]
Type=oneshot
RemainAfterExit=true
SyslogIdentifier=%N
ExecStart=/bin/podman run --rm --entrypoint /bin/bash \
--volume rss2email-feeds:/etc/rss2email/conf.d:z \
localhost/rss2email:latest -c \
"printf '[feed.%%s]\nurl = %I\n' $(md5sum <<< '%i' | cut -c-32) > /etc/rss2email/conf.d/%i.conf"
ExecStop=/bin/podman run --rm --entrypoint /bin/bash \
--volume rss2email-feeds:/etc/rss2email/conf.d:z \
localhost/rss2email:latest -c \
"rm -f /etc/rss2email/conf.d/%i.conf"
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,16 @@
[Unit]
Description=RSS Feed to Email
Wants=container-build@%N.service postfix.service
After=container-build@%N.service postfix.service
[Service]
Type=oneshot
SyslogIdentifier=%N
ExecStart=/bin/podman run --replace --name %N --net internal \
--env-file %E/coreos-home-server/%N/%N.env \
--volume %N-feeds:/etc/%N/conf.d:z,ro \
--volume %N:/var/lib/%N:z \
localhost/%N:latest run
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,9 @@
[Unit]
Description=RSS-to-Email scheduled conversion
[Timer]
OnUnitActiveSec=1h
Persistent=true
[Install]
WantedBy=timers.target

Binary file not shown.

Binary file not shown.

View File

@ -18,6 +18,7 @@ ignition:
- local: service/radicale/spec.ign
- local: service/discord-ircd/spec.ign
- local: service/spectrum/spec.ign
- local: service/rss2email/spec.ign
passwd:
users:

View File

@ -34,3 +34,7 @@ POSTFIX_LOCAL_SMTP_PASSWORD=password
# Configuration for rspamd.
RSPAMD_CONTROLLER_PASSWORD=password
# Configuration for RSS2Email.
RSS2EMAIL_FROM=noreply@localhost
RSS2EMAIL_TO=root@localhost