diff --git a/CPScripts/mailscannerinstaller.sh b/CPScripts/mailscannerinstaller.sh index 05951f7c6..875e6c791 100644 --- a/CPScripts/mailscannerinstaller.sh +++ b/CPScripts/mailscannerinstaller.sh @@ -1,6 +1,20 @@ #!/bin/bash +#systemctl stop firewalld + +echo 'backup configs'; +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/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') + + +ZONE=$(firewall-cmd --get-default-zone) +firewall-cmd --zone=$ZONE --add-port=4190/tcp --permanent systemctl stop firewalld +echo 'Stop CSF' +csf -x + MAILSCANNER=/etc/MailScanner if [ -d $MAILSCANNER ];then @@ -173,13 +187,115 @@ systemctl restart mailscanner IPADDRESS=$(cat /etc/cyberpanel/machineIP) + +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 'Fix protocols' +sed -i 's/^protocols =.*/protocols = imap pop3 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 + +if [ "$OS" = "NAME=\"Ubuntu\"" ];then + + apt-get install -y dovecot-managesieved dovecot-sieve net-tools pflogsumm + +elif [ "$OS" = "NAME=\"CentOS Linux\"" ];then + + 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} +touch /var/log/{dovecot-sieve-errors.log,dovecot-sieve.log} +touch /var/log/{dovecot-lmtp-errors.log,dovecot-lmtp.log} +touch /etc/dovecot/sieve/default.sieve +chown vmail: -R /etc/dovecot/sieve +chown vmail:mail /var/log/dovecot-* + +echo 'Create Sieve Default spam to Junk rule' +cat >> /etc/dovecot/sieve/default.sieve <> /etc/dovecot/dovecot.conf <