3 # Configure Exim for GForge
4 # Christian Bayle, Roland Mas, debian-sf (GForge for Debian)
8 if [ $(id -u) != 0 ] ; then
9 echo "You must be root to run this, please enter passwd"
15 cp -a /etc/aliases /etc/aliases.gforge-new
16 # Redirect "noreply" mail to the bit bucket (if need be)
17 noreply_to_bitbucket=$(forge_get_config noreply_to_bitbucket)
18 if [ "$noreply_to_bitbucket" != "no" ] ; then
19 if ! grep -q "^noreply:" /etc/aliases.gforge-new ; then
20 echo "### Next line inserted by GForge install" >> /etc/aliases.gforge-new
21 echo "noreply: /dev/null" >> /etc/aliases.gforge-new
25 # Redirect "gforge" mail to the site admin
26 server_admin=$(forge_get_config admin_email)
27 if ! grep -q "^gforge:" /etc/aliases.gforge-new ; then
28 echo "### Next line inserted by GForge install" >> /etc/aliases.gforge-new
29 echo "gforge: $server_admin" >> /etc/aliases.gforge-new
32 cp -a /etc/exim/exim.conf /etc/exim/exim.conf.gforge-new
34 pattern=$(basename $0).XXXXXX
35 tmp1=$(mktemp /tmp/$pattern)
36 # First, get the list of local domains right
38 require ("/usr/share/gforge/lib/include.pl") ;
39 $seen_sf_domains = 0 ;
40 while (($l = <>) !~ /^\s*local_domains/) {
42 $seen_sf_domains = 1 if ($l =~ /\s*SOURCEFORGE_DOMAINS=/) ;
44 # hide pgsql_servers = "localhost/gforge/some_user/some_password"
45 print "SOURCEFORGE_DOMAINS=$sys_users_host:$sys_lists_host\n" unless $seen_sf_domains ;
47 $l .= ":SOURCEFORGE_DOMAINS" unless ($l =~ /^[^#]*SOURCEFORGE_DOMAINS/) ;
49 while ($l = <>) { print $l; };
50 ' < /etc/exim/exim.conf.gforge-new > $tmp1
51 tmp2=$(mktemp /tmp/$pattern)
52 # Second, insinuate our forwarding rules in the directors section
54 require ("/usr/share/gforge/lib/include.pl") ;
56 $sf_block = "# BEGIN SOURCEFORGE BLOCK -- DO NOT EDIT #
57 # You may move this block around to accomodate your local needs as long as you
58 # keep it in the Directors Configuration section (between the second and the
59 # third occurences of a line containing only the word \"end\")
61 domains = $sys_users_host
63 file_transport = address_file
64 query = \"ldap:///uid=\$local_part,ou=People,$sys_ldap_base_dn?debGforgeForwardEmail\"
69 forward_for_gforge_lists:
70 domains = $sys_lists_host
72 pipe_transport = address_pipe
73 query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListPostaddress\"
78 forward_for_gforge_lists_owner:
79 domains = $sys_lists_host
82 pipe_transport = address_pipe
83 query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListOwnerAddress\"
88 forward_for_gforge_lists_request:
89 domains = $sys_lists_host
92 pipe_transport = address_pipe
93 query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListRequestAddress\"
98 forward_for_sourceforge_lists_admin:
99 domains = $sys_lists_host
102 pipe_transport = address_pipe
103 query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListAdminAddress\"
108 forward_for_sourceforge_lists_bounces:
109 domains = $sys_lists_host
112 pipe_transport = address_pipe
113 query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListBouncesAddress\"
118 forward_for_sourceforge_lists_confirm:
119 domains = $sys_lists_host
122 pipe_transport = address_pipe
123 query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListConfirmAddress\"
128 forward_for_sourceforge_lists_join:
129 domains = $sys_lists_host
132 pipe_transport = address_pipe
133 query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListJoinAddress\"
138 forward_for_sourceforge_lists_leave:
139 domains = $sys_lists_host
142 pipe_transport = address_pipe
143 query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListLeaveAddress\"
148 forward_for_sourceforge_lists_subscribe:
149 domains = $sys_lists_host
152 pipe_transport = address_pipe
153 query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListSubscribeAddress\"
158 forward_for_sourceforge_lists_unsubscribe:
159 domains = $sys_lists_host
160 suffix = -unsubscribe
162 pipe_transport = address_pipe
163 query = \"ldap:///cn=\$local_part,ou=mailingList,$sys_ldap_base_dn?debGforgeListUnsubscribeAddress\"
167 # END SOURCEFORGE BLOCK #
170 while (($l = <>) !~ /^\s*end\s*$/) { print $l ; };
172 while (($l = <>) !~ /^\s*end\s*$/) { print $l ; };
177 while (($l = <>) !~ /^\s*end\s*$/) {
178 if ($l =~ /^# *DIRECTORS CONFIGURATION *#/) {
180 while ((($l = <>) =~ /^#.*#/) and ($l !~ /^# BEGIN SOURCEFORGE BLOCK -- DO NOT EDIT #/)) {
186 if ($l =~ /^# BEGIN SOURCEFORGE BLOCK -- DO NOT EDIT #/) {
188 push @line_buf, $sf_block unless $sf_block_done ;
191 push @line_buf, $l unless $in_sf_block ;
192 $in_sf_block = 0 if ($l =~ /^# END SOURCEFORGE BLOCK #/) ;
195 print $sf_block unless $sf_block_done ;
197 while ($l = <>) { print $l; };
200 cat $tmp2 > /etc/exim/exim.conf.gforge-new
205 [ -x /usr/bin/newaliases ] && newaliases
209 pattern=$(basename $0).XXXXXX
210 tmp1=$(mktemp /tmp/$pattern)
211 cp -a /etc/aliases /etc/aliases.gforge-new
212 # Redirect "noreply" mail to the bit bucket (if need be)
213 noreply_to_bitbucket=$(forge_get_config noreply_to_bitbucket)
214 if [ "$noreply_to_bitbucket" != "no" ] ; then
215 grep -v "^noreply:" /etc/aliases.gforge-new > $tmp1
216 cat $tmp1 > /etc/aliases.gforge-new
220 cp -a /etc/exim/exim.conf /etc/exim/exim.conf.gforge-new
222 tmp1=$(mktemp /tmp/$pattern)
223 # First, replace the list of local domains
225 while (($l = <>) !~ /^\s*local_domains/) {
226 print $l unless ($l =~ /\s*SOURCEFORGE_DOMAINS=/) ;
229 $l =~ /^(\s*local_domains\s*=\s*)(\S+)/ ;
230 $l = $1 . join (":", grep (!/SOURCEFORGE_DOMAINS/, (split ":", $2))) ;
232 while ($l = <>) { print $l; };
233 ' < /etc/exim/exim.conf.gforge-new > $tmp1
234 tmp2=$(mktemp /tmp/$pattern)
235 # Second, kill our forwarding rules
237 while (($l = <>) !~ /^\s*end\s*$/) { print $l ; };
239 while (($l = <>) !~ /^\s*end\s*$/) { print $l ; };
242 while (($l = <>) !~ /^\s*end\s*$/) {
243 if ($l =~ /^# BEGIN SOURCEFORGE BLOCK -- DO NOT EDIT #/) {
246 print $l unless $in_sf_block ;
247 $in_sf_block = 0 if ($l =~ /^# END SOURCEFORGE BLOCK #/) ;
250 while ($l = <>) { print $l; };
253 cat $tmp2 > /etc/exim/exim.conf.gforge-new
261 echo "Usage: $0 {configure|configure-files|purge|purge-files}"