Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > a10d635066162e7205b635e128a00462 > scriptlet

mailman-2.1.27-1.mga6.armv5tl.rpm

PREIN

/bin/sh
if [ $1 = "2" ]; then
  if [ ! -L /usr/lib/mailman/Mailman/mm_cfg.py ]; then
    mv /usr/lib/mailman/Mailman/mm_cfg.py /etc/mailman.tmp
  fi
  if [ ! -L /var/lib/mailman/logs ]; then
    mv /var/lib/mailman/logs /var/log/mailman
  fi
fi

PREUN

/bin/sh
/usr/share/rpm-helper/del-service mailman $1 mailman

POSTIN

/bin/sh
/usr/share/rpm-helper/add-service mailman $1 mailman 


cd /usr/lib/mailman

if [ $1 = 1 ] && [ -z "$DURING_INSTALL" ]; then
    # installation

    # generic tasks
    hostname=`hostname`
    domainname=`dnsdomainname`

    if [ -z "$domainname" ]; then
        domainname=localdomain
        # Add fqdn related items to allow installation to complete without error
        # when a fqdn has not been set. This will also permit the creation of the
        # required mailman site list to complete and the mailman service to then
        # start.
        properfqdn=false
    fi
    fqdn=$hostname.$domainname

    # mailman basic configuration
    cat >>Mailman/mm_cfg.py <<EOF
DEFAULT_EMAIL_HOST = '$domainname'
DEFAULT_URL_HOST = '$hostname'
add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
#VIRTUAL_HOST_OVERVIEW=Off
EOF

    # make sure mail user is allowed to use cron
    if [ -f /etc/cron.allow ]; then
        if ! grep -q mail /etc/cron.allow; then
            echo "mail" >> /etc/cron.allow
        fi
    fi

    # add cron task
    crontab -u mail /usr/lib/mailman/cron/crontab.in

    # add aliases
    /usr/share/rpm-helper/create-file mailman $1 /var/lib/mailman/data/aliases mail mail 660 

    mta="`readlink /etc/alternatives/sendmail-command 2>/dev/null | cut -d . -f 2`"
    if [ "$mta" == "postfix" ]; then
        cat >>Mailman/mm_cfg.py <<EOF
MTA = 'Postfix'
EOF
        maps=`/usr/sbin/postconf -h alias_maps`
        postconf -e \
            "recipient_delimiter = +" \
            "unknown_local_recipient_reject_code = 550" \
            "alias_maps = $maps, hash:/var/lib/mailman/data/aliases"
        /usr/sbin/postalias /var/lib/mailman/data/aliases
    else
        cat >> /etc/aliases <<EOF
:include:   /var/lib/mailman/data/aliases
EOF
        /usr/bin/newaliases
    fi

    # generate random password
    passwd=$(/usr/share/rpm-helper/get-password 8)

    # site password
    /usr/sbin/mmsitepass $passwd > /dev/null

    if [ ! -f /var/lib/mailman/lists/mailman/config.pck ]; then
        # initial list creation and configuration
        if [ "$properfqdn" = "false" ]; then
            su mail \
                -c "/usr/sbin/newlist -a mailman@$fqdn root@$fqdn $passwd" > /dev/null
        else
            su mail \
                -c "/usr/sbin/newlist mailman root@$hostname $passwd" > /dev/null
        fi
        su mail \
            -c "/usr/sbin/config_list -i /var/lib/mailman/data/sitelist.cfg mailman"
    fi

else
    # upgrade
    if [ -f /etc/mailman.tmp ]; then
        mv -f /etc/mailman.tmp /etc/mailman
    fi
fi

POSTUN

/bin/sh
if [ $1 = 0 ]; then
    # generic tasks

    # remove cron task and the now empty file in cron.d
    crontab -u mail -r
    rm -f /etc/cron.d/mailman

    # remove aliases
    mta="`readlink /etc/alternatives/sendmail-command 2>/dev/null | cut -d . -f 2`"
    if [ "$mta" == "postfix" ]; then
        database=`/usr/sbin/postconf -h alias_database | \
            sed -e 's|, hash:/var/lib/mailman/data/aliases||'`
        maps=`/usr/sbin/postconf -h alias_maps | \
            sed -e 's|, hash:/var/lib/mailman/data/aliases||'`
        postconf -e \
            "alias_database = $database" \
            "alias_maps = $maps"
    else
        sed -i -e '/:include:   /var/lib/mailman/data/aliases/d' \
            /etc/aliases
    fi
    /usr/bin/newaliases

    # remove other remaining associated files
    rm -fR /usr/lib/mailman
    rm -fR /var/log/mailman
fi