mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
remove sieve configurations from mailscanner install
This commit is contained in:
@@ -11,13 +11,12 @@ else
|
||||
fi
|
||||
}
|
||||
|
||||
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');
|
||||
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
|
||||
@@ -28,7 +27,6 @@ csf -x
|
||||
MAILSCANNER=/etc/MailScanner
|
||||
|
||||
if [ -d $MAILSCANNER ]; then
|
||||
|
||||
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 "/etc/MailScanner and /usr/share/MailScanner directories"
|
||||
@@ -62,11 +60,8 @@ DIR=/etc/mail/spamassassin
|
||||
|
||||
if [ -d "$DIR" ]; then
|
||||
sa-update
|
||||
|
||||
else
|
||||
|
||||
echo "Please install spamassassin through the CyberPanel interface before proceeding"
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
@@ -90,19 +85,14 @@ perl -MCPAN -e 'install Razor2::Client::Agent'
|
||||
perl -MCPAN -e 'install Sys::Hostname::Long'
|
||||
perl -MCPAN -e 'install Sys::SigAction'
|
||||
|
||||
|
||||
|
||||
freshclam -v
|
||||
|
||||
DIR=/etc/mail/spamassassin
|
||||
|
||||
if [ -d "$DIR" ]; then
|
||||
sa-update
|
||||
|
||||
else
|
||||
|
||||
echo "Please install spamassassin through the CyberPanel interface before proceeding"
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
@@ -235,7 +225,7 @@ USER=root
|
||||
DATABASE=mailscanner
|
||||
ADMINPASS=$(cat /etc/cyberpanel/adminPass)
|
||||
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 "FLUSH PRIVILEGES;"
|
||||
mysql -u${USER} -D${DATABASE} -p${PASSWORD} -e "INSERT INTO mailscanner.users SET username = 'admin', password = MD5('${ADMINPASS}'), fullname = 'admin', type = 'A';"
|
||||
@@ -268,125 +258,121 @@ systemctl restart mailscanner
|
||||
|
||||
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 "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 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
|
||||
|
||||
if [ "$OS" = "NAME=\"Ubuntu\"" ];then
|
||||
if [ "$UBUNTUVERSION" = "VERSION_ID=\"18.04\"" ];then
|
||||
apt-get install -y dovecot-managesieved dovecot-sieve dovecot-lmtpd net-tools pflogsumm
|
||||
elif [ "$UBUNTUVERSION" = "VERSION_ID=\"20.04\"" ];then
|
||||
apt-get install -y libmysqlclient-dev
|
||||
sed -e '/deb/ s/^#*/#/' -i /etc/apt/sources.list.d/dovecot.list
|
||||
apt install -y dovecot-lmtpd dovecot-managesieved dovecot-sieve net-tools pflogsumm
|
||||
fi
|
||||
|
||||
elif [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ];then
|
||||
|
||||
yum install -y nano net-tools dovecot-pigeonhole postfix-perl-scripts
|
||||
|
||||
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
|
||||
dnf --enablerepo=gf-plus upgrade -y dovecot23*
|
||||
dnf --enablerepo=gf-plus install -y dovecot23-pigeonhole
|
||||
dnf install -y net-tools postfix-perl-scripts
|
||||
|
||||
elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ];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 <<EOL
|
||||
require "fileinto";
|
||||
if header :contains "X-Spam-Flag" "YES" {
|
||||
fileinto "INBOX.Junk E-mail";
|
||||
}
|
||||
EOL
|
||||
|
||||
|
||||
echo "Adding Sieve to /etc/dovecot/dovecot.conf"
|
||||
cat >> /etc/dovecot/dovecot.conf <<EOL
|
||||
|
||||
service managesieve-login {
|
||||
inet_listener sieve {
|
||||
port = 4190
|
||||
}
|
||||
}
|
||||
service managesieve {
|
||||
}
|
||||
protocol sieve {
|
||||
managesieve_max_line_length = 65536
|
||||
managesieve_implementation_string = dovecot
|
||||
log_path = /var/log/dovecot-sieve-errors.log
|
||||
info_log_path = /var/log/dovecot-sieve.log
|
||||
}
|
||||
plugin {
|
||||
sieve = /home/vmail/%d/%n/dovecot.sieve
|
||||
sieve_global_path = /etc/dovecot/sieve/default.sieve
|
||||
sieve_dir = /home/vmail/%d/%n/sieve
|
||||
sieve_global_dir = /etc/dovecot/sieve/global/
|
||||
}
|
||||
protocol lda {
|
||||
mail_plugins = $mail_plugins sieve quota
|
||||
postmaster_address = postmaster@example.com
|
||||
hostname = server.example.com
|
||||
auth_socket_path = /var/run/dovecot/auth-master
|
||||
log_path = /var/log/dovecot-lda-errors.log
|
||||
info_log_path = /var/log/dovecot-lda.log
|
||||
}
|
||||
protocol lmtp {
|
||||
mail_plugins = $mail_plugins sieve quota
|
||||
log_path = /var/log/dovecot-lmtp-errors.log
|
||||
info_log_path = /var/log/dovecot-lmtp.log
|
||||
}
|
||||
EOL
|
||||
|
||||
hostname=$(hostname);
|
||||
|
||||
echo 'Fix postmaster email in sieve'
|
||||
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|server.example.com|$hostname|g" /etc/dovecot/dovecot.conf
|
||||
sed -i "s|postmaster@example.com|$postmaster_address|g" /etc/dovecot/dovecot.conf
|
||||
|
||||
#Sieve the global spam filter
|
||||
sievec /etc/dovecot/sieve/default.sieve
|
||||
|
||||
#Sieve the global spam filter
|
||||
sievec /etc/dovecot/sieve/default.sieve
|
||||
|
||||
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/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}|g' /etc/postfix/master.cf
|
||||
|
||||
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
|
||||
|
||||
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 '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 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
|
||||
#
|
||||
#if [ "$OS" = "NAME=\"Ubuntu\"" ]; then
|
||||
# if [ "$UBUNTUVERSION" = "VERSION_ID=\"18.04\"" ]; then
|
||||
# apt-get install -y dovecot-managesieved dovecot-sieve dovecot-lmtpd net-tools pflogsumm
|
||||
# elif [ "$UBUNTUVERSION" = "VERSION_ID=\"20.04\"" ]; then
|
||||
# apt-get install -y libmysqlclient-dev
|
||||
# sed -e '/deb/ s/^#*/#/' -i /etc/apt/sources.list.d/dovecot.list
|
||||
# apt install -y dovecot-lmtpd dovecot-managesieved dovecot-sieve net-tools pflogsumm
|
||||
# fi
|
||||
#
|
||||
#elif [ "$CENTOSVERSION" = "VERSION_ID=\"7\"" ]; then
|
||||
#
|
||||
# yum install -y nano net-tools dovecot-pigeonhole postfix-perl-scripts
|
||||
#
|
||||
#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
|
||||
# dnf --enablerepo=gf-plus upgrade -y dovecot23*
|
||||
# dnf --enablerepo=gf-plus install -y dovecot23-pigeonhole
|
||||
# dnf install -y net-tools postfix-perl-scripts
|
||||
#
|
||||
#elif [ "$CLNVERSION" = "ID=\"cloudlinux\"" ]; 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 <<EOL
|
||||
#require "fileinto";
|
||||
#if header :contains "X-Spam-Flag" "YES" {
|
||||
# fileinto "INBOX.Junk E-mail";
|
||||
#}
|
||||
#EOL
|
||||
#
|
||||
#echo "Adding Sieve to /etc/dovecot/dovecot.conf"
|
||||
#cat >>/etc/dovecot/dovecot.conf <<EOL
|
||||
#
|
||||
#service managesieve-login {
|
||||
# inet_listener sieve {
|
||||
# port = 4190
|
||||
# }
|
||||
#}
|
||||
#service managesieve {
|
||||
#}
|
||||
#protocol sieve {
|
||||
# managesieve_max_line_length = 65536
|
||||
# managesieve_implementation_string = dovecot
|
||||
# log_path = /var/log/dovecot-sieve-errors.log
|
||||
# info_log_path = /var/log/dovecot-sieve.log
|
||||
#}
|
||||
#plugin {
|
||||
#sieve = /home/vmail/%d/%n/dovecot.sieve
|
||||
#sieve_global_path = /etc/dovecot/sieve/default.sieve
|
||||
#sieve_dir = /home/vmail/%d/%n/sieve
|
||||
#sieve_global_dir = /etc/dovecot/sieve/global/
|
||||
#}
|
||||
#protocol lda {
|
||||
# mail_plugins = $mail_plugins sieve quota
|
||||
# postmaster_address = postmaster@example.com
|
||||
# hostname = server.example.com
|
||||
# auth_socket_path = /var/run/dovecot/auth-master
|
||||
# log_path = /var/log/dovecot-lda-errors.log
|
||||
# info_log_path = /var/log/dovecot-lda.log
|
||||
#}
|
||||
#protocol lmtp {
|
||||
# mail_plugins = $mail_plugins sieve quota
|
||||
# log_path = /var/log/dovecot-lmtp-errors.log
|
||||
# info_log_path = /var/log/dovecot-lmtp.log
|
||||
#}
|
||||
#EOL
|
||||
#
|
||||
#hostname=$(hostname)
|
||||
#
|
||||
#echo 'Fix postmaster email in sieve'
|
||||
#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|server.example.com|$hostname|g" /etc/dovecot/dovecot.conf
|
||||
#sed -i "s|postmaster@example.com|$postmaster_address|g" /etc/dovecot/dovecot.conf
|
||||
#
|
||||
##Sieve the global spam filter
|
||||
#sievec /etc/dovecot/sieve/default.sieve
|
||||
#
|
||||
##Sieve the global spam filter
|
||||
#sievec /etc/dovecot/sieve/default.sieve
|
||||
#
|
||||
#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/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}|g' /etc/postfix/master.cf
|
||||
#
|
||||
#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
|
||||
#
|
||||
#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'
|
||||
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
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@ systemctl stop mailscanner
|
||||
if [ "$OS" = "NAME=\"Ubuntu\"" ]; then
|
||||
apt purge -y mailscanner
|
||||
|
||||
|
||||
elif [ "$OS" = "NAME=\"CentOS Linux\"" ];then
|
||||
elif
|
||||
[ "$OS" = "NAME=\"CentOS Linux\"" ]
|
||||
then
|
||||
yum remove -y MailScanner
|
||||
|
||||
elif [ "$OS" = "NAME=\"CloudLinux\"" ]; then
|
||||
@@ -22,7 +23,6 @@ yum remove -y MailScanner
|
||||
|
||||
fi
|
||||
|
||||
|
||||
sed -i '/\/^Received:\/ HOLD/d' /etc/postfix/header_checks
|
||||
rm -rf /etc/MailScanner
|
||||
rm -rf /usr/share/MailScanner
|
||||
|
||||
@@ -343,6 +343,7 @@ password=%s""" % (rootdbpassword, rootdbpassword)
|
||||
|
||||
def SyncNow(self):
|
||||
try:
|
||||
|
||||
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'])
|
||||
|
||||
Reference in New Issue
Block a user