mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
complete mailscanner
This commit is contained in:
@@ -449,6 +449,9 @@ milter_default_action = accept
|
||||
def installSpamAssassin(install, SpamAssassin):
|
||||
try:
|
||||
|
||||
if os.path.exists(mailUtilities.spamassassinInstallLogPath):
|
||||
os.remove(mailUtilities.spamassassinInstallLogPath)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sudo yum install spamassassin -y'
|
||||
else:
|
||||
@@ -477,6 +480,51 @@ milter_default_action = accept
|
||||
writeToFile.close()
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installSpamAssassin]")
|
||||
|
||||
@staticmethod
|
||||
def installMailScanner(install, SpamAssassin):
|
||||
try:
|
||||
|
||||
if os.path.exists(mailUtilities.spamassassinInstallLogPath):
|
||||
os.remove(mailUtilities.spamassassinInstallLogPath)
|
||||
|
||||
if mailUtilities.checkIfSpamAssassinInstalled():
|
||||
|
||||
command = 'chmod +x /usr/local/CyberCP/CPScripts/mailscannerinstaller.sh'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
command = '/usr/local/CyberCP/CPScripts/mailscannerinstaller.sh'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
with open(mailUtilities.spamassassinInstallLogPath, 'w') as f:
|
||||
res = subprocess.call(cmd, stdout=f)
|
||||
|
||||
if res == 1:
|
||||
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
|
||||
writeToFile.writelines("Can not be installed.[404]\n")
|
||||
writeToFile.close()
|
||||
logging.CyberCPLogFileWriter.writeToFile("[Could not Install MailScanner.]")
|
||||
return 0
|
||||
else:
|
||||
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
|
||||
writeToFile.writelines("MailScanner Installed.[200]\n")
|
||||
writeToFile.close()
|
||||
|
||||
return 1
|
||||
else:
|
||||
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
|
||||
writeToFile.writelines("Please install SpamAssassin from CyberPanel before installing MailScanner.[404]\n")
|
||||
writeToFile.close()
|
||||
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
|
||||
writeToFile.writelines("Can not be installed.[404]\n")
|
||||
writeToFile.close()
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installSpamAssassin]")
|
||||
|
||||
@staticmethod
|
||||
def checkIfSpamAssassinInstalled():
|
||||
try:
|
||||
@@ -670,7 +718,7 @@ milter_default_action = accept
|
||||
def checkIfMailScannerInstalled():
|
||||
try:
|
||||
|
||||
path = "/usr/local/CyberCP/public/mailscanner"
|
||||
path = "/usr/local/CyberCP/public/mailwatch"
|
||||
|
||||
if os .path.exists(path):
|
||||
return 1
|
||||
@@ -711,6 +759,8 @@ def main():
|
||||
mailUtilities.savePolicyServerStatus(args.install)
|
||||
elif args.function == 'installSpamAssassin':
|
||||
mailUtilities.installSpamAssassin("install", "SpamAssassin")
|
||||
elif args.function == 'installMailScanner':
|
||||
mailUtilities.installMailScanner("install", "installMailScanner")
|
||||
elif args.function == 'AfterEffects':
|
||||
mailUtilities.AfterEffects(args.domain)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user