v5/common/usr/sbin/ms-update-safe-sites

72 lines
2.9 KiB
Text
Raw Normal View History

2016-04-28 18:38:13 +08:00
#!/usr/bin/env bash
#
# MailScanner - SMTP E-Mail Virus Scanner
# Copyright (C) 2002 Julian Field
#
# $Id: update_phishing_sites 3982 2007-06-26 09:00:39Z sysjkf $
#
# 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
#
#
# set your options here
#
#CONFIGDIR='/opt/MailScanner/etc';
CONFIGDIR='/etc/MailScanner';
THEURL='http://phishing.mailscanner.info/phishing.safe.sites.conf';
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/sfw/bin
export PATH
if [ -d $CONFIGDIR ]; then
cd $CONFIGDIR
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
# check for the custom config file and create if missing
if [ ! -f $CONFIGDIR/phishing.safe.sites.custom ]; then
echo '# Add your custom Phishing safe sites to the' >> $CONFIGDIR/phishing.safe.sites.custom
echo '# phishing.safe.sites.custom file in your MailScanner' >> $CONFIGDIR/phishing.safe.sites.custom
echo '# directory. Note that phishing.safe.sites.conf is' >> $CONFIGDIR/phishing.safe.sites.custom
echo '# overwritten when update_phishing_sites is executed.' >> $CONFIGDIR/phishing.safe.sites.custom
echo '#' >> $CONFIGDIR/phishing.safe.sites.custom
echo 'mailscanner.info' >> $CONFIGDIR/phishing.safe.sites.custom
fi
curl --compressed -o $CONFIGDIR/phishing.safe.sites.conf.master $THEURL || \
wget --no-check-certificate -O $CONFIGDIR/phishing.safe.sites.conf.master $THEURL || \
( 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.custom phishing.safe.sites.conf.master | \
uniq > phishing.safe.sites.conf.new
rm -f phishing.safe.sites.conf
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