#!/bin/bash
# 2003-12-21
# Thomas Chung <tchung@openwebmail.org>
# Upgrade Notes - Some of the virus scanner "wrapper" and "autoupdate" scripts have been updated in new version. 
# If upgrading from earlier versions using the RPM distributions, you will need to manually rename each of the 
#  /usr/lib/MailScanner/*.rpmnew files over the top of the old scripts in the same directory

echo "renaming new scripts to current scripts..."
cd /usr/lib/MailScanner
if [ -f *.rpmnew ]; then
  for NEW in *-wrapper.rpmnew *-autoupdate.rpmnew
  do
     echo $NEW ...
     F=`echo $NEW | sed -e 's/\.rpmnew//'`
     [ -f $F ] && mv -f $F ${F}.rpmold
     mv -f $NEW $F
  done
else
  echo "no new updated scripts were found."
fi

echo "upgrading to new MailScanner config..."
cd /etc/MailScanner
/usr/sbin/upgrade_MailScanner_conf MailScanner.conf MailScanner.conf.rpmnew > MailScanner.new
mv MailScanner.conf MailScanner.old
mv MailScanner.new  MailScanner.conf

echo "stopping sendmail and starting MailScanner..."
service sendmail stop
chkconfig sendmail off
chkconfig --level 2345 MailScanner on
service MailScanner start

echo "Done!"

