Changeset 1237 for trunk/debian/postinst


Ignore:
Timestamp:
03/11/06 16:09:50 (7 years ago)
Author:
lunar
Message:

r88@sud: lunar | 2006-03-11 15:14:54 +0100
Major cleanup on a debian packaging POV


  • Adapt package to 0.9.4 configuration files (for alternc.install and menufile.txt) and bump dependency accordingly.
  • Add mysql-client to Depends field (used in debian scripts)
  • Now store Mailman configuration file template in /etc/alternc/templates/mailman/mm_cfg.py
  • Remove unneeded use of debconf:

alternc is in pre-depends, and its configuration file is sourced in
postinst script. This script use a '-e' shell, and will then fail if
it is unable to read the configuration file.

  • Add a warning about modifying /etc/mailman/mm_cfg.py directly.
  • Major overhaul of postinst script:

o Fix apache configuration template condition. o Uses alternc.install to update apache configuration files against

modified templates.

o Generated Mailman configuration is now backuped in /var/backups/alternc

in order to prevent overwrite of user modification (despite the
warning).
The postinst script will fail in this case, displaying a message telling
the user how to correct the situation.

o Automatically creates the "mailman" list (a.k.a site list) if it

doesn't exist. (Closes: #157, #365, #560)

  • Overhaul of postrm script too:

o Adapt to 0.9.4 configuration style.
o Drop mailman table on purge. (Closes: #224)

  • Cleanup of debian/rules
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debian/postinst

    r1219 r1237  
    1 #!/bin/sh -e 
     1#!/bin/sh 
    22 
    3 # Cette fonction regarde si un fichier de config ($1) a déjà reçu une modif 
    4 # de config, et sinon, lui ajoute la ligne voulue là où la balise le demande. 
     3set -e 
     4 
     5CONFIGFILE="/etc/alternc/local.sh" 
     6MENUFILE="/etc/alternc/menulist.txt" 
     7MAILMAN_SCRIPT="/var/lib/mailman/mail/mailman" 
     8MAILMAN_CONFIG="/etc/mailman/mm_cfg.py" 
     9MAILMAN_CONFIG_TEMPLATE="/etc/alternc/templates/mailman/mm_cfg.py" 
     10MAILMAN_CONFIG_BACKUP="/var/backups/alternc/etc-mailman-mm_cfg.py" 
     11MAILMAN_SCRIPT="/var/lib/mailman/mail/mailman" 
     12 
     13# Add mailman aliases to the apache configuration file given as argument 
    514function configure { 
    6     if grep -vqs "\*\*\*MAILMAN\*\*\*" $1 
    7         then 
    8     # 1. on déplace le fichier 
    9         rm -f $1.alternc_mailman 
     15    if ! grep -Eq "\*\*\*MAILMAN\*\*\*" $1; then 
     16        cp -a -f $1.tmp 
    1017        sed -e "s/\*\*\*ALTERNC_ALIASES\*\*\*/&\\ 
    1118            # ***MAILMAN*** \\ 
    1219        Alias \/marchives\/ \/var\/lib\/mailman\/archives\/public\/ \\ 
    13         Alias \/mimages\/ \/usr\/share\/images\/mailman\//" <$1 >$1.alternc_mailman 
    14         mv -f $1.alternc_mailman $1 
     20        Alias \/mimages\/ \/usr\/share\/images\/mailman\//" < $1 > $1.tmp 
     21        mv -f $1.tmp $1 
    1522    fi 
    1623} 
    1724 
    1825 
     26case "$1" in 
     27  configure) 
     28    . "$CONFIGFILE" 
    1929 
    20 if [ "$1" = "configure" ] 
    21     then 
    22     QUIT=0 
    23     # is "AlternC" package properly installed ? 
    24     if [ -f /etc/alternc/alternc.conf ] 
    25     then 
    26         # is Alternc package properly CONFIGURED by the user ? 
    27         (grep "^exit" /etc/alternc/alternc.conf) || (QUIT=1) 
    28     else  
    29        QUIT=1 
     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 
    3043    fi 
    31     if [ ! -f /etc/alternc/local.sh ] 
    32     then 
    33        QUIT=1 
     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 
    3468    fi 
    3569 
     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 
    3675 
    37     if [ $QUIT -eq 0 ] 
    38         then 
    39         # Oui : on peut créer la table mailman tout de suite 
    40         . /etc/alternc/local.sh 
    41         echo "Installing mysql table" 
    42         mysql -u"$MYSQL_USER" -p"$MYSQL_PASS" -h"$MYSQL_HOST" "$MYSQL_DATABASE" </usr/share/alternc/install/mailman.sql || true 
    43         # on modifie le httpd.conf d'apache et d'apache-ssl (déjà installés) 
    44         echo "Configuring apache" 
    45         configure /etc/apache/httpd.conf 
    46         echo "Configuring apache-ssl" 
    47         configure /etc/apache-ssl/httpd.conf 
    48         echo "Configuration AlternC" 
    49         # On modifie /usr/share/alternc/install/etc/apache et apache-ssl 
    50         # uniquement si besoin. 
    51         configure /usr/share/alternc/install/etc/apache/httpd.conf 
    52         configure /usr/share/alternc/install/etc/apache-ssl/httpd.conf 
    53         # On crée le fichier mm_cfg.py dans /etc/mailman :  
    54         echo "Création du fichier de config mailman" 
    55         sed -e "s/%%fqdn%%/$FQDN/" </usr/share/alternc/install/etc/mailman/mm_cfg.py >/etc/mailman/mm_cfg.py 
    56         # Process the language compilation. 
    57         /usr/share/alternc/install/dopo.sh 
    58         ln -sf /usr/lib/cgi-bin/mailman /var/alternc/cgi-bin/mailman 
    59         # ADD Mailman menu item :  
    60         MENUFILE=/var/alternc/bureau/admin/menulist.txt 
    61         if grep -vqs "menu_mailman" $MENUFILE 
    62         then 
    63             rm -f $MENUFILE.alternc_mailman 
    64             sed -e "s/menu_ftp.php/&\\ 
     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/&\\ 
    6583menu_mailman.php/" <$MENUFILE >$MENUFILE.alternc_mailman 
    66             mv -f $MENUFILE.alternc_mailman $MENUFILE 
    67         fi 
    68         # Set nonexec on list creation / deletion via cgi-bin 
    69         chmod 0 /usr/lib/cgi-bin/mailman/create  /usr/lib/cgi-bin/mailman/rmlist || true 
    70         /etc/init.d/apache restart 
    71         /etc/init.d/apache-ssl restart 
    72     else  
    73         # Source debconf library. 
    74         . /usr/share/debconf/confmodule 
    75         db_version 2.0 
    76         db_title AlternC-Mailman 
    77         db_fset alternc-mailman/errorinstall seen false 
    78         db_input medium alternc-mailman/errorinstall 
    79         db_go 
    80         # il FAUT qu'AlternC soit proprement configuré pour installer mailman 
    81         exit 1 
     84        mv -f $MENUFILE.alternc_mailman $MENUFILE 
    8285    fi 
    83 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    ;; 
     95esac 
    8496 
    8597# dh_installdeb will replace this with shell code automatically 
    8698# generated by other debhelper scripts. 
    8799#DEBHELPER# 
     100 
     101# vim: et sw=4 
Note: See TracChangeset for help on using the changeset viewer.