root/alternc-mailman/tags/1.4.10/debian/postinst

Revision 1239, 3.6 kB (checked in by lunar, 3 years ago)

r90@sud: lunar | 2006-03-11 15:24:41 +0100
Fix configure/unconfigure functions in postinst/postrm scripts

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/bin/sh
2
3 set -e
4
5 CONFIGFILE="/etc/alternc/local.sh"
6 MENUFILE="/etc/alternc/menulist.txt"
7 MAILMAN_SCRIPT="/var/lib/mailman/mail/mailman"
8 MAILMAN_CONFIG="/etc/mailman/mm_cfg.py"
9 MAILMAN_CONFIG_TEMPLATE="/etc/alternc/templates/mailman/mm_cfg.py"
10 MAILMAN_CONFIG_BACKUP="/var/backups/alternc/etc-mailman-mm_cfg.py"
11 MAILMAN_SCRIPT="/var/lib/mailman/mail/mailman"
12
13 # Add mailman aliases to the apache configuration file given as argument
14 function configure {
15     if ! grep -Eq "\*\*\*MAILMAN\*\*\*" $1; then
16         cp -a -f $1 $1.tmp
17         sed -e "s/\*\*\*ALTERNC_ALIASES\*\*\*/&\\
18             # ***MAILMAN*** \\
19         Alias \/marchives\/ \/var\/lib\/mailman\/archives\/public\/ \\
20         Alias \/mimages\/ \/usr\/share\/images\/mailman\//" < $1 > $1.tmp
21         mv -f $1.tmp $1
22     fi
23 }
24
25
26 case "$1" in
27   configure)
28     . "$CONFIGFILE"
29
30     echo "Installing mysql table"
31     mysql -u"$MYSQL_USER" -p"$MYSQL_PASS" -h"$MYSQL_HOST" "$MYSQL_DATABASE" \
32         < /usr/share/alternc/install/mailman.sql
33    
34     # Install generated mailman configuration if it has not been modified since
35     # last package configuration
36     if [ -f "$MAILMAN_CONFIG_BACKUP" ]; then
37         if ! diff -q "$MAILMAN_CONFIG" "$MAILMAN_CONFIG_BACKUP"; then
38             echo "$MAILMAN_CONFIG has been modified since last alternc-mailman"
39             echo "configuration.  You should merge your changes to"
40             echo "$MAILMAN_CONFIG_TEMPLATE and delete $MAILMAN_CONFIG_BACKUP"
41             exit 1
42         fi
43     fi
44     sed -e "s/%%fqdn%%/$FQDN/" < "$MAILMAN_CONFIG_TEMPLATE" > "$MAILMAN_CONFIG"
45     cp -a -f "$MAILMAN_CONFIG" "$MAILMAN_CONFIG_BACKUP"
46
47     # Create the "mailman" list if it does not exist yet
48     if [ ! -d /var/lib/mailman/lists/mailman ]; then
49         /var/lib/mailman/bin/newlist -q mailman "root@$FQDN" "$MYSQL_PASS"
50         ( echo "INSERT INTO mailman
51                 VALUES (NULL, 2000, 'mailman', '${FQDN}', 'mailman');"
52           echo "INSERT INTO mail_domain
53                 VALUES ('${user}@${FQDN}', '${user}_${FQDN}', 2000, 0, 1);"
54           echo "INSERT INTO mail_alias
55                 VALUES ('${user}_${FQDN}',
56                         '\"| $MAILMAN_SCRIPT post mailman\"');"
57           for kind in request owner admin bounces confirm join \
58                       leave subscribe unsubscribe; do
59               echo "INSERT INTO mail_domain
60                          VALUES ('mailman-${kind}@${FQDN}',
61                                  'mailman-${kind}_${FQDN}', 2000, 0, 1);"
62               echo "INSERT INTO mail_alias
63                          VALUES ('mailman-${kind}_${FQDN}',
64                                  '\"| $MAILMAN_SCRIPT ${kind} mailman\"');"
65           done
66         ) | mysql -f -u"$MYSQL_USER" -p"$MYSQL_PASS" -h"$MYSQL_HOST" \
67               "$MYSQL_DATABASE" || true
68     fi
69
70     # Refresh apache configuration
71     configure /etc/alternc/templates/apache/httpd.conf
72     configure /etc/alternc/templates/apache-ssl/httpd.conf
73     ln -sf /usr/lib/cgi-bin/mailman /var/alternc/cgi-bin/mailman
74     alternc.install
75
76     # Process the language compilation.
77     /usr/share/alternc/install/dopo.sh
78
79     # ADD Mailman menu item :
80     if ! grep -q "^menu_mailman.php$" "$MENUFILE"; then
81         rm -f $MENUFILE.alternc_mailman
82         sed -e "s/menu_ftp.php/&\\
83 menu_mailman.php/" <$MENUFILE >$MENUFILE.alternc_mailman
84         mv -f $MENUFILE.alternc_mailman $MENUFILE
85     fi
86     ;;
87
88   abort-upgrade|abort-remove|abort-deconfigure)
89     ;;
90
91   *)
92     echo "postinst called with unknown argument \`$1'" >&2
93     exit 1
94     ;;
95 esac
96
97 # dh_installdeb will replace this with shell code automatically
98 # generated by other debhelper scripts.
99 #DEBHELPER#
100
101 # vim: et sw=4
102
Note: See TracBrowser for help on using the browser.