Hello,
On Mon, May 27, 2024 at 06:00:15AM -0000, marcus--- via Mailman-users wrote:
Thank you for your solution. I assumed that Debian actually creates the most important packages and configurations with the installation via the packages.
Here is how I automatically install and migrate data (still testing, seems to work quite well so far) on Debian bookworm. A few things are missing from the script for clarity (it gets munin & logcheck monitoring, notably).
It assumes a few things in a templates/ directory.
I have a few aliases (such as services_*), but you get the idea.
Some stuff could be configured via debconf preseeding, but I didn't do it that way.
#! /bin/bash
set -e
services_install postfix (while read line do case $line in *=*) postconf -e "$line";; *) echo "TOSSING: $line" >&2;; esac done) <<EOF myhostname = $lists mydestination = $lists mynetworks = 127.0.0.0/8 inet_protocols = ipv4 inet_interfaces = all transport_maps = hash:/var/lib/mailman3/data/postfix_lmtp local_recipient_maps = hash:/var/lib/mailman3/data/postfix_lmtp relay_domains = hash:/var/lib/mailman3/data/postfix_domains EOF
services_do restart postfix
djangoauth=($(egrep '^djangosuperuser\s' templates/passwords/pw)) psqlauth=($(egrep '^psql\s' templates/passwords/pw)) rm -f templates/passwords/pw
services_install dbconfig-pgsql
cat > /etc/dbconfig-common/mailman3.conf <<EOF dbc_install='true' dbc_upgrade='true' dbc_remove='false' dbc_dbtype='pgsql' dbc_dbuser='${psqlauth[1]}' dbc_dbpass='${psqlauth[2]}' dbc_dbserver='ds-services-psql' dbc_dbname='mailman' dbc_dbadmin='postgres' EOF
sed < /etc/dbconfig-common/mailman3.conf
> /etc/dbconfig-common/mailman3-web.conf
"s/^dbc_dbname=.*/dbc_dbname='mailmanweb'/"
chmod 600 /etc/dbconfig-common/mailman3.conf
/etc/dbconfig-common/mailman3-web.conf
services_install mailman3-full mailman3-web
sed --in-place "s/^site_owner: .*/site_owner: ${djangoauth[1]}/"
/etc/mailman3/mailman.cfg
# work-around: SQLAlchemy no longer supports "postgres"
sed --in-place "s%^url: postgres://%url: postgresql://%"
/etc/mailman3/mailman.cfg
sed --in-place "s/.*'Mailman Suite Admin', 'root@localhost').*/('Mailman Suite Admin', '${djangoauth[1]}'),/;s/^EMAILNAME\s*=.*/EMAILNAME = '$lists'/" /etc/mailman3/mailman-web.py
# aliases mailman <-> postfix mkdir -p /var/lib/mailman3/data chown list:list /var/lib/mailman3/data for i in postfix_lmtp postfix_lmtp postfix_domains do touch /var/lib/mailman3/data/$i postmap /var/lib/mailman3/data/$i done chown list:list /var/lib/mailman3/data/postfix_*
services_do restart postfix service_enable postfix
services_install apache2
ln -s /etc/mailman3/apache.conf /etc/apache2/conf-available/mailman3.conf a2enconf mailman3
a2enmod proxy_uwsgi
service_enable apache2 services_do restart apache2
service_enable mailman3-web services_do restart mailman3-web
# fix example.com PGPASSWORD=${psqlauth[2]} psql -h ds-services-psql -U ${psqlauth[1]} mailmanweb -c "UPDATE django_site SET domain = '$lists', name = '$lists' WHERE id = 1"
# workaround required? #chgrp list /var/lib/mailman3/locks/ #chmod g+rwx /var/lib/mailman3/locks/ chgrp list /var/log/mailman3/*.log
mailman-wrapper info
env DJANGO_SUPERUSER_PASSWORD=${djangoauth[3]}
DJANGO_SUPERUSER_USERNAME=${djangoauth[2]}
DJANGO_SUPERUSER_EMAIL=${djangoauth[1]}
mailman-web createsuperuser --noinput
|| echo "django super user already exists in DB, ignored"
services_do restart mailman3
if [ 0 = 0 ]; then # permissions on ~user are restrictive mkdir /tmp/mailman cp -a templates/lists /tmp/mailman/lists
# to be generated with: scripts/get_ml.sh for i in /tmp/mailman/lists/*.pck do l=${i/*\/} l=${l/.pck} mailman-wrapper remove $l@$lists || echo "list $l does not yet exist, ignoring rm" mailman-wrapper create $l@$lists mailman-wrapper import21 --charset iso8859-1 $l@$lists $i done
# not doing that yet if [ 0 = 1 ]; then for i in /tmp/mailman/lists/*.members do l=${i/*\/} l=${l/.members} mailman-wrapper --no-welcome-msg addmembers $i $l@$lists done else echo schaefer@horus.ch | mailman-wrapper addmembers - $l@$lists fi
for i in /tmp/mailman/lists/*.mbox do l=${i/*\/} l=${l/.mbox}
/usr/share/mailman3-web/manage.py hyperkitty_import \
-l $l@$lists $i
done
rm -rf /tmp/mailman
/usr/share/mailman3-web/manage.py update_index else # simple test mailman-wrapper create --notify --owner schaefer@alphanet.ch mailman-admins@$lists echo schaefer@horus.ch | mailman-wrapper addmembers - mailman-admins@$lists fi