mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
refactor: install code for dovecot/postfix on ubuntu20
This commit is contained in:
@@ -14,7 +14,6 @@ import argparse
|
||||
import json
|
||||
from CLScript.CLMain import CLMain
|
||||
|
||||
|
||||
class CloudLinuxResellers(CLMain):
|
||||
|
||||
def __init__(self, id, name):
|
||||
|
||||
@@ -766,28 +766,21 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
|
||||
command = 'dnf install --enablerepo=gf-plus postfix3 postfix3-mysql -y'
|
||||
else:
|
||||
command = 'apt-get -y debconf-utils'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
file_name = self.cwd + '/pf.unattend.text'
|
||||
pf = open(file_name, 'w')
|
||||
pf.write('postfix postfix/mailname string ' + str(socket.getfqdn() + '\n'))
|
||||
pf.write('postfix postfix/main_mailer_type string "Internet Site"\n')
|
||||
pf.close()
|
||||
command = 'debconf-set-selections ' + file_name
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
# command = 'apt-get -y debconf-utils'
|
||||
# preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
# file_name = self.cwd + '/pf.unattend.text'
|
||||
# pf = open(file_name, 'w')
|
||||
# pf.write('postfix postfix/mailname string ' + str(socket.getfqdn() + '\n'))
|
||||
# pf.write('postfix postfix/main_mailer_type string "Internet Site"\n')
|
||||
# pf.close()
|
||||
# command = 'debconf-set-selections ' + file_name
|
||||
# preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
command = 'apt-get -y install postfix'
|
||||
command = 'apt-get -y install postfix postfix-mysql'
|
||||
# os.remove(file_name)
|
||||
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
if self.distro == centos or self.distro == cent8:
|
||||
pass
|
||||
else:
|
||||
command = 'apt-get -y install dovecot-imapd dovecot-pop3d postfix-mysql'
|
||||
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
##
|
||||
|
||||
if self.distro == centos:
|
||||
@@ -795,42 +788,42 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
elif self.distro == cent8:
|
||||
command = 'dnf install --enablerepo=gf-plus dovecot23 dovecot23-mysql -y'
|
||||
else:
|
||||
command = 'apt-get -y install dovecot-mysql'
|
||||
command = 'apt-get -y install dovecot-mysql dovecot-imapd dovecot-pop3d'
|
||||
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
if self.distro != centos:
|
||||
command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
debPath = '/etc/apt/sources.list.d/dovecot.list'
|
||||
writeToFile = open(debPath, 'w')
|
||||
writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
|
||||
writeToFile.close()
|
||||
|
||||
try:
|
||||
command = 'apt update -y'
|
||||
subprocess.call(command, shell=True)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'dpkg --configure -a'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'apt --fix-broken install -y'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
subprocess.call(command, shell=True)
|
||||
except:
|
||||
pass
|
||||
# if self.distro != centos:
|
||||
# command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = 'gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# debPath = '/etc/apt/sources.list.d/dovecot.list'
|
||||
# writeToFile = open(debPath, 'w')
|
||||
# writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
|
||||
# writeToFile.close()
|
||||
#
|
||||
# try:
|
||||
# command = 'apt update -y'
|
||||
# subprocess.call(command, shell=True)
|
||||
# except:
|
||||
# pass
|
||||
#
|
||||
# try:
|
||||
# command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = 'dpkg --configure -a'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = 'apt --fix-broken install -y'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
# subprocess.call(command, shell=True)
|
||||
# except:
|
||||
# pass
|
||||
|
||||
except BaseException as msg:
|
||||
logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_postfix_davecot]")
|
||||
@@ -845,19 +838,13 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
|
||||
os.chdir(self.cwd)
|
||||
|
||||
if mysql == 'Two':
|
||||
mysql_virtual_domains = "email-configs/mysql-virtual_domains.cf"
|
||||
mysql_virtual_forwardings = "email-configs/mysql-virtual_forwardings.cf"
|
||||
mysql_virtual_mailboxes = "email-configs/mysql-virtual_mailboxes.cf"
|
||||
mysql_virtual_email2email = "email-configs/mysql-virtual_email2email.cf"
|
||||
davecotmysql = "email-configs/dovecot-sql.conf.ext"
|
||||
else:
|
||||
mysql_virtual_domains = "email-configs-one/mysql-virtual_domains.cf"
|
||||
mysql_virtual_forwardings = "email-configs-one/mysql-virtual_forwardings.cf"
|
||||
mysql_virtual_mailboxes = "email-configs-one/mysql-virtual_mailboxes.cf"
|
||||
mysql_virtual_email2email = "email-configs-one/mysql-virtual_email2email.cf"
|
||||
davecotmysql = "email-configs-one/dovecot-sql.conf.ext"
|
||||
|
||||
|
||||
### update password:
|
||||
|
||||
data = open(davecotmysql, "r").readlines()
|
||||
@@ -875,8 +862,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
@@ -894,9 +879,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
### update password:
|
||||
@@ -913,9 +895,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
### update password:
|
||||
@@ -932,9 +911,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
### update password:
|
||||
@@ -951,9 +927,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
|
||||
@@ -1060,27 +1033,13 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
# Cleanup config files for ubuntu
|
||||
if self.distro == ubuntu:
|
||||
preFlightsChecks.stdOut("Cleanup postfix/dovecot config files", 1)
|
||||
if mysql == 'Two':
|
||||
self.centos_lib_dir_to_ubuntu("email-configs/master.cf", "/usr/libexec/", "/usr/lib/")
|
||||
self.centos_lib_dir_to_ubuntu("email-configs/main.cf", "/usr/libexec/postfix",
|
||||
"/usr/lib/postfix/sbin")
|
||||
else:
|
||||
|
||||
self.centos_lib_dir_to_ubuntu("email-configs-one/master.cf", "/usr/libexec/", "/usr/lib/")
|
||||
self.centos_lib_dir_to_ubuntu("email-configs-one/main.cf", "/usr/libexec/postfix",
|
||||
"/usr/lib/postfix/sbin")
|
||||
|
||||
########### Copy config files
|
||||
|
||||
if mysql == 'Two':
|
||||
shutil.copy("email-configs/mysql-virtual_domains.cf", "/etc/postfix/mysql-virtual_domains.cf")
|
||||
shutil.copy("email-configs/mysql-virtual_forwardings.cf", "/etc/postfix/mysql-virtual_forwardings.cf")
|
||||
shutil.copy("email-configs/mysql-virtual_mailboxes.cf", "/etc/postfix/mysql-virtual_mailboxes.cf")
|
||||
shutil.copy("email-configs/mysql-virtual_email2email.cf", "/etc/postfix/mysql-virtual_email2email.cf")
|
||||
shutil.copy("email-configs/main.cf", main)
|
||||
shutil.copy("email-configs/master.cf", master)
|
||||
shutil.copy("email-configs/dovecot.conf", davecot)
|
||||
shutil.copy("email-configs/dovecot-sql.conf.ext", davecotmysql)
|
||||
else:
|
||||
shutil.copy("email-configs-one/mysql-virtual_domains.cf", "/etc/postfix/mysql-virtual_domains.cf")
|
||||
shutil.copy("email-configs-one/mysql-virtual_forwardings.cf",
|
||||
"/etc/postfix/mysql-virtual_forwardings.cf")
|
||||
@@ -1092,6 +1051,7 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
shutil.copy("email-configs-one/dovecot.conf", davecot)
|
||||
shutil.copy("email-configs-one/dovecot-sql.conf.ext", davecotmysql)
|
||||
|
||||
|
||||
######################################## Permissions
|
||||
|
||||
command = 'chmod o= /etc/postfix/mysql-virtual_domains.cf'
|
||||
|
||||
Reference in New Issue
Block a user