Skip to content
Snippets Groups Projects
Commit 71464c0d authored by ale's avatar ale
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
image: docker:latest
stages:
- build
- release
services:
- docker:dind
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
RELEASE_TAG: $CI_REGISTRY_IMAGE:latest
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.git.autistici.org
build:
stage: build
script:
- docker build --pull -t $IMAGE_TAG .
- docker push $IMAGE_TAG
release:
stage: release
script:
- docker pull $IMAGE_TAG
- docker tag $IMAGE_TAG $RELEASE_TAG
- docker push $RELEASE_TAG
only:
- master
FROM registry.git.autistici.org/ai3/docker/apache2-base:master
COPY build.sh /tmp/build.sh
COPY smtpd.py /usr/bin/smtpd
COPY conf/ /etc/
RUN /tmp/build.sh && rm /tmp/build.sh
ENTRYPOINT ['/usr/local/bin/chaperone']
Docker image for lurker, a mailing list archiver.
The image contains both an Apache server and an incoming SMTP server,
this is simply because the Debian lurker package has a strict dependency
on the apache2 package, so it was more convenient to do it this way
instead of using two separate container images.
Configuration and data storage must be mounted respectively in
*/etc/lurker* and */var/lib/lurker*.
build.sh 0 → 100755
#!/bin/sh
#
# Install script for Lurker inside a Docker container.
#
PACKAGES="
lurker
python3-aiosmtpd
"
install_packages() {
env DEBIAN_FRONTEND=noninteractive apt-get install -qy -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --no-install-recommends "$@"
}
die() {
echo "ERROR: $*" >&2
exit 1
}
set -x
# Install packages.
apt-get -q update
install_packages ${PACKAGES} \
|| die "could not install packages"
# Enable the apache modules we need.
a2enmod -q cgi rewrite
# Enable the lurker vhost.
a2ensite lurker
# Create mountpoint dirs.
mkdir -p /var/lib/lurker
# Clear the existing default config
# (this will be mounted externally).
rm -fr /etc/lurker/*
# Clean up.
apt-get autoremove -y
apt-get clean
rm -fr /var/lib/apt/lists/*
<VirtualHost *:80>
ServerAdmin webmaster@autistici.org
ServerName lists.autistici.org
DocumentRoot /var/lib/lurker/www
ScriptAlias /cgi-lurker /usr/lib/cgi-bin/lurker
# correzione per lo stupido mailman che aggiunge una /
# in fondo alle url dalla pagina di informazioni della lista
RewriteEngine on
RewriteRule ^(/list/.*\.html)/$ $1 [R]
# disabilita il sito quando e' in corso la rigenerazione
RewriteCond /var/lib/lurker/.tmp -d
<Directory /var/lib/lurker/www>
Require all granted
AddType text/xml .xsl
AddType text/xml .xml
AddType message/rfc822 .rfc822
AddDefaultCharset UTF-8
# invoke lurker if the requested file does not exist
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(attach|list|mbox|message|mindex|search|splash|thread|zap)/[^/]+$ /cgi-lurker/lurker.cgi [L,PT,E=LURKER_CONFIG:/etc/lurker/lurker.conf,E=LURKER_FRONTEND:%{REQUEST_FILENAME}]
</IfModule>
</Directory>
</VirtualHost>
\ No newline at end of file
smtpd.service: {
command: "/usr/bin/smtpd",
exit_kills: true,
}
smtpd.py 0 → 100755
#!/usr/bin/python3
#
# SMTP server for lurker.
#
# Listens on an arbitrary port and forwards messages with a recipient of
#
# lurker+<list_name>@<mydomain>
#
# to the lurker-index binary.
import asyncio
import logging
import os
from aiosmtpd.controller import Controller
LURKER_LIBDIR = os.getenv('LURKER_LIBDIR', '/var/lib/lurker/')
LURKER_DOMAIN_NAME = os.getenv('LURKER_DOMAIN_NAME', 'lurker.autistici.org')
def _is_lurker_in_maintenance():
return os.path.exists(os.path.join(LURKER_LIBDIR, '.tmp'))
class LurkerHandler:
async def handle_RCPT(server, session, envelope, address, rcpt_options):
if _is_lurker_in_maintenance():
return '450 lurker is in maintenance mode'
userpart, domain = address.split('@', 1)
if domain != LURKER_DOMAIN_NAME:
return '550 unknown recipient domain'
if not userpart.startswith('lurker+'):
return '550 unknown recipient user'
envelope.rcpt_tos.append(address)
return '250 OK'
async def handle_DATA(server, session, envelope):
logging.debug('message from %s to %s',
envelope.mail_from, envelope.rcpt_tos)
data = envelope.content.decode('utf8', errors='replace')
for rcpt in envelope.rcpt_tos:
list_name = rcpt.split('@')[0].split('+', 1)[1]
cmd = ['/usr/bin/lurker-index', '-m', '-l', list_name]
proc = await asyncio.create_subprocess_exec(
'/usr/bin/lurker-index', '-m', '-l', list_name,
stdin=asyncio.subprocess.PIPE)
await proc.communicate(data)
await proc.wait()
return '250 Message accepted for delivery'
async def amain(loop):
port = int(os.getenv('SMTP_PORT', '5525'))
controller = Controller(LurkerHandler, hostname='', port=port)
controller.start()
if __name__ == '__main__':
logging.basicConfig(level=logging.WARNING)
loop = asyncio.get_event_loop()
loop.create_task(amain(loop=loop))
loop.run_forever()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment