build.sh 3.3 KB
Newer Older
ale's avatar
ale committed
1
2
3
4
5
6
7
#!/bin/sh
#
# Install script for Mailman 2 inside a Docker container.
#

# Packages that are only used to build the site. These will be
# removed once we're done.
ale's avatar
ale committed
8
9
10
11
BUILD_PACKAGES="
        git
        rsync
"
ale's avatar
ale committed
12
13
14
15
16

# Packages required to serve the website and run the services, in
# addition to those already installed by the base apache2 image.
PACKAGES="
	mailman
ale's avatar
ale committed
17
	locales
ale's avatar
ale committed
18
        python-pip
ale's avatar
ale committed
19
        python-setuptools
ale's avatar
ale committed
20
21
        python-flask
        ai-sso-python
ale's avatar
ale committed
22
        findutils
ale's avatar
ale committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"

# Apache modules to enable.
APACHE_MODULES_ENABLE="
	cgi
"
export APACHE_MODULES_ENABLE

# Config snippets to enable for Apache.
APACHE_CONFIG_ENABLE=
export APACHE_CONFIG_ENABLE

# Sites to enable.
APACHE_SITES="
	mailman
"
export APACHE_SITES

# The default bitnami/minideb image defines an 'install_packages'
# command which is just a convenient helper. Define our own in
# case we are using some other Debian image.
if [ "x$(which install_packages)" = "x" ]; then
    install_packages() {
        env DEBIAN_FRONTEND=noninteractive apt-get install -qqy --no-install-recommends "$@"
    }
fi

set -e

ale's avatar
ale committed
52
53
54
55
56
57
# Preseed debconf for mailman. Install all languages.
debconf-set-selections <<EOF
mailman mailman/default_server_language select en
mailman mailman/site_languages multiselect ar (Arabic), ca (Catalan), cs (Czech), da (Danish), de (German), en (English), es (Spanish), et (Estonian), eu (Basque), fi (Finnish), fr (French), hr (Croatian), hu (Hungarian), ia (Interlingua), it (Italian), ja (Japanese), ko (Korean), lt (Lithuanian), nl (Dutch), no (Norwegian), pl (Polish), pt (Portuguese), pt_BR (Brasilian Portuguese), ro (Romanian), ru (Russian), sl (Slovenian), sr (Serbian), sv (Swedish), tr (Turkish), uk (Ukrainian), vi (Vietnamese), zh_CN (Chinese - China), zh_TW (Chinese - Taiwan)
EOF

ale's avatar
ale committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
install_packages ${BUILD_PACKAGES} ${PACKAGES}

# Install the configuration, overlayed over /etc.
rsync -a /tmp/conf/ /etc/

# Setup Apache.
/usr/local/bin/setup-apache.sh

# Create writable storage mountpoint. The situation with /var/lib/mailman
# is complex, there are "data" files and mailman files, and Debian links
# various subdirectories to locations in the /usr filesystem.
#
# Instead, we're going to do the reverse, and replace the "data" subdirs
# in /var/lib/mailman with symbolic links to /data, which will be where
# the data volume will be mounted in the container.
mkdir -p /data

# Exclude 'messages': it is maintained by the Debian package.
mailman_data_subdirs="archives data lists locks logs qfiles spam"
for d in $mailman_data_subdirs ; do
    rm -fr /var/lib/mailman/$d || true
    ln -sf /data/$d /var/lib/mailman/$d
done

ale's avatar
ale committed
82
83
84
85
# Since Mailman installs stuff in /etc/mailman too, we do the same trick
# as above but with the /config mountpoint.
mkdir -p /config
rm -f /etc/mailman/mm_cfg.py
ale's avatar
ale committed
86
for f in mm_cfg.py mailman_api.conf domains forced_params ; do
ale's avatar
ale committed
87
88
89
    ln -s /config/$f /etc/mailman/$f
done

ale's avatar
ale committed
90
91
92
93
# Create directory for PID file.
mkdir /var/run/mailman
chmod 1777 /var/run/mailman

ale's avatar
ale committed
94
95
96
# Create empty dir for webroot.
mkdir /var/empty

ale's avatar
ale committed
97
98
chmod 755 /usr/local/bin/apply-forced-params

ale's avatar
ale committed
99
# Install python-mailman-api.
ale's avatar
ale committed
100
(cd /tmp ; pip install \
ale's avatar
ale committed
101
    'git+https://git.autistici.org/ai3/python-mailman-api.git#egg=mailman-api')
ale's avatar
ale committed
102

ale's avatar
ale committed
103
104
105
106
107
108
109
# Remove packages used for installation.
apt-get remove -y --purge ${BUILD_PACKAGES}
apt-get autoremove -y
apt-get clean
rm -fr /var/lib/apt/lists/*
rm -fr /tmp/conf