#!/bin/sh

#
#   MailScanner - SMTP E-Mail Virus Scanner
#   Copyright (C) 2002  Julian Field
#
#   $Id: update_phishing_sites,v 1.1.2.4 2005/11/09 14:58:36 jkf Exp $
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#   The author, Julian Field, can be contacted by email at
#      Jules@JulianField.net
#   or by paper mail at
#      Julian Field
#      Dept of Electronics & Computer Science
#      University of Southampton
#      Southampton
#      SO17 1BJ
#      United Kingdom
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/etc:/usr/local/bin
export PATH

if [ -d /usr/local/etc/MailScanner ]; then
    cd /usr/local/etc/MailScanner
else
    logger -p mail.warn -t update.phishing.sites Cannot find MailScanner configuration directory, update failed.
    echo Cannot find MailScanner configuration directory.
    echo Auto-updates of phishing.safe.sites.conf will not happen.
    exit 1
fi

wget http://www.mailscanner.info/phishing.safe.sites.conf.master || \
curl -O http://www.mailscanner.info/phishing.safe.sites.conf.master || \
( logger -p mail.warn -t update.phishing.sites Cannot find wget or curl, update failed. ; echo Cannot find wget or curl to do phishing sites update. ; exit 1 )

if [ -s phishing.safe.sites.conf.master ]; then
    cat phishing.safe.sites.conf.master phishing.safe.sites.conf | \
    sort | uniq > phishing.safe.sites.conf.new
    cp -f phishing.safe.sites.conf phishing.safe.sites.conf.old
    mv -f phishing.safe.sites.conf.new phishing.safe.sites.conf
    chmod a+r phishing.safe.sites.conf
    logger -p mail.info -t update.phishing.sites Phishing safe sites list updated
else
    logger -p mail.info -t update.phishing.sites Phishing safe sites list update failed!
fi
rm -f phishing.safe.sites.conf.master

exit 0

