Open meramsey opened 4 years ago
Will require testing but I believe this should accomplish the task.
#!/bin/bash
## Uninstall Mailscanner CyberPanel
if [ -f /etc/os-release ];then
OS=$(head -1 /etc/os-release)
UBUNTUVERSION=$(sed '6q;d' /etc/os-release)
CENTOSVERSION=$(sed '5q;d' /etc/os-release)
CLNVERSION=$(sed '3q;d' /etc/os-release)
fi
systemctl stop mailscanner
if [ "$OS" = "NAME=\"Ubuntu\"" ];then
apt purge -y mailscanner
elif [ "$OS" = "NAME=\"CentOS Linux\"" ];then
yum remove -y MailScanner
elif [ "$OS" = "NAME=\"CloudLinux\"" ];then
yum remove -y MailScanner
fi
sed -i '/\/^Received:\/ HOLD/d' /etc/postfix/header_checks
rm -rf /etc/MailScanner
rm -rf /usr/share/MailScanner
rm -rf /usr/local/CyberCP/public/mailwatch
systemctl restart postfix dovecot
Tested on Ubuntu and worked perfect for me. Could use someone testing on Centos but don't see why it wouldn't work.
root@server:~# apt list --installed | grep mailscanner
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
mailscanner/now 5.3.3-1 all [installed,local]
root@server:~# nano mailscanneruninstaller.sh
root@server:~# nano /etc/postfix/header_checks
root@server:~# cat /etc/postfix/header_checks
/^Received:/ HOLD
root@server:~# bash mailscanneruninstaller.sh
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libmariadbclient18
Use 'apt autoremove' to remove it.
The following packages will be REMOVED:
mailscanner*
0 upgraded, 0 newly installed, 1 to remove and 67 not upgraded.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 165673 files and directories currently installed.)
Removing mailscanner (5.3.3-1) ...
Removed /etc/systemd/system/multi-user.target.wants/mailscanner.service.
(Reading database ... 165547 files and directories currently installed.)
Purging configuration files for mailscanner (5.3.3-1) ...
dpkg: warning: while removing mailscanner, directory '/usr/share/MailScanner/perl/custom' not empty so not removed
root@server:~# apt list --installed | grep mailscanner
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
root@server:~#
File added: https://github.com/usmannasir/cyberpanel/commit/6f7af44a522ad10c7ab09bdc00a7b05dafe571c5
@usmannasir Can we add an Uninstall button if it is installed? and map it to this script to current dev so we can test this?
:8090/emailPremium/MailScanner
Also there should be a warning that this should be installed in Low Ram VPS due to the high overhead without large swap. This will ensure people who go to install it are aware of the possible performance impacts before enabling on production server with 1-2GB ram. Recommending like 3-4GB unless there going to manually extend the swap.
Hi, you might want to restore the dovecot and postfix config's backup created during mailscanner installation too.
@aonsyed That would break all the spamassassin dovecot/sieve stuff which is unrelated to uninstalling Mailscanner. In hindsight the spamassassin dovecot sieve code should probably be ported to that installer to make this clearer.
Dovecot and postfix settings are backed up after Spamassasin is installed and before all the modification are made for mailscanner https://github.com/usmannasir/cyberpanel/blob/e49338af5ecc18388fc0f9f8b032edf05399acda/CPScripts/mailscannerinstaller.sh#L14
@aonsyed I fixed this up so all the spamassassin piggybacked code is in its own script to prevent confusion going forward.
once the spamassassin script is executed at the end of the current python installSpamassassin function then this below commit should be merged https://github.com/usmannasir/cyberpanel/pull/401
From then on the mailscanner installer/uninstaller will only contain mailscanner related install requirements
I am using centos 7 and after installed mailscanner my postfix stopped to answer on 25 port.
errors:
Sep 25 23:28:47 centos-2gb-hel1-1 postfix/smtpd[144907]: warning: SASL: Connect to private/auth failed: Connection refused
Sep 25 23:28:47 centos-2gb-hel1-1 postfix/smtpd[144907]: fatal: no SASL authentication mechanisms
O Centos 7 I did:
yum remove -y MailScanner
sed -i '/\/^Received:\/ HOLD/d' /etc/postfix/header_checks
rm -rf /etc/MailScanner
rm -rf /usr/share/MailScanner
rm -rf /usr/local/CyberCP/public/mailwatch
systemctl restart postfix dovecot
It seems to be removed, however I continuing gettin SASL errors.
I tried to remove all "sieve" related configuration from dovecot.conf:
#protocols = imap pop3 lmtp sieve
protocols = imap pop3 lmtp
#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 = quota
#mail_plugins = sieve quota
protocol lmtp {
mail_plugins = quota
#mail_plugins = sieve quota
I am comparing with a server that never installed mailscanner service...
Now I am receiving emails and rainloop started to login again.
But customers that add their mail account in Gmail are getting:
I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.
For further assistance, please send mail to postmaster.
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
<xxxxx@gmail.com> (expanded from <xxxxx@yyyyy.wwwww>): user unknown
I found dovecot and postfix backups and I applied them:
[root@centos-2gb-hel1-1 dovecot]# ls -l /etc/dovecot/ | egrep -i bak
-rw-r--r--. 1 root root 3053 Sep 25 19:20 dovecot.conf-bak_2020-09-25_17_20:41
-rw-r-----. 1 root root 272 Sep 25 19:20 dovecot-sql.conf.ext-bak_2020-09-25_17_20:41
[root@centos-2gb-hel1-1 dovecot]#
[root@centos-2gb-hel1-1 ~]# ls -l /etc/postfix/ | egrep -i bak
-rw-r--r--. 1 root root 3093 Sep 25 19:20 main.cf-bak_2020-09-25_17_20:41
-rw-r-----. 1 root root 6395 Sep 25 19:20 master.cf-bak_2020-09-25_17_20:41
[root@centos-2gb-hel1-1 ~]#
https://forums.cyberpanel.net/discussion/4394/mailscanner-issue
https://github.com/usmannasir/cyberpanel/commit/56c87428db520caa99c216221256a37a1c5a5a55
Need button and uninstall script