###############################################################################
# Copyright 2004-2020, Way to the Web Limited
# URL: http://www.configserver.com
# Email: sales@waytotheweb.com
###############################################################################


Installation and Upgrading (cPanel)
===================================

1. Download the tarball:

cd /usr/src
rm -fv msinstall*
wget https://download.configserver.com/msinstall.tar.gz
tar -xzf msinstall.tar.gz
cd msinstall/
sh install.sh
/usr/mscpanel/mscheck.pl
/usr/msfe/msrules.pl -i

2. Disable the following options in WHM:

WHM > Tweak Settings > Uncheck "Apache SpamAssassin Spam Filter" and "Apache SpamAssassin Spam Box" 
WHM > Service Manager > Uncheck both boxes for "Apache SpamAssassin" and click "Save"

3. MailScanner can be configured by editing the file /usr/mailscanner/etc/MailScanner.conf or via the ConfigServer MSFE UI. There are detailed explanations and instructions in that file. Be sure to restart MailScanner after making modifications to this file

4. If purchased, install MSFE:
https://www.configserver.com/cp/msfeinstaller.html

5. Modify /etc/csf/csf.pignore and add:
pcmd:MailScanner:.*

6. Restart lfd:
service lfd restart


Installation (DirectAdmin)
==========================
# Note: This application will NOT function on DirectAdmin servers without our MailScanner Front-End product.

# Please ensure that exim is at least v4.93:

exim -bV

If it is older, you must update to the latest exim release:
/usr/local/directadmin/custombuild/build update
/usr/local/directadmin/custombuild/build set exim yes
/usr/local/directadmin/custombuild/build build exim

1. Prepare the server by installing and configuring the required modules:

chattr -ia /etc/exim.conf
/usr/local/directadmin/custombuild/build set spamd no
/usr/local/directadmin/custombuild/build remove_spamassassin
/usr/local/directadmin/custombuild/build remove_rspamd
/usr/local/directadmin/custombuild/build remove_rspamd_conf
/usr/local/directadmin/custombuild/build set easy_spam_fighter no
/usr/local/directadmin/custombuild/build remove_easy_spam_fighter
rpm -e spamassassin

systemctl stop rspamd
systemctl disable rspamd

/usr/local/directadmin/custombuild/build set clamav_exim no
mv -fv /etc/exim.clamav.load.conf /etc/exim.clamav.load.conf.disabled

/usr/local/directadmin/custombuild/build set eximconf no

# Take a backup copy of the following files as they may be modified or overwritten:
/etc/exim.conf
/etc/exim.clamav.load.conf
/usr/local/directadmin/data/templates/filter_spamfolder
/usr/local/directadmin/data/templates/filter_userspamfolder
/usr/local/directadmin/data/templates/custom/filter_spamfolder
/usr/local/directadmin/data/templates/custom/filter_userspamfolder

CentOS/CloudLinux v7
--------->
yum install epel-release
yum-config-manager --enable repo

yum install spamassassin gd gd-devel perl-Filesys-Df perl-IO-stringy.noarch perl-Sys-Hostname-Long.noarch perl-Net-CIDR.noarch perl-Sys-SigAction.noarch perl-MIME-tools.noarch perl-Convert-TNEF.noarch perl-OLE-Storage_Lite.noarch perl-DateTime perl-DBD-MySQL perl-DBD-SQLite perl-GDGraph perl-Path-Tiny perl-Archive-Zip perl-CGI perl-JSON perl-Razor-Agent perl-ExtUtils-Embed perl-DBI perl-Perl4-CoreLibs perl-libwww-perl perl-LWP-Protocol-https
<---------


CentOS/AlmaLinux v8
--------->
yum install epel-release

yum install 'dnf-command(config-manager)'
yum config-manager --set-enabled PowerTools
yum config-manager --set-enabled powertools

yum install perl-DateTime

yum install spamassassin gd gd-devel perl-Filesys-Df perl-IO-stringy.noarch perl-Net-CIDR.noarch perl-MIME-tools.noarch perl-Convert-TNEF.noarch perl-OLE-Storage_Lite.noarch perl-DBD-MySQL perl-DBD-SQLite perl-GDGraph perl-Path-Tiny perl-Archive-Zip perl-CGI perl-JSON perl-Razor-Agent perl-ExtUtils-Embed perl-DBI perl-libwww-perl perl-App-cpanminus perl-LWP-Protocol-https

cpanm install Sys::Hostname::Long
cpanm install Sys::SigAction
<---------


CloudLinux v8 (one line at a time here)
--------->
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum install perl-Mail-DKIM
yum install perl-Mail-SPF
cpanm Filesys::Df Net::CIDR Convert::TNEF OLE::Storage_Lite DateTime GD::Graph Razor::Agent Convert::BinHex

yum install perl-DateTime

yum config-manager --set-enabled cloudlinux-PowerTools

yum install epel-release

yum config-manager --set-enabled epel

yum install spamassassin gd gd-devel perl-Filesys-Df perl-IO-stringy.noarch perl-Net-CIDR.noarch perl-MIME-tools.noarch perl-Convert-TNEF.noarch perl-OLE-Storage_Lite.noarch perl-DBD-MySQL perl-DBD-SQLite perl-GDGraph perl-Path-Tiny perl-Archive-Zip perl-CGI perl-JSON perl-Razor-Agent perl-ExtUtils-Embed perl-DBI perl-libwww-perl perl-App-cpanminus

cpanm install Sys::Hostname::Long
cpanm install Sys::SigAction
cpanm install LWP::Protocol::https
<---------


AlmaLinux v9 (one line at a time here)
--------->
yum install epel-release

yum install 'dnf-command(config-manager)'
yum config-manager --set-enabled crb

yum install perl-DateTime

yum install spamassassin gd gd-devel perl-Filesys-Df perl-IO-stringy.noarch perl-Net-CIDR.noarch perl-MIME-tools.noarch perl-Convert-TNEF.noarch perl-OLE-Storage_Lite.noarch perl-DBD-MySQL perl-DBD-SQLite perl-GDGraph perl-Path-Tiny perl-Archive-Zip perl-CGI perl-JSON perl-Razor-Agent perl-ExtUtils-Embed perl-DBI perl-libwww-perl perl-App-cpanminus perl-LWP-Protocol-https

cpanm install Sys::Hostname::Long
cpanm install Sys::SigAction
cpanm install GD::Graph
<---------


Ubuntu/Debian
--------->

apt install spamassassin libgd-dev libfilesys-df-perl libio-stringy-perl libsys-hostname-long-perl libnet-cidr-perl libsys-sigaction-perl libmime-tools-perl libconvert-tnef-perl libole-storage-lite-perl libdatetime-perl libdbd-mysql-perl libdbd-sqlite3-perl libgd-graph-perl libtypes-path-tiny-perl libarchive-zip-perl libcgi-pm-perl libjson-perl razor  libdbi-perl libperl4-corelibs-perl libwww-perl liblwp-protocol-https-perl

ln -s /var/lib/mysql/mysql.sock /var/run/mysqld/mysqld.sock

If you are unable to use mysql.sock, you can force MSFE to use MySQL on 127.0.0.1 TCP port 3306 instead by creating a touch file:

touch /usr/msfe/mailcontrol/mysql.sock.disable

apt reinstall spamassassin
<---------

2. Installed ClamAV:

a. EITHER: You can install through EPEL (recommended):

--------->
yum -y install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd

sed -i -e "s/^Example/#Example/" /etc/clamd.d/scan.conf
sed -i -e "s/^Example/#Example/" /etc/freshclam.conf

# Now edit /etc/clamd.d/scan.conf and change:
User root
LocalSocket /var/run/clamd.scan/clamd.sock
FixStaleSocket yes

# Now update, start and enable clamd:
freshclam
systemctl enable clamd@scan
systemctl restart clamd@scan

# You will then need to wait until clamd has fully started and created the
# socket at:

chmod 755 /var/run/clamd.scan/
chmod 755 /var/run/clamd/

# wait for it to restart and create /var/run/clamd.socket
ls -la /var/run/clamd.scan/clamd.sock
<---------

b. OR: You can use the DirectAdmin supplied ClamAV build through custombuild:

--------->
/usr/local/directadmin/custombuild/build set clamav yes
/usr/local/directadmin/custombuild/build set clamav_exim no
/usr/local/directadmin/custombuild/build clamav

# Now edit /etc/clamd.d/scan.conf and change:
User root
LocalSocket /run/clamd.socket
FixStaleSocket yes
LocalSocketMode 666

# Edit /etc/systemd/system/multi-user.target.wants/clamd@scan.service and change to:
PrivateTmp = false

chmod 755 /var/run/clamd/
service clamd restart

# wait for it to restart and create /run/clamd.socket
ls -la /run/clamd.socket
<---------

3. Install MailScanner:

cd /usr/src
rm -fv msinstall*
wget https://download.configserver.com/msinstall.tar.gz
tar -xzf msinstall.tar.gz
cd msinstall/
sh install.sh

4. Install MSFE once purchased (required on DirectAdmin for this installer to work):

cd /usr/src/
rm -fv msfe*
wget https://download.configserver.com/msfeinstaller.tgz
tar -xzf msfeinstaller.tgz
perl msfeinstaller.pl ipv4
rm -fv msfeinstaller*
/usr/mscpanel/mscheck.pl
/usr/mscpanel/msrules.pl -i

5. Check MailScanner has the right setting for the clamd socket (LocalSocket from the configuration of ClamAV above):

# Now edit: /usr/mailscanner/etc/MailScanner.conf

# For example:
Clamd Socket = /var/run/clamd.scan/clamd.sock

6. Make sure Exim isn't already scanning using ClamAV:

/usr/local/directadmin/custombuild/build set clamav_exim no
mv -fv /etc/exim.clamav.load.conf /etc/exim.clamav.load.conf.disabled
service exim restart

7. Restart services and then check MailControl in UI:

service MailScanner restart
service exim restart

8. MailScanner can be configured by editing the file /usr/mailscanner/etc/MailScanner.conf or via the ConfigServer MSFE UI. There are detailed explanations and instructions in that file. Be sure to restart MailScanner after making modifications to this file

9. Modify /etc/csf/csf.pignore and add:
pcmd:MailScanner:.*

10. Restart lfd:
service lfd restart


Upgrading (DirectAdmin)
=======================

# Upgrade MailScanner:

cd /usr/src
rm -fv msinstall*
wget https://download.configserver.com/msinstall.tar.gz
tar -xzf msinstall.tar.gz
cd msinstall/
sh install.sh

# Upgrade MSFE:

cd /usr/src/
rm -fv msfe*
wget https://download.configserver.com/msfeinstaller.tgz
tar -xzf msfeinstaller.tgz
perl msfeinstaller.pl ipv4
rm -fv msfeinstaller*
/usr/mscpanel/mscheck.pl
/usr/mscpanel/msrules.pl -i


Uninstall
=========

cd /usr/src
rm -fv msinstall*
wget https://download.configserver.com/msinstall.tar.gz
tar -xzf msinstall.tar.gz
cd msinstall/
sh uninstall.sh


Further Information
===================

ConfigServer technical FAQ:
http://www.configserver.com/techfaq/faqlist.php?catid=5

ConfigServer forums: 
http://forum.configserver.com/forumdisplay.php?f=20

MailScanner website:
http://www.mailscanner.info

MailScanner mailing list:
http://www.mailscanner.info/support.html#mailing
