aaPanel_Kern
Recently, I did the modification on the /www/server/panel/install/mail_sys.sh
file, adding new functionality for the Centos 9 (which I'm using CentOS Stream 9). Here is my edits:
install_rspamd()
{
if [[ $systemver = "7" ]];then
wget -O /etc/yum.repos.d/rspamd.repo https://rspamd.com/rpm-stable/centos-7/rspamd.repo
rpm --import https://rspamd.com/rpm-stable/gpg.key
# yum makecache -y
yum install rspamd -y
elif [ $systemver = "8" ]; then
wget -O /etc/yum.repos.d/rspamd.repo https://rspamd.com/rpm-stable/centos-8/rspamd.repo
rpm --import https://rspamd.com/rpm-stable/gpg.key
# yum makecache -y
yum install rspamd -y
elif [ $systemver = "9" ]; then
wget -O /etc/yum.repos.d/rspamd.repo https://rspamd.com/rpm-stable/centos-9/rspamd.repo
rpm --import https://rspamd.com/rpm-stable/gpg.key
# yum makecache -y
yum install rspamd -y
else
*rest of the code blocks
}
Install_rspamd_rpm() {
if [[ $systemver = "7" ]]; then
wget $download_Url/src/rspamd-3.4-1.x86_64.rpm
rpm -ivh rspamd-3.4-1.x86_64.rpm
rm -f rspamd-3.4-1.x86_64.rpm
elif [[ $systemver = "8" ]]; then
wget $download_Url/src/rspamd-3.4-1.x86_64.rpm
rpm -ivh rspamd-3.4-1.x86_64.rpm
rm -f rspamd-3.4-1.x86_64.rpm
elif [[ $systemver = "9" ]]; then
wget https://rspamd.com/rpm-stable/centos-9/x86_64/rspamd-3.10.0-1.el9.x86_64.rpm
rpm -ivh rspamd-3.10.0-1.el9.x86_64.rpm
rm -f rspamd-3.10.0-1.el9.x86_64.rpm
else
*rest of the code blocks
}
download_Url9=http://mirror.ghettoforge.org
download_official_url=https://mirror.stream.centos.org
Install_centos9() {
# Enable EPEL repository for CentOS Stream 9
dnf install epel-release -y
# Remove system-provided postfix if necessary
if [[ $cpu_arch = "x86_64" && $postfixver != "3.9.0" ]]; then
dnf remove postfix -y
rm -rf /etc/postfix
fi
# 安装postfix和postfix-sqlite
wget -O /tmp/postfix3-3.9.0-1.gf.el9.x86_64.rpm $download_Url9/distributions/gf/el/9/plus/x86_64/postfix3-3.9.0-1.gf.el9.x86_64.rpm
dnf localinstall /tmp/postfix3-3.9.0-1.gf.el9.x86_64.rpm -y
wget -O /tmp/postfix3-sqlite-3.9.0-1.gf.el9.x86_64.rpm $download_Url9/distributions/gf/el/9/plus/x86_64/postfix3-sqlite-3.9.0-1.gf.el9.x86_64.rpm
dnf localinstall /tmp/postfix3-sqlite-3.9.0-1.gf.el9.x86_64.rpm -y
wget -O /tmp/postfix-perl-scripts-3.5.25-1.el9.x86_64.rpm $download_official_url/9-stream/AppStream/x86_64/os/Packages/postfix-perl-scripts-3.5.25-1.el9.x86_64.rpm
dnf localinstall /tmp/postfix-perl-scripts-3.5.25-1.el9.x86_64.rpm -y
if [[ ! -f "/usr/sbin/postfix" ]]; then
dnf install postfix -y
dnf install postfix-sqlite -y
fi
# 安装dovecot和dovecot-sieve
dnf install dovecot-pigeonhole -y
# wget -O /tmp/dovecot23-2.3.20-3.gf.el9.x86_64.rpm $download_Url9/distributions/gf/el/9/plus/x86_64/dovecot23-2.3.20-3.gf.el9.x86_64.rpm
# yum localinstall /tmp/dovecot23-2.3.20-3.gf.el9.x86_64.rpm -y
if [[ ! -f "/usr/sbin/dovecot" ]]; then
dnf install dovecot -y
fi
# 安装opendkim
# 安装rspamd
if [ $ping_url != "200" ]; then
Install_rspamd_rpm
else
install_rspamd
fi
dnf install cyrus-sasl-plain cyrus-sasl-lib cyrus-sasl libsodium libwins -y
}
...
Install()
{
if [ ! -d /www/server/panel/plugin/mail_sys ];then
mkdir -p $pluginPath
mkdir -p $pluginStaticPath
# 调整顺序
filesize=`ls -l /etc/dovecot/dh.pem | awk '{print $5}'`
echo $filesize
if [ ! -f "/etc/dovecot/dh.pem" ] || [ $filesize -lt 300 ]; then
openssl dhparam 2048 > /etc/dovecot/dh.pem
fi
if [[ $systemver = "7" ]]; then
Install_centos7
elif [[ $systemver = "8" ]]; then
Install_centos8
elif [[ $systemver = "9" ]]; then
Install_centos9
else
Install_ubuntu
fi
fi
*rest of the code blocks
}
Uninstall()
{
if [[ $systemver = "7" ]];then
yum remove postfix -y
yum remove dovecot -y
yum remove opendkim -y
yum remove rspamd -y
yum remove dovecot-pigeonhole -y
elif [ $systemver = "8" ]; then
yum remove postfix -y
yum remove dovecot -y
yum remove opendkim -y
yum remove rspamd -y
yum remove dovecot-pigeonhole -y
elif [ $systemver = "9" ]; then
yum remove postfix -y
yum remove dovecot -y
yum remove opendkim -y
yum remove rspamd -y
yum remove dovecot-pigeonhole -y
else
*rest of the code blocks
}
Or you can manually install using these commands:
# sudo dnf remove postfix -y
# rm -rf /etc/postfix
# wget -O /tmp/postfix3-3.9.0-1.gf.el9.x86_64.rpm http://mirror.ghettoforge.org/distributions/gf/el/9/plus/x86_64/postfix3-3.9.0-1.gf.el9.x86_64.rpm
# dnf localinstall /tmp/postfix3-3.9.0-1.gf.el9.x86_64.rpm -y
# wget -O /tmp/postfix3-sqlite-3.9.0-1.gf.el9.x86_64.rpm http://mirror.ghettoforge.org/distributions/gf/el/9/plus/x86_64/postfix3-sqlite-3.9.0-1.gf.el9.x86_64.rpm
# dnf localinstall /tmp/postfix3-sqlite-3.9.0-1.gf.el9.x86_64.rpm -y
# wget -O /tmp/postfix-perl-scripts-3.5.25-1.el9.x86_64.rpm https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/postfix-perl-scripts-3.5.25-1.el9.x86_64.rpm
# dnf localinstall /tmp/postfix-perl-scripts-3.5.25-1.el9.x86_64.rpm -y
# wget -O /tmp/cyrus-sasl-2.1.27-21.el9.x86_64.rpm https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/cyrus-sasl-2.1.27-21.el9.x86_64.rpm
# dnf localinstall /tmp/cyrus-sasl-2.1.27-21.el9.x86_64.rpm
# wget -O /tmp/cyrus-sasl-lib-2.1.27-21.el9.x86_64.rpm https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/cyrus-sasl-lib-2.1.27-21.el9.x86_64.rpm
# dnf localinstall /tmp/cyrus-sasl-lib-2.1.27-21.el9.x86_64.rpm
# wget -O /tmp/cyrus-sasl-plain-2.1.27-21.el9.x86_64.rpm https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/cyrus-sasl-plain-2.1.27-21.el9.x86_64.rpm
# dnf localinstall /tmp/cyrus-sasl-plain-2.1.27-21.el9.x86_64.rpm
Then, initialize the mail server environment prompt at aapanel and select on Close.
After,
systemctl enable postfix && systemctl start postfix
Works like a charm!