Sophie

Sophie

distrib > Mandriva > 2006.0 > x86_64 > media > updates > by-pkgid > 996fce5acfdab232f87c3d091badb3a2 > scriptlet

mailman-2.1.6-6.4.20060mdk.x86_64.rpm

PREIN

/bin/sh
if [ $1 = "2" ]; then
  if [ ! -L /usr/lib64/mailman/Mailman/mm_cfg.py ]; then
    mv /usr/lib64/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 
if [ $1 = 1 ]; then
    # installation: restart web server if running,
    # as there is a new configuration file
    /sbin/service httpd condrestart
fi

cd /usr/lib64/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/lib64/mailman/cron/crontab.in

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

  # mta specific tasks
  if [ "$mta" == "postfix" ]; then
    cat >>Mailman/mm_cfg.py <<EOF
MTA = 'Postfix'
EOF
    maps=`/usr/sbin/postconf -h alias_maps`
    postconf -e \
    	"owner_request_special = no" \
    	"recipient_delimiter = +" \
    	"alias_maps = $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/lib64/mailman/bin
    echo 'Running kernel-secure, executing'
    echo '/usr/lib64/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/sbin/mmsitepass $passwd > /dev/null

  # initial list creation
  su mail -c "/usr/sbin/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
/sbin/service httpd condrestart
if [ $1 = 0 ]; then
  # generic tasks

  # remove cron task
  crontab -u mail -r

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

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