send emails for cyberpanel logs
This commit is contained in:
parent
e5a9527bbb
commit
8982422edc
|
|
@ -667,7 +667,7 @@ class MailServerManager:
|
|||
zone.save()
|
||||
|
||||
path = "/etc/opendkim/keys/" + domainName + "/default.txt"
|
||||
command = "sudo cat " + path
|
||||
command = "cat " + path
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
leftIndex = output.index('(') + 2
|
||||
rightIndex = output.rindex(')') - 1
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import subprocess
|
||||
import time
|
||||
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
import socket
|
||||
from loginSystem.models import Administrator
|
||||
import os
|
||||
|
||||
class CyberCPLogFileWriter:
|
||||
fileName = "/home/cyberpanel/error-logs.txt"
|
||||
|
|
@ -13,6 +16,25 @@ class CyberCPLogFileWriter:
|
|||
"%m.%d.%Y_%H-%M-%S") + "] "+ message + "\n")
|
||||
file.close()
|
||||
|
||||
## Send Email
|
||||
|
||||
emailPath = '/usr/local/CyberCP/emailDebug'
|
||||
|
||||
if os.path.exists(emailPath):
|
||||
SUBJECT = "CyberPanel log reporting"
|
||||
admin = Administrator.objects.get(userName='admin')
|
||||
sender = 'root@%s' % (socket.gethostname())
|
||||
TO = [admin.email]
|
||||
message = """\
|
||||
From: %s
|
||||
To: %s
|
||||
Subject: %s
|
||||
|
||||
%s
|
||||
""" % (sender, ", ".join(TO), SUBJECT, '[%s] %s. \n' % (time.strftime("%m.%d.%Y_%H-%M-%S"), message))
|
||||
mailUtilities.SendEmail(sender, TO, message)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
return "Can not write to error file."
|
||||
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ class DNS:
|
|||
zone = Domains.objects.get(name=topLevelDomain)
|
||||
|
||||
path = "/etc/opendkim/keys/" + topLevelDomain + "/default.txt"
|
||||
command = "sudo cat " + path
|
||||
command = "cat " + path
|
||||
output = subprocess.check_output(shlex.split(command)).decode("utf-8")
|
||||
leftIndex = output.index('(') + 2
|
||||
rightIndex = output.rindex(')') - 1
|
||||
|
|
@ -402,8 +402,8 @@ class DNS:
|
|||
record.save()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
command = ' systemctl restart pdns'
|
||||
ProcessUtiities.executioner(command)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ class mailUtilities:
|
|||
|
||||
## Generate keys
|
||||
|
||||
command = "sudo opendkim-genkey -D /etc/opendkim/keys/%s -d %s -s default" % (virtualHostName, virtualHostName)
|
||||
command = "opendkim-genkey -D /etc/opendkim/keys/%s -d %s -s default" % (virtualHostName, virtualHostName)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
## Fix permissions
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue