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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
#! /bin/sh
#
# $Id: install-exim.sh 4099 2005-03-05 17:56:46Z cbayle $
#
# Configure Exim for GForge
# Christian Bayle, Roland Mas, debian-sf (GForge for Debian)
set -e
if [ $(id -u) != 0 ] ; then
echo "You must be root to run this, please enter passwd"
exec su -c "$0 $1"
fi
case "$1" in
configure-files)
cp -a /etc/aliases /etc/aliases.gforge-new
# Redirect "noreply" mail to the bit bucket (if need be)
noreply_to_bitbucket=$(perl -e'require "/etc/gforge/local.pl"; print "$noreply_to_bitbucket\n";')
if [ "$noreply_to_bitbucket" = "true" ] ; then
if ! grep -q "^noreply:" /etc/aliases.gforge-new ; then
echo "### Next line inserted by GForge install" >> /etc/aliases.gforge-new
echo "noreply: /dev/null" >> /etc/aliases.gforge-new
fi
fi
# Redirect "gforge" mail to the site admin
server_admin=$(perl -e'require "/etc/gforge/local.pl"; print "$server_admin\n";')
if ! grep -q "^gforge:" /etc/aliases.gforge-new ; then
echo "### Next line inserted by GForge install" >> /etc/aliases.gforge-new
echo "gforge: $server_admin" >> /etc/aliases.gforge-new
fi
cp -a /etc/exim/exim.conf /etc/exim/exim.conf.gforge-new
pattern=$(basename $0).XXXXXX
tmp1=$(mktemp /tmp/$pattern)
# First, get the list of local domains right
perl -e '
require ("/etc/gforge/local.pl") ;
$seen_sf_domains = 0 ;
while (($l = <>) !~ /^\s*local_domains/) {
print $l;
$seen_sf_domains = 1 if ($l =~ /\s*SOURCEFORGE_DOMAINS=/) ;
};
# hide pgsql_servers = "localhost/gforge/some_user/some_password"
print "SOURCEFORGE_DOMAINS=$sys_users_host:$sys_lists_host\n" unless $seen_sf_domains ;
chomp $l ;
$l .= ":SOURCEFORGE_DOMAINS" unless ($l =~ /^[^#]*SOURCEFORGE_DOMAINS/) ;
print "$l\n" ;
while ($l = <>) { print $l; };
' < /etc/exim/exim.conf.gforge-new > $tmp1
tmp2=$(mktemp /tmp/$pattern)
# Second, insinuate our forwarding rules in the directors section
perl -e '
require ("/etc/gforge/local.pl") ;
$sf_block = "# BEGIN SOURCEFORGE BLOCK -- DO NOT EDIT #
# You may move this block around to accomodate your local needs as long as you
# keep it in the Directors Configuration section (between the second and the
# third occurences of a line containing only the word \"end\")
forward_for_gforge:
domains = $sys_users_host
driver = aliasfile
file_transport = address_file
query = \"ldap:///uid=\$local_part,ou=People,$sys_ldap_base_dn?debGforgeForwardEmail\"
search_type = ldap
user = nobody
group = nogroup
forward_for_gforge_lists:
domains = $sys_lists_host
driver = aliasfile
pipe_transport = address_pipe
query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListPostaddress\"
search_type = ldap
user = nobody
group = nogroup
forward_for_gforge_lists_owner:
domains = $sys_lists_host
suffix = -owner
driver = aliasfile
pipe_transport = address_pipe
query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListOwnerAddress\"
search_type = ldap
user = nobody
group = nogroup
forward_for_gforge_lists_request:
domains = $sys_lists_host
suffix = -request
driver = aliasfile
pipe_transport = address_pipe
query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListRequestAddress\"
search_type = ldap
user = nobody
group = nogroup
forward_for_sourceforge_lists_admin:
domains = $sys_lists_host
suffix = -admin
driver = aliasfile
pipe_transport = address_pipe
query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListAdminAddress\"
search_type = ldap
user = nobody
group = nogroup
forward_for_sourceforge_lists_bounces:
domains = $sys_lists_host
suffix = -bounces
driver = aliasfile
pipe_transport = address_pipe
query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListBouncesAddress\"
search_type = ldap
user = nobody
group = nogroup
forward_for_sourceforge_lists_confirm:
domains = $sys_lists_host
suffix = -confirm
driver = aliasfile
pipe_transport = address_pipe
query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListConfirmAddress\"
search_type = ldap
user = nobody
group = nogroup
forward_for_sourceforge_lists_join:
domains = $sys_lists_host
suffix = -join
driver = aliasfile
pipe_transport = address_pipe
query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListJoinAddress\"
search_type = ldap
user = nobody
group = nogroup
forward_for_sourceforge_lists_leave:
domains = $sys_lists_host
suffix = -leave
driver = aliasfile
pipe_transport = address_pipe
query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListLeaveAddress\"
search_type = ldap
user = nobody
group = nogroup
forward_for_sourceforge_lists_subscribe:
domains = $sys_lists_host
suffix = -subscribe
driver = aliasfile
pipe_transport = address_pipe
query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListSubscribeAddress\"
search_type = ldap
user = nobody
group = nogroup
forward_for_sourceforge_lists_unsubscribe:
domains = $sys_lists_host
suffix = -unsubscribe
driver = aliasfile
pipe_transport = address_pipe
query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListUnsubscribeAddress\"
search_type = ldap
user = nobody
group = nogroup
# END SOURCEFORGE BLOCK #
" ;
while (($l = <>) !~ /^\s*end\s*$/) { print $l ; };
print $l ;
while (($l = <>) !~ /^\s*end\s*$/) { print $l ; };
print $l ;
$in_sf_block = 0 ;
$sf_block_done = 0 ;
@line_buf = () ;
while (($l = <>) !~ /^\s*end\s*$/) {
if ($l =~ /^# *DIRECTORS CONFIGURATION *#/) {
push @line_buf, $l ;
while ((($l = <>) =~ /^#.*#/) and ($l !~ /^# BEGIN SOURCEFORGE BLOCK -- DO NOT EDIT #/)) {
push @line_buf, $l ;
};
print @line_buf ;
@line_buf = () ;
};
if ($l =~ /^# BEGIN SOURCEFORGE BLOCK -- DO NOT EDIT #/) {
$in_sf_block = 1 ;
push @line_buf, $sf_block unless $sf_block_done ;
$sf_block_done = 1 ;
};
push @line_buf, $l unless $in_sf_block ;
$in_sf_block = 0 if ($l =~ /^# END SOURCEFORGE BLOCK #/) ;
};
push @line_buf, $l ;
print $sf_block unless $sf_block_done ;
print @line_buf ;
while ($l = <>) { print $l; };
' < $tmp1 > $tmp2
rm $tmp1
cat $tmp2 > /etc/exim/exim.conf.gforge-new
rm $tmp2
;;
configure)
[ -x /usr/bin/newaliases ] && newaliases
;;
purge-files)
pattern=$(basename $0).XXXXXX
tmp1=$(mktemp /tmp/$pattern)
cp -a /etc/aliases /etc/aliases.gforge-new
# Redirect "noreply" mail to the bit bucket (if need be)
noreply_to_bitbucket=$(perl -e'require "/etc/gforge/local.pl"; print "$noreply_to_bitbucket\n";')
if [ "$noreply_to_bitbucket" = "true" ] ; then
grep -v "^noreply:" /etc/aliases.gforge-new > $tmp1
cat $tmp1 > /etc/aliases.gforge-new
fi
rm -f $tmp1
cp -a /etc/exim/exim.conf /etc/exim/exim.conf.gforge-new
tmp1=$(mktemp /tmp/$pattern)
# First, replace the list of local domains
perl -e '
while (($l = <>) !~ /^\s*local_domains/) {
print $l unless ($l =~ /\s*SOURCEFORGE_DOMAINS=/) ;
};
chomp $l ;
$l =~ /^(\s*local_domains\s*=\s*)(\S+)/ ;
$l = $1 . join (":", grep (!/SOURCEFORGE_DOMAINS/, (split ":", $2))) ;
print "$l\n" ;
while ($l = <>) { print $l; };
' < /etc/exim/exim.conf.gforge-new > $tmp1
tmp2=$(mktemp /tmp/$pattern)
# Second, kill our forwarding rules
perl -e '
while (($l = <>) !~ /^\s*end\s*$/) { print $l ; };
print $l ;
while (($l = <>) !~ /^\s*end\s*$/) { print $l ; };
print $l ;
$in_sf_block = 0 ;
while (($l = <>) !~ /^\s*end\s*$/) {
if ($l =~ /^# BEGIN SOURCEFORGE BLOCK -- DO NOT EDIT #/) {
$in_sf_block = 1 ;
}
print $l unless $in_sf_block ;
$in_sf_block = 0 if ($l =~ /^# END SOURCEFORGE BLOCK #/) ;
};
print $l ;
while ($l = <>) { print $l; };
' < $tmp1 > $tmp2
rm $tmp1
cat $tmp2 > /etc/exim/exim.conf.gforge-new
rm $tmp2
;;
purge)
;;
*)
echo "Usage: $0 {configure|configure-files|purge|purge-files}"
exit 1
;;
esac
|