remove sieve configurations from mailscanner install

This commit is contained in:
Usman Nasir
2021-04-21 22:51:44 +05:00
parent 695f9b38b0
commit c166da2a69
3 changed files with 254 additions and 267 deletions

View File

@@ -2,22 +2,21 @@
#systemctl stop firewalld #systemctl stop firewalld
check_return() { check_return() {
#check previous command result , 0 = ok , non-0 = something wrong. #check previous command result , 0 = ok , non-0 = something wrong.
if [[ $? -eq "0" ]] ; then if [[ $? -eq "0" ]]; then
: :
else else
echo -e "\ncommand failed, exiting..." echo -e "\ncommand failed, exiting..."
exit exit
fi fi
} }
echo 'backup configs'; echo 'backup configs'
cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf-bak_$(date '+%Y-%m-%d_%H_%M:%S'); cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf-bak_$(date '+%Y-%m-%d_%H_%M:%S')
cp /etc/postfix/master.cf /etc/postfix/master.cf-bak_$(date '+%Y-%m-%d_%H_%M:%S'); cp /etc/postfix/master.cf /etc/postfix/master.cf-bak_$(date '+%Y-%m-%d_%H_%M:%S')
cp /etc/postfix/main.cf /etc/postfix/main.cf-bak_$(date '+%Y-%m-%d_%H_%M:%S'); cp /etc/postfix/main.cf /etc/postfix/main.cf-bak_$(date '+%Y-%m-%d_%H_%M:%S')
cp /etc/dovecot/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext-bak_$(date '+%Y-%m-%d_%H_%M:%S') cp /etc/dovecot/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext-bak_$(date '+%Y-%m-%d_%H_%M:%S')
ZONE=$(firewall-cmd --get-default-zone) ZONE=$(firewall-cmd --get-default-zone)
firewall-cmd --zone=$ZONE --add-port=4190/tcp --permanent firewall-cmd --zone=$ZONE --add-port=4190/tcp --permanent
systemctl stop firewalld systemctl stop firewalld
@@ -27,167 +26,158 @@ csf -x
MAILSCANNER=/etc/MailScanner MAILSCANNER=/etc/MailScanner
if [ -d $MAILSCANNER ];then if [ -d $MAILSCANNER ]; then
echo "MailScanner found. If you wish to reinstall then remove the package and revert"
echo "MailScanner found. If you wish to reinstall then remove the package and revert" echo "Postfix back to its original config at /etc/postfix/main.cf and remove"
echo "Postfix back to its original config at /etc/postfix/main.cf and remove" echo "/etc/MailScanner and /usr/share/MailScanner directories"
echo "/etc/MailScanner and /usr/share/MailScanner directories" exit
exit
fi fi
if [ -f /etc/os-release ];then if [ -f /etc/os-release ]; then
OS=$(head -1 /etc/os-release) OS=$(head -1 /etc/os-release)
UBUNTUVERSION=$(sed '6q;d' /etc/os-release) UBUNTUVERSION=$(sed '6q;d' /etc/os-release)
CENTOSVERSION=$(sed '5q;d' /etc/os-release) CENTOSVERSION=$(sed '5q;d' /etc/os-release)
CLNVERSION=$(sed '3q;d' /etc/os-release) CLNVERSION=$(sed '3q;d' /etc/os-release)
fi fi
if [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ];then if [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ]; then
setenforce 0 setenforce 0
yum install -y perl yum-utils perl-CPAN yum install -y perl yum-utils perl-CPAN
yum install -y gcc cpp perl bzip2 zip make patch automake rpm-build perl-Archive-Zip perl-Filesys-Df perl-OLE-Storage_Lite perl-Sys-Hostname-Long perl-Sys-SigAction perl-Net-CIDR perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib unzip zlib-devel wget mlocate clamav "perl(DBD::mysql)" yum install -y gcc cpp perl bzip2 zip make patch automake rpm-build perl-Archive-Zip perl-Filesys-Df perl-OLE-Storage_Lite perl-Sys-Hostname-Long perl-Sys-SigAction perl-Net-CIDR perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib unzip zlib-devel wget mlocate clamav "perl(DBD::mysql)"
rpm -Uvh https://forensics.cert.org/centos/cert/7/x86_64/unrar-5.4.0-1.el7.x86_64.rpm rpm -Uvh https://forensics.cert.org/centos/cert/7/x86_64/unrar-5.4.0-1.el7.x86_64.rpm
export PERL_MM_USE_DEFAULT=1 export PERL_MM_USE_DEFAULT=1
curl -L https://cpanmin.us | perl - App::cpanminus curl -L https://cpanmin.us | perl - App::cpanminus
perl -MCPAN -e 'install Encoding::FixLatin' perl -MCPAN -e 'install Encoding::FixLatin'
perl -MCPAN -e 'install Digest::SHA1' perl -MCPAN -e 'install Digest::SHA1'
perl -MCPAN -e 'install Geo::IP' perl -MCPAN -e 'install Geo::IP'
perl -MCPAN -e 'install Razor2::Client::Agent' perl -MCPAN -e 'install Razor2::Client::Agent'
perl -MCPAN -e 'install Net::Patricia' perl -MCPAN -e 'install Net::Patricia'
freshclam -v freshclam -v
DIR=/etc/mail/spamassassin DIR=/etc/mail/spamassassin
if [ -d "$DIR" ]; then if [ -d "$DIR" ]; then
sa-update sa-update
else
echo "Please install spamassassin through the CyberPanel interface before proceeding"
exit
fi
else elif [ "$CENTOSVERSION" = "VERSION_ID=\"8\"" ]; then
echo "Please install spamassassin through the CyberPanel interface before proceeding" setenforce 0
yum install -y perl yum-utils perl-CPAN
dnf --enablerepo=powertools install -y perl-IO-stringy
dnf --enablerepo=PowerTools install -y perl-IO-stringy
yum install -y gcc cpp perl bzip2 zip make patch automake rpm-build perl-Archive-Zip perl-Filesys-Df perl-OLE-Storage_Lite perl-Net-CIDR perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib unzip zlib-devel wget mlocate clamav clamav-update "perl(DBD::mysql)"
exit rpm -Uvh https://forensics.cert.org/centos/cert/8/x86_64/unrar-5.4.0-1.el8.x86_64.rpm
fi
elif [ "$CENTOSVERSION" = "VERSION_ID=\"8\"" ];then export PERL_MM_USE_DEFAULT=1
curl -L https://cpanmin.us | perl - App::cpanminus
setenforce 0 perl -MCPAN -e 'install Encoding::FixLatin'
yum install -y perl yum-utils perl-CPAN perl -MCPAN -e 'install Digest::SHA1'
dnf --enablerepo=powertools install -y perl-IO-stringy perl -MCPAN -e 'install Geo::IP'
dnf --enablerepo=PowerTools install -y perl-IO-stringy perl -MCPAN -e 'install Razor2::Client::Agent'
yum install -y gcc cpp perl bzip2 zip make patch automake rpm-build perl-Archive-Zip perl-Filesys-Df perl-OLE-Storage_Lite perl-Net-CIDR perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib unzip zlib-devel wget mlocate clamav clamav-update "perl(DBD::mysql)" perl -MCPAN -e 'install Sys::Hostname::Long'
perl -MCPAN -e 'install Sys::SigAction'
rpm -Uvh https://forensics.cert.org/centos/cert/8/x86_64/unrar-5.4.0-1.el8.x86_64.rpm freshclam -v
export PERL_MM_USE_DEFAULT=1 DIR=/etc/mail/spamassassin
curl -L https://cpanmin.us | perl - App::cpanminus
perl -MCPAN -e 'install Encoding::FixLatin' if [ -d "$DIR" ]; then
perl -MCPAN -e 'install Digest::SHA1' sa-update
perl -MCPAN -e 'install Geo::IP' else
perl -MCPAN -e 'install Razor2::Client::Agent' echo "Please install spamassassin through the CyberPanel interface before proceeding"
perl -MCPAN -e 'install Sys::Hostname::Long' exit
perl -MCPAN -e 'install Sys::SigAction' fi
elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ]; then
setenforce 0
yum install -y perl yum-utils perl-CPAN
yum install -y gcc cpp perl bzip2 zip make patch automake rpm-build perl-Archive-Zip perl-Filesys-Df perl-OLE-Storage_Lite perl-Sys-Hostname-Long perl-Sys-SigAction perl-Net-CIDR perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib unzip zlib-devel wget mlocate clamav "perl(DBD::mysql)"
freshclam -v rpm -Uvh https://forensics.cert.org/centos/cert/7/x86_64/unrar-5.4.0-1.el7.x86_64.rpm
export PERL_MM_USE_DEFAULT=1
curl -L https://cpanmin.us | perl - App::cpanminus
perl -MCPAN -e 'install Encoding::FixLatin'
perl -MCPAN -e 'install Digest::SHA1'
perl -MCPAN -e 'install Geo::IP'
perl -MCPAN -e 'install Razor2::Client::Agent'
perl -MCPAN -e 'install Net::Patricia'
DIR=/etc/mail/spamassassin freshclam -v
DIR=/etc/mail/spamassassin
if [ -d "$DIR" ]; then if [ -d "$DIR" ]; then
sa-update sa-update
else else
echo "Please install spamassassin through the CyberPanel interface before proceeding" echo "Please install spamassassin through the CyberPanel interface before proceeding"
exit exit
fi fi
elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ];then elif [ "$OS" = "NAME=\"Ubuntu\"" ]; then
setenforce 0 apt-get install -y libmysqlclient-dev
yum install -y perl yum-utils perl-CPAN
yum install -y gcc cpp perl bzip2 zip make patch automake rpm-build perl-Archive-Zip perl-Filesys-Df perl-OLE-Storage_Lite perl-Sys-Hostname-Long perl-Sys-SigAction perl-Net-CIDR perl-DBI perl-MIME-tools perl-DBD-SQLite binutils glibc-devel perl-Filesys-Df zlib unzip zlib-devel wget mlocate clamav "perl(DBD::mysql)"
rpm -Uvh https://forensics.cert.org/centos/cert/7/x86_64/unrar-5.4.0-1.el7.x86_64.rpm apt-get install -y cpanminus gcc perl bzip2 zip make patch automake rpm libarchive-zip-perl libfilesys-df-perl libole-storage-lite-perl libsys-hostname-long-perl libsys-sigaction-perl libregexp-common-net-cidr-perl libmime-tools-perl libdbd-sqlite3-perl binutils build-essential libfilesys-df-perl zlib1g unzip mlocate clamav libdbd-mysql-perl unrar libclamav-dev libclamav-client-perl libclamunrar9
export PERL_MM_USE_DEFAULT=1
curl -L https://cpanmin.us | perl - App::cpanminus
perl -MCPAN -e 'install Encoding::FixLatin'
perl -MCPAN -e 'install Digest::SHA1'
perl -MCPAN -e 'install Geo::IP'
perl -MCPAN -e 'install Razor2::Client::Agent'
perl -MCPAN -e 'install Net::Patricia'
freshclam -v cpanm Encoding::FixLatin
DIR=/etc/mail/spamassassin cpanm Digest::SHA1
cpanm Geo::IP
cpanm Razor2::Client::Agent
cpanm Net::Patricia
cpanm Net::CIDR
if [ -d "$DIR" ]; then sudo systemctl stop clamav-freshclam.service
sa-update
else freshclam
echo "Please install spamassassin through the CyberPanel interface before proceeding" sudo systemctl start clamav-freshclam.service
exit DIR=/etc/spamassassin
fi if [ -d "$DIR" ]; then
elif [ "$OS" = "NAME=\"Ubuntu\"" ];then apt-get -y install razor pyzor libencode-detect-perl libgeo-ip-perl libnet-patricia-perl
sa-update
apt-get install -y libmysqlclient-dev else
echo "Please install spamassassin through the CyberPanel interface before proceeding"
apt-get install -y cpanminus gcc perl bzip2 zip make patch automake rpm libarchive-zip-perl libfilesys-df-perl libole-storage-lite-perl libsys-hostname-long-perl libsys-sigaction-perl libregexp-common-net-cidr-perl libmime-tools-perl libdbd-sqlite3-perl binutils build-essential libfilesys-df-perl zlib1g unzip mlocate clamav libdbd-mysql-perl unrar libclamav-dev libclamav-client-perl libclamunrar9 exit
fi
cpanm Encoding::FixLatin
cpanm Digest::SHA1
cpanm Geo::IP
cpanm Razor2::Client::Agent
cpanm Net::Patricia
cpanm Net::CIDR
sudo systemctl stop clamav-freshclam.service
freshclam
sudo systemctl start clamav-freshclam.service
DIR=/etc/spamassassin
if [ -d "$DIR" ]; then
apt-get -y install razor pyzor libencode-detect-perl libgeo-ip-perl libnet-patricia-perl
sa-update
else
echo "Please install spamassassin through the CyberPanel interface before proceeding"
exit
fi
fi fi
echo "header_checks = regexp:/etc/postfix/header_checks" >> /etc/postfix/main.cf echo "header_checks = regexp:/etc/postfix/header_checks" >>/etc/postfix/main.cf
echo "/^Received:/ HOLD" >> /etc/postfix/header_checks echo "/^Received:/ HOLD" >>/etc/postfix/header_checks
systemctl restart postfix systemctl restart postfix
if [ "$OS" = "NAME=\"Ubuntu\"" ];then if [ "$OS" = "NAME=\"Ubuntu\"" ]; then
wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.noarch.deb wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.noarch.deb
dpkg -i *.noarch.deb dpkg -i *.noarch.deb
mkdir /var/run/MailScanner mkdir /var/run/MailScanner
mkdir /var/lock/subsys mkdir /var/lock/subsys
mkdir /var/lock/subsys/MailScanner mkdir /var/lock/subsys/MailScanner
chown -R postfix:postfix /var/run/MailScanner chown -R postfix:postfix /var/run/MailScanner
chown -R postfix:postfix /var/lock/subsys/MailScanner chown -R postfix:postfix /var/lock/subsys/MailScanner
chown -R postfix:postfix /var/spool/MailScanner chown -R postfix:postfix /var/spool/MailScanner
elif [ "$OS" = "NAME=\"CentOS Linux\"" ];then elif [ "$OS" = "NAME=\"CentOS Linux\"" ]; then
wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.rhel.noarch.rpm wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.rhel.noarch.rpm
rpm -Uvh *.rhel.noarch.rpm rpm -Uvh *.rhel.noarch.rpm
elif [ "$OS" = "NAME=\"CloudLinux\"" ];then elif [ "$OS" = "NAME=\"CloudLinux\"" ]; then
wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.rhel.noarch.rpm wget https://github.com/MailScanner/v5/releases/download/5.3.3-1/MailScanner-5.3.3-1.rhel.noarch.rpm
rpm -Uvh *.rhel.noarch.rpm rpm -Uvh *.rhel.noarch.rpm
fi fi
mkdir /var/spool/MailScanner/spamassassin mkdir /var/spool/MailScanner/spamassassin
@@ -234,8 +224,8 @@ PASSWORD=$(cat /etc/cyberpanel/mysqlPassword)
USER=root USER=root
DATABASE=mailscanner DATABASE=mailscanner
ADMINPASS=$(cat /etc/cyberpanel/adminPass) ADMINPASS=$(cat /etc/cyberpanel/adminPass)
mysql -u${USER} -p${PASSWORD} < "/usr/local/CyberCP/public/mailwatch/create.sql" mysql -u${USER} -p${PASSWORD} <"/usr/local/CyberCP/public/mailwatch/create.sql"
mysql -u${USER} -p${PASSWORD} -e "use mailscanner"; mysql -u${USER} -p${PASSWORD} -e "use mailscanner"
mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "GRANT ALL ON mailscanner.* TO root@localhost IDENTIFIED BY '${PASSWORD}';" mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "GRANT ALL ON mailscanner.* TO root@localhost IDENTIFIED BY '${PASSWORD}';"
mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "FLUSH PRIVILEGES;" mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "FLUSH PRIVILEGES;"
mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "INSERT INTO mailscanner.users SET username = 'admin', password = MD5('${ADMINPASS}'), fullname = 'admin', type = 'A';" mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "INSERT INTO mailscanner.users SET username = 'admin', password = MD5('${ADMINPASS}'), fullname = 'admin', type = 'A';"
@@ -247,11 +237,11 @@ sed -i "s/^define('DB_PASS',.*/define('DB_PASS','${PASSWORD}');/" /usr/local/Cyb
sed -i "s/^define('MAILWATCH_HOME',.*/define(\'MAILWATCH_HOME\', \'\/usr\/local\/CyberCP\/public\/mailwatch\/mailscanner');/" /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php sed -i "s/^define('MAILWATCH_HOME',.*/define(\'MAILWATCH_HOME\', \'\/usr\/local\/CyberCP\/public\/mailwatch\/mailscanner');/" /usr/local/CyberCP/public/mailwatch/mailscanner/conf.php
MSDEFAULT=/etc/MailScanner/defaults MSDEFAULT=/etc/MailScanner/defaults
if [ -f "$MSDEFAULT" ];then if [ -f "$MSDEFAULT" ]; then
sed -i 's/^run_mailscanner=.*/run_mailscanner=1/' /etc/MailScanner/defaults sed -i 's/^run_mailscanner=.*/run_mailscanner=1/' /etc/MailScanner/defaults
elif [ ! -f "$MSDEFAULT" ];then elif [ ! -f "$MSDEFAULT" ]; then
touch /etc/MailScanner/defaults touch /etc/MailScanner/defaults
echo "run_mailscanner=1" >> /etc/MailScanner/defaults echo "run_mailscanner=1" >>/etc/MailScanner/defaults
fi fi
cp /usr/local/CyberCP/public/mailwatch/MailScanner_perl_scripts/MailWatchConf.pm /usr/share/MailScanner/perl/custom/ cp /usr/local/CyberCP/public/mailwatch/MailScanner_perl_scripts/MailWatchConf.pm /usr/share/MailScanner/perl/custom/
@@ -268,125 +258,121 @@ systemctl restart mailscanner
IPADDRESS=$(cat /etc/cyberpanel/machineIP) IPADDRESS=$(cat /etc/cyberpanel/machineIP)
### Furhter onwards is sieve configurations
echo 'Setting up spamassassin and sieve to deliver spam to Junk folder by default' #echo 'Setting up spamassassin and sieve to deliver spam to Junk folder by default'
#echo "If you wish mailscanner/spamassassin to send spam email to a spam folder please follow the tutorial on the Cyberpanel Website" ##echo "If you wish mailscanner/spamassassin to send spam email to a spam folder please follow the tutorial on the Cyberpanel Website"
echo 'Fix protocols' #echo 'Fix protocols'
sed -i 's/^protocols =.*/protocols = imap pop3 lmtp sieve/g' /etc/dovecot/dovecot.conf #sed -i 's/^protocols =.*/protocols = imap pop3 lmtp sieve/g' /etc/dovecot/dovecot.conf
#
#sed -i "s|^user_query.*|user_query = SELECT '5000' as uid, '5000' as gid, '/home/vmail/%d/%n' as home,mail FROM e_users WHERE email='%u';|g" /etc/dovecot/dovecot-sql.conf.ext
sed -i "s|^user_query.*|user_query = SELECT '5000' as uid, '5000' as gid, '/home/vmail/%d/%n' as home,mail FROM e_users WHERE email='%u';|g" /etc/dovecot/dovecot-sql.conf.ext #
#if [ "$OS" = "NAME=\"Ubuntu\"" ]; then
if [ "$OS" = "NAME=\"Ubuntu\"" ];then # if [ "$UBUNTUVERSION" = "VERSION_ID=\"18.04\"" ]; then
if [ "$UBUNTUVERSION" = "VERSION_ID=\"18.04\"" ];then # apt-get install -y dovecot-managesieved dovecot-sieve dovecot-lmtpd net-tools pflogsumm
apt-get install -y dovecot-managesieved dovecot-sieve dovecot-lmtpd net-tools pflogsumm # elif [ "$UBUNTUVERSION" = "VERSION_ID=\"20.04\"" ]; then
elif [ "$UBUNTUVERSION" = "VERSION_ID=\"20.04\"" ];then # apt-get install -y libmysqlclient-dev
apt-get install -y libmysqlclient-dev # sed -e '/deb/ s/^#*/#/' -i /etc/apt/sources.list.d/dovecot.list
sed -e '/deb/ s/^#*/#/' -i /etc/apt/sources.list.d/dovecot.list # apt install -y dovecot-lmtpd dovecot-managesieved dovecot-sieve net-tools pflogsumm
apt install -y dovecot-lmtpd dovecot-managesieved dovecot-sieve net-tools pflogsumm # fi
fi #
#elif [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ]; then
elif [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ];then #
# yum install -y nano net-tools dovecot-pigeonhole postfix-perl-scripts
yum install -y nano net-tools dovecot-pigeonhole postfix-perl-scripts #
#elif [ "$CENTOSVERSION" = "VERSION_ID=\"8\"" ]; then
elif [ "$CENTOSVERSION" = "VERSION_ID=\"8\"" ];then #
# rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm
rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm # dnf --enablerepo=gf-plus upgrade -y dovecot23*
dnf --enablerepo=gf-plus upgrade -y dovecot23* # dnf --enablerepo=gf-plus install -y dovecot23-pigeonhole
dnf --enablerepo=gf-plus install -y dovecot23-pigeonhole # dnf install -y net-tools postfix-perl-scripts
dnf install -y net-tools postfix-perl-scripts #
#elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ]; then
elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ];then # yum install -y nano net-tools dovecot-pigeonhole postfix-perl-scripts
#fi
yum install -y nano net-tools dovecot-pigeonhole postfix-perl-scripts #
fi ## Create Sieve files
#mkdir -p /etc/dovecot/sieve/global
#touch /var/log/{dovecot-lda-errors.log,dovecot-lda.log}
# Create Sieve files #touch /var/log/{dovecot-sieve-errors.log,dovecot-sieve.log}
mkdir -p /etc/dovecot/sieve/global #touch /var/log/{dovecot-lmtp-errors.log,dovecot-lmtp.log}
touch /var/log/{dovecot-lda-errors.log,dovecot-lda.log} #touch /etc/dovecot/sieve/default.sieve
touch /var/log/{dovecot-sieve-errors.log,dovecot-sieve.log} #chown vmail: -R /etc/dovecot/sieve
touch /var/log/{dovecot-lmtp-errors.log,dovecot-lmtp.log} #chown vmail:mail /var/log/dovecot-*
touch /etc/dovecot/sieve/default.sieve #
chown vmail: -R /etc/dovecot/sieve #echo 'Create Sieve Default spam to Junk rule'
chown vmail:mail /var/log/dovecot-* #cat >>/etc/dovecot/sieve/default.sieve <<EOL
#require "fileinto";
echo 'Create Sieve Default spam to Junk rule' #if header :contains "X-Spam-Flag" "YES" {
cat >> /etc/dovecot/sieve/default.sieve <<EOL # fileinto "INBOX.Junk E-mail";
require "fileinto"; #}
if header :contains "X-Spam-Flag" "YES" { #EOL
fileinto "INBOX.Junk E-mail"; #
} #echo "Adding Sieve to /etc/dovecot/dovecot.conf"
EOL #cat >>/etc/dovecot/dovecot.conf <<EOL
#
#service managesieve-login {
echo "Adding Sieve to /etc/dovecot/dovecot.conf" # inet_listener sieve {
cat >> /etc/dovecot/dovecot.conf <<EOL # port = 4190
# }
service managesieve-login { #}
inet_listener sieve { #service managesieve {
port = 4190 #}
} #protocol sieve {
} # managesieve_max_line_length = 65536
service managesieve { # managesieve_implementation_string = dovecot
} # log_path = /var/log/dovecot-sieve-errors.log
protocol sieve { # info_log_path = /var/log/dovecot-sieve.log
managesieve_max_line_length = 65536 #}
managesieve_implementation_string = dovecot #plugin {
log_path = /var/log/dovecot-sieve-errors.log #sieve = /home/vmail/%d/%n/dovecot.sieve
info_log_path = /var/log/dovecot-sieve.log #sieve_global_path = /etc/dovecot/sieve/default.sieve
} #sieve_dir = /home/vmail/%d/%n/sieve
plugin { #sieve_global_dir = /etc/dovecot/sieve/global/
sieve = /home/vmail/%d/%n/dovecot.sieve #}
sieve_global_path = /etc/dovecot/sieve/default.sieve #protocol lda {
sieve_dir = /home/vmail/%d/%n/sieve # mail_plugins = $mail_plugins sieve quota
sieve_global_dir = /etc/dovecot/sieve/global/ # postmaster_address = postmaster@example.com
} # hostname = server.example.com
protocol lda { # auth_socket_path = /var/run/dovecot/auth-master
mail_plugins = $mail_plugins sieve quota # log_path = /var/log/dovecot-lda-errors.log
postmaster_address = postmaster@example.com # info_log_path = /var/log/dovecot-lda.log
hostname = server.example.com #}
auth_socket_path = /var/run/dovecot/auth-master #protocol lmtp {
log_path = /var/log/dovecot-lda-errors.log # mail_plugins = $mail_plugins sieve quota
info_log_path = /var/log/dovecot-lda.log # log_path = /var/log/dovecot-lmtp-errors.log
} # info_log_path = /var/log/dovecot-lmtp.log
protocol lmtp { #}
mail_plugins = $mail_plugins sieve quota #EOL
log_path = /var/log/dovecot-lmtp-errors.log #
info_log_path = /var/log/dovecot-lmtp.log #hostname=$(hostname)
} #
EOL #echo 'Fix postmaster email in sieve'
#postmaster_address=$(grep postmaster_address /etc/dovecot/dovecot.conf | sed 's/.*=//' | sed -e 's/^[ \t]*//' | sort -u)
hostname=$(hostname); #
#sed -i "s|postmaster@example.com|$postmaster_address|g" /etc/dovecot/dovecot.conf
echo 'Fix postmaster email in sieve' #sed -i "s|server.example.com|$hostname|g" /etc/dovecot/dovecot.conf
postmaster_address=$(grep postmaster_address /etc/dovecot/dovecot.conf | sed 's/.*=//' |sed -e 's/^[ \t]*//'| sort -u) #sed -i "s|postmaster@example.com|$postmaster_address|g" /etc/dovecot/dovecot.conf
#
sed -i "s|postmaster@example.com|$postmaster_address|g" /etc/dovecot/dovecot.conf ##Sieve the global spam filter
sed -i "s|server.example.com|$hostname|g" /etc/dovecot/dovecot.conf #sievec /etc/dovecot/sieve/default.sieve
sed -i "s|postmaster@example.com|$postmaster_address|g" /etc/dovecot/dovecot.conf #
##Sieve the global spam filter
#Sieve the global spam filter #sievec /etc/dovecot/sieve/default.sieve
sievec /etc/dovecot/sieve/default.sieve #
#if [ "$OS" = "NAME=\"Ubuntu\"" ]; then
#Sieve the global spam filter # sed -i 's|^spamassassin.*|spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}|g' /etc/postfix/master.cf
sievec /etc/dovecot/sieve/default.sieve #
#elif [ "$OS" = "NAME=\"CentOS Linux\"" ]; then
if [ "$OS" = "NAME=\"Ubuntu\"" ];then # sed -i 's|^spamassassin.*|spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}|g' /etc/postfix/master.cf
sed -i 's|^spamassassin.*|spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}|g' /etc/postfix/master.cf #
#elif [ "$OS" = "NAME=\"CloudLinux\"" ]; then
elif [ "$OS" = "NAME=\"CentOS Linux\"" ];then # sed -i 's|^spamassassin.*|spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}|g' /etc/postfix/master.cf
sed -i 's|^spamassassin.*|spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}|g' /etc/postfix/master.cf #
#fi
elif [ "$OS" = "NAME=\"CloudLinux\"" ];then
sed -i 's|^spamassassin.*|spamassassin unix - n n - - pipe flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e /usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}|g' /etc/postfix/master.cf
fi
echo 'Restart and check services are up' echo 'Restart and check services are up'
systemctl restart dovecot && systemctl restart postfix && systemctl restart spamassassin && systemctl restart mailscanner; systemctl restart dovecot && systemctl restart postfix && systemctl restart spamassassin && systemctl restart mailscanner
csf -e csf -e

View File

@@ -1,28 +1,28 @@
#!/bin/bash #!/bin/bash
## Uninstall Mailscanner CyberPanel ## Uninstall Mailscanner CyberPanel
if [ -f /etc/os-release ];then if [ -f /etc/os-release ]; then
OS=$(head -1 /etc/os-release) OS=$(head -1 /etc/os-release)
UBUNTUVERSION=$(sed '6q;d' /etc/os-release) UBUNTUVERSION=$(sed '6q;d' /etc/os-release)
CENTOSVERSION=$(sed '5q;d' /etc/os-release) CENTOSVERSION=$(sed '5q;d' /etc/os-release)
CLNVERSION=$(sed '3q;d' /etc/os-release) CLNVERSION=$(sed '3q;d' /etc/os-release)
fi fi
systemctl stop mailscanner systemctl stop mailscanner
if [ "$OS" = "NAME=\"Ubuntu\"" ];then if [ "$OS" = "NAME=\"Ubuntu\"" ]; then
apt purge -y mailscanner apt purge -y mailscanner
elif
[ "$OS" = "NAME=\"CentOS Linux\"" ]
then
yum remove -y MailScanner
elif [ "$OS" = "NAME=\"CentOS Linux\"" ];then elif [ "$OS" = "NAME=\"CloudLinux\"" ]; then
yum remove -y MailScanner yum remove -y MailScanner
elif [ "$OS" = "NAME=\"CloudLinux\"" ];then
yum remove -y MailScanner
fi fi
sed -i '/\/^Received:\/ HOLD/d' /etc/postfix/header_checks sed -i '/\/^Received:\/ HOLD/d' /etc/postfix/header_checks
rm -rf /etc/MailScanner rm -rf /etc/MailScanner
rm -rf /usr/share/MailScanner rm -rf /usr/share/MailScanner

View File

@@ -343,6 +343,7 @@ password=%s""" % (rootdbpassword, rootdbpassword)
def SyncNow(self): def SyncNow(self):
try: try:
self.PostStatus('Syncing data from home directory to fail over server..') self.PostStatus('Syncing data from home directory to fail over server..')
command = "rsync -avzp -e 'ssh -o StrictHostKeyChecking=no -p %s -i /root/.ssh/cyberpanel' /home root@%s:/" % (self.config['failoverServerSSHPort'], self.config['failoverServerIP']) command = "rsync -avzp -e 'ssh -o StrictHostKeyChecking=no -p %s -i /root/.ssh/cyberpanel' /home root@%s:/" % (self.config['failoverServerSSHPort'], self.config['failoverServerIP'])