-
Notifications
You must be signed in to change notification settings - Fork 1
/
setupmailman.sh
executable file
·159 lines (111 loc) · 3.35 KB
/
setupmailman.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
# Store the current directory
SCRIPTDIR=`pwd`
# Postfix Config file
POSTFIXCONF=/etc/postfix/master.cf
# Mailman Apache Setup
MAILMANAPACHECONF=/etc/mailman/apache.conf
# Apache sites-enabled setup
APACHESITES=/etc/apache2/sites-enabled/mailman
# Mailman DIRs
MAILMANCONFDIR=/etc/mailman
MAILMANDATADIR=/var/lib/mailman
MAILMANCODEDIR=/usr/lib/mailman
function install_python-markdown {
echo "Installing python-markdown"
aptitude install -y python-markdown >> setupmailman.log
}
function install_python-psycopg2 {
echo "Installing python-psycopg2"
aptitude install -y python-psycopg2 >> setupmailman.log
}
function install_python-storm {
echo "Installing python-storm"
aptitude install -y python-storm >> setupmailman.log
}
function install_postgresql {
echo "Installing PostgreSQL"
aptitude install -y postgresql >> setupmailman.log
}
function install_mailman {
echo "Intalling MailMan, Postfix and Apache2"
aptitude install -y mailman postfix
}
function install_bazaar {
echo "Installing Bazaar"
aptitude install -y bzr >> setupmailman.log
}
function install_mailx {
echo "Installing mailx"
aptitude install -y heirloom-mailx >> setupmailman.log
}
function edit_postgres {
echo "Creating PostgreSQL user mailman"
sudo -u postgres createuser -s -d -R mailman
echo "Altering Role"
sudo -u postgres psql << EOF
alter user mailman password 'mailman';
EOF
}
function edit_postfix {
echo "Editing Postfix Configuration"
cat postfix.cnf.add >> $POSTFIXCONF
echo "Restarting Postfix"
/etc/init.d/postfix restart
}
function edit_apache {
echo "Adding MailMan config to Apache sites"
cp $MAILMANAPACHECONF $APACHESITES
echo "Restarting Apache"
/etc/init.d/apache2 restart
}
function setup_mailman {
echo "Creating directory in Mailman Code Directory"
mkdir $MAILMANCODEDIR/templates
echo "Copying English templates"
mv $MAILMANCONFDIR/en $MAILMANCODEDIR/templates/
echo "Moving old templates symlink"
mv $MAILMANDATADIR/templates $MAILMANDATADIR/templates.old
echo "Creating new symbolic link to templates"
ln -s $MAILMANCODEDIR/templates $MAILMANDATADIR/templates
echo "Shifting to MailMan Code Directory"
cd $MAILMANCODEDIR
echo "Checking out Systers Mailman code. This could take a while."
bzr checkout lp:systers .
echo "Applying Patch"
patch $MAILMANCODEDIR/Mailman/mm_cfg.py $SCRIPTDIR/mm_cfg.patch
echo "Fixing permissions"
$MAILMANCODEDIR/bin/check_perms -f >> setupmailman.log
echo "Creating newlist mailman"
newlist -q mailman root@localhost.localdomain 1234 >> setupmailman.log
echo "Creating newlist systers-admin"
newlist -q systers-admin root@localhost.localdomain 1234 >> setupmailman.log
echo "Copying and generating new alias DB"
$MAILMANCODEDIR/bin/genaliases -q >> /etc/aliases
newaliases
echo "Starting Mailman"
/etc/init.d/mailman start
}
echo "Starting install process"
if [ ! -e setupmailman.log ]; then
touch setupmailman.log;
fi
echo ""
echo "Will install all packages now"
install_python-markdown
install_python-psycopg2
install_python-storm
install_postgresql
install_mailman
install_bazaar
install_mailx
echo ""
echo "Will edit all configuration now"
edit_postgres
edit_postfix
edit_apache
echo ""
echo "Will setup mailman now"
setup_mailman
echo ""
echo "Done!"