dovecot for ubuntu

This commit is contained in:
usmannasir
2018-11-06 13:03:12 +05:00
parent 00d9e7f942
commit d008bfd251
3 changed files with 56 additions and 18 deletions

View File

@@ -9,7 +9,7 @@ from firewallUtilities import FirewallUtilities
import time import time
import string import string
import random import random
import errno import socket
from os.path import * from os.path import *
from stat import * from stat import *
@@ -192,7 +192,7 @@ class preFlightsChecks:
while (1): while (1):
command = "mkdir /etc/letsencrypt" command = "mkdir -p /etc/letsencrypt/live/"
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -617,6 +617,18 @@ class preFlightsChecks:
preFlightsChecks.stdOut("MySQL-python successfully installed!") preFlightsChecks.stdOut("MySQL-python successfully installed!")
break break
if self.distro == ubuntu:
command = "pip install MySQL-python"
res = subprocess.call(shlex.split(command))
if res != 0:
logging.InstallLog.writeToFile(
"Unable to install MySQL-python, exiting installer! [install_python_mysql_library] Error: " + str(
res))
preFlightsChecks.stdOut(
"Unable to install MySQL-python, exiting installer! [install_python_mysql_library] Error: " + str(
res))
os._exit(os.EX_OSERR)
def install_gunicorn(self): def install_gunicorn(self):
self.stdOut("Install GUnicorn") self.stdOut("Install GUnicorn")
count = 0 count = 0
@@ -1268,7 +1280,6 @@ class preFlightsChecks:
return 1 return 1
def setup_email_Passwords(self,mysqlPassword, mysql): def setup_email_Passwords(self,mysqlPassword, mysql):
try: try:
@@ -1383,7 +1394,6 @@ class preFlightsChecks:
return 1 return 1
def setup_postfix_davecot_config(self, mysql): def setup_postfix_davecot_config(self, mysql):
try: try:
logging.InstallLog.writeToFile("Configuring postfix and dovecot...") logging.InstallLog.writeToFile("Configuring postfix and dovecot...")
@@ -1979,9 +1989,7 @@ class preFlightsChecks:
while(1): while(1):
command = "chmod 755 "+main command = "chmod 755 "+main
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
if res == 1: if res == 1:
@@ -1995,6 +2003,19 @@ class preFlightsChecks:
preFlightsChecks.stdOut("Permissions changed for /etc/postfix/main.cf!") preFlightsChecks.stdOut("Permissions changed for /etc/postfix/main.cf!")
break break
if self.distro == ubuntu:
command = "mkdir -p /etc/pki/dovecot/private/"
cmd = shlex.split(command)
res = subprocess.call(cmd)
command = "mkdir -p /etc/opendkim/keys/"
cmd = shlex.split(command)
res = subprocess.call(cmd)
command = "sed -i 's/auth_mechanisms = plain/#auth_mechanisms = plain/g' /etc/dovecot/conf.d/10-auth.conf"
subprocess.call(shlex.split(command))
logging.InstallLog.writeToFile("Postfix and Dovecot configured") logging.InstallLog.writeToFile("Postfix and Dovecot configured")
except OSError, msg: except OSError, msg:
@@ -2006,7 +2027,6 @@ class preFlightsChecks:
return 1 return 1
def downoad_and_install_raindloop(self): def downoad_and_install_raindloop(self):
try: try:
########### ###########
@@ -2188,9 +2208,6 @@ class preFlightsChecks:
def installFirewalld(self): def installFirewalld(self):
try: try:
if self.distro == ubuntu:
return 0 # Uses AppArmor
preFlightsChecks.stdOut("Enabling Firewall!") preFlightsChecks.stdOut("Enabling Firewall!")
count = 0 count = 0
@@ -2342,6 +2359,17 @@ class preFlightsChecks:
logging.InstallLog.writeToFile("LSCPD Successfully enabled at system startup!") logging.InstallLog.writeToFile("LSCPD Successfully enabled at system startup!")
preFlightsChecks.stdOut("LSCPD Successfully enabled at system startup!") preFlightsChecks.stdOut("LSCPD Successfully enabled at system startup!")
break break
##
count = 0
# In Ubuntu, the library that lscpd looks for is libpcre.so.1, but the one it installs is libpcre.so.3...
if self.distro == ubuntu:
command = 'ln -s /lib/x86_64-linux-gnu/libpcre.so.3 /lib/x86_64-linux-gnu/libpcre.so.1'
res = subprocess.call(shlex.split(command))
if res == 0:
self.stdOut("Created ubuntu symbolic link to pcre")
else:
self.stdOut("Error creating symbolic link to pcre: " + str(res))
## ##
@@ -2786,6 +2814,13 @@ class preFlightsChecks:
preFlightsChecks.stdOut("Succcessfully installed opendkim!") preFlightsChecks.stdOut("Succcessfully installed opendkim!")
break break
if self.distro == ubuntu:
command = 'apt install opendkim-tools'
subprocess.call(shlex.split(command))
command = 'mkdir -p /etc/opendkim/keys/'
subprocess.call(shlex.split(command))
except OSError, msg: except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [installOpenDKIM]") logging.InstallLog.writeToFile(str(msg) + " [installOpenDKIM]")
@@ -3287,7 +3322,7 @@ def main():
import installCyberPanel import installCyberPanel
installCyberPanel.Main(cwd, mysql) installCyberPanel.Main(cwd, mysql, distro)
checks.fix_selinux_issue() checks.fix_selinux_issue()
checks.install_psmisc() checks.install_psmisc()
checks.install_postfix_davecot() checks.install_postfix_davecot()
@@ -3325,7 +3360,7 @@ def main():
checks.configureOpenDKIM() checks.configureOpenDKIM()
checks.modSecPreReqs() checks.modSecPreReqs()
checks.setupVirtualEnv() checks.setupVirtualEnv(distro)
checks.setupPHPAndComposer() checks.setupPHPAndComposer()
if args.postfix != None: if args.postfix != None:
@@ -3347,6 +3382,7 @@ def main():
checks.enableDisableFTP('On') checks.enableDisableFTP('On')
logging.InstallLog.writeToFile("CyberPanel installation successfully completed!") logging.InstallLog.writeToFile("CyberPanel installation successfully completed!")
checks.installation_successfull()
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -3,7 +3,6 @@ import subprocess
import os import os
import pexpect import pexpect
from mysqlUtilities import mysqlUtilities from mysqlUtilities import mysqlUtilities
import install
import installLog as logging import installLog as logging
import shlex import shlex
import randomPassword import randomPassword
@@ -1265,7 +1264,6 @@ def Main(cwd, mysql, distro):
mysqlUtilities.createDatabaseCyberPanel("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword, mysql) mysqlUtilities.createDatabaseCyberPanel("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword, mysql)
installer.installPureFTPD() installer.installPureFTPD()
installer.installPureFTPDConfigurations(mysql) installer.installPureFTPDConfigurations(mysql)
installer.startPureFTPD() installer.startPureFTPD()

View File

@@ -158,8 +158,12 @@ class sslUtilities:
@staticmethod @staticmethod
def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None): def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None):
try: try:
acmePath = '/root/.acme.sh/acme.sh'
if not os.path.exists('/root/.acme.sh/acme.sh'): if os.path.exists('/etc/lsb-release'):
acmePath = '/home/cyberpanel/.acme.sh/acme.sh'
if not os.path.exists(acmePath):
command = 'wget -O - https://get.acme.sh | sh' command = 'wget -O - https://get.acme.sh | sh'
subprocess.call(command, shell=True) subprocess.call(command, shell=True)
@@ -173,7 +177,7 @@ class sslUtilities:
try: try:
logging.CyberCPLogFileWriter.writeToFile("Trying to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName) logging.CyberCPLogFileWriter.writeToFile("Trying to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName)
command = "/root/.acme.sh/acme.sh --issue -d " + virtualHostName + " -d www." + virtualHostName \ command = acmePath + " --issue -d " + virtualHostName + " -d www." + virtualHostName \
+ ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \ + ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force' + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
@@ -187,7 +191,7 @@ class sslUtilities:
try: try:
logging.CyberCPLogFileWriter.writeToFile("Trying to obtain SSL for: " + virtualHostName) logging.CyberCPLogFileWriter.writeToFile("Trying to obtain SSL for: " + virtualHostName)
command = "/root/.acme.sh/acme.sh --issue -d " + virtualHostName + ' --cert-file ' + existingCertPath \ command = acmePath + " --issue -d " + virtualHostName + ' --cert-file ' + existingCertPath \
+ '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \ + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force' + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
output = subprocess.check_output(shlex.split(command)) output = subprocess.check_output(shlex.split(command))
@@ -206,7 +210,7 @@ class sslUtilities:
logging.CyberCPLogFileWriter.writeToFile( logging.CyberCPLogFileWriter.writeToFile(
"Trying to obtain SSL for: " + virtualHostName + ", www." + virtualHostName + ", " + aliasDomain + " and www." + aliasDomain + ",") "Trying to obtain SSL for: " + virtualHostName + ", www." + virtualHostName + ", " + aliasDomain + " and www." + aliasDomain + ",")
command = "/root/.acme.sh/acme.sh --issue -d " + virtualHostName + " -d www." + virtualHostName \ command = acmePath + " --issue -d " + virtualHostName + " -d www." + virtualHostName \
+ ' -d ' + aliasDomain + ' -d www.' + aliasDomain\ + ' -d ' + aliasDomain + ' -d www.' + aliasDomain\
+ ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \ + ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force' + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'