Sophie

Sophie

distrib > Mandriva > 10.2 > i586 > media > main > by-pkgid > fe2b766dfe2f9c06d20313e2689f1c11 > scriptlet

mailman-2.1.5-15mdk.i586.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 ]; then
  # installation

  # generic tasks
  hostname=`hostname`

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

  # locale setup
  lang=`echo $LANGUAGE | awk -F: '{print $2}'`
  if [ "$lang" != "en" ] && [ -n "$lang" ]; then
    cat >>Mailman/mm_cfg.py <<EOF
DEFAULT_SERVER_LANGUAGE = '$lang'
EOF
  fi

  # 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

  # restart web server
  /sbin/service httpd reload

  # check mta
  mta="`readlink /etc/alternatives/mta 2>/dev/null | cut -d . -f 2`"

  # mta specific tasks
  if [ "$mta" == "postfix" ]; then
    cat >>Mailman/mm_cfg.py <<EOF
MTA = 'Postfix'
EOF
    postconf -e \
    	'owner_request_special = no' \
    	'recipient_delimiter = +' \
    	'alias_maps = '`/usr/sbin/postconf -h alias_maps`', hash:/var/lib/mailman/data/aliases'

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

  # check kernel secure
  if [ `uname -r | grep -c secure` != 0 ]; then
    echo ''
    echo '*****'
    cd /usr/lib/mailman/bin
    echo 'Running kernel-secure, executing'
    echo '/usr/lib/mailman/bin/check_perms_grsecurity.py'
    echo 'for proper mailman functionality'
    echo '*****'
    ./check_perms -f > /dev/null
    ./check_perms_grsecurity.py -f
  fi

  # generate random password
  passwd=`perl -e 'print map { (a..z,A..Z,0..9)[rand 62] } 0..8'`

  # site password
  /usr/lib/mailman/bin/mmsitepass $passwd > /dev/null

  # initial list creation
  su mail -c "/usr/lib/mailman/bin/newlist mailman root@$hostname $passwd" > /dev/null

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
  crontab -u mail -r

  # restart web server
  /sbin/service httpd reload

  # check mta
  mta="`readlink /etc/alternatives/mta 2>/dev/null | cut -d . -f 2`"

  # mta specific tasks
  if [ "$mta" == "postfix" ]; then
    postconf -e 'alias_maps = '`/usr/sbin/postconf -h alias_maps | sed -e 's|, hash:/var/lib/mailman/data/aliases||'`
  fi
fi