minor bug fix to scheduled backups

This commit is contained in:
Usman Nasir
2019-07-25 14:12:54 +05:00
parent 91c9c22f38
commit e66f061a4a
5 changed files with 112 additions and 49 deletions

View File

@@ -654,13 +654,13 @@ class BackupManager:
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
if backupDest == "Home" and backupFreq == "Daily": if backupDest == "Home" and backupFreq == "Daily":
cronJob = "0 3 * * 0-6 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py" cronJob = "0 3 * * * root python /usr/local/CyberCP/plogical/backupScheduleLocal.py"
elif backupDest == "Home" and backupFreq == "Weekly": elif backupDest == "Home" and backupFreq == "Weekly":
cronJob = "0 3 * * 3 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py " cronJob = "0 0 * * 0 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py "
elif backupDest != "Home" and backupFreq == "Daily": elif backupDest != "Home" and backupFreq == "Daily":
cronJob = "0 3 * * 0-6 root python /usr/local/CyberCP/plogical/backupSchedule.py" cronJob = "0 3 * * * root python /usr/local/CyberCP/plogical/backupSchedule.py"
elif backupDest != "Home" and backupFreq == "Weekly": elif backupDest != "Home" and backupFreq == "Weekly":
cronJob = "0 3 * * 3 root python /usr/local/CyberCP/plogical/backupSchedule.py " cronJob = "0 0 * * 0 root python /usr/local/CyberCP/plogical/backupSchedule.py "
command = "cat " + path command = "cat " + path
output = ProcessUtilities.outputExecutioner(command) output = ProcessUtilities.outputExecutioner(command)
@@ -672,10 +672,10 @@ class BackupManager:
writeToFile.writelines(finalCronJob + "\n") writeToFile.writelines(finalCronJob + "\n")
writeToFile.close() writeToFile.close()
command = "sudo mv " + tempCronPath + " " + path command = "mv " + tempCronPath + " " + path
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
command = "sudo systemctl restart crond" command = "systemctl restart crond"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
destination = dest.objects.get(destLoc=backupDest) destination = dest.objects.get(destLoc=backupDest)
@@ -686,14 +686,13 @@ class BackupManager:
return HttpResponse(final_json) return HttpResponse(final_json)
except: except:
if backupDest == "Home" and backupFreq == "Daily": if backupDest == "Home" and backupFreq == "Daily":
cronJob = "0 3 * * 0-6 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py" cronJob = "0 3 * * * root python /usr/local/CyberCP/plogical/backupScheduleLocal.py"
elif backupDest == "Home" and backupFreq == "Weekly": elif backupDest == "Home" and backupFreq == "Weekly":
cronJob = "0 3 * * 3 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py" cronJob = "0 0 * * 0 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py "
elif backupDest != "Home" and backupFreq == "Daily": elif backupDest != "Home" and backupFreq == "Daily":
cronJob = "0 3 * * 0-6 root python /usr/local/CyberCP/plogical/backupSchedule.py" cronJob = "0 3 * * * root python /usr/local/CyberCP/plogical/backupSchedule.py"
elif backupDest != "Home" and backupFreq == "Weekly": elif backupDest != "Home" and backupFreq == "Weekly":
cronJob = "0 3 * * 3 root python /usr/local/CyberCP/plogical/backupSchedule.py" cronJob = "0 0 * * 0 root python /usr/local/CyberCP/plogical/backupSchedule.py "
command = "cat " + path command = "cat " + path
output = ProcessUtilities.outputExecutioner(command) output = ProcessUtilities.outputExecutioner(command)

View File

@@ -17,6 +17,7 @@ import plogical.CyberCPLogFileWriter as logging
from plogical.acl import ACLManager from plogical.acl import ACLManager
from manageServices.models import PDNSStatus from manageServices.models import PDNSStatus
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
from plogical.processUtilities import ProcessUtilities
# Create your views here. # Create your views here.
@@ -58,7 +59,12 @@ def getAdminStatus(request):
pdns = PDNSStatus.objects.get(pk=1) pdns = PDNSStatus.objects.get(pk=1)
currentACL['dnsAsWhole'] = pdns.serverStatus currentACL['dnsAsWhole'] = pdns.serverStatus
except: except:
if os.path.exists('/etc/pdns'): if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
pdnsPath = '/etc/powerdns'
else:
pdnsPath = '/etc/pdns'
if os.path.exists(pdnsPath):
PDNSStatus(serverStatus=1).save() PDNSStatus(serverStatus=1).save()
currentACL['dnsAsWhole'] = 1 currentACL['dnsAsWhole'] = 1
else: else:

View File

@@ -1151,7 +1151,7 @@ class preFlightsChecks:
'Change permissions for client.', 1, 0, os.EX_OSERR) 'Change permissions for client.', 1, 0, os.EX_OSERR)
impFile = ['/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf', '/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf', impFile = ['/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf', '/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf',
'/etc/dovecot/dovecot.conf', '/etc/pdns/pdns.conf', '/etc/pure-ftpd/db/mysql.conf'] '/etc/dovecot/dovecot.conf', '/etc/pdns/pdns.conf', '/etc/pure-ftpd/db/mysql.conf', '/etc/powerdns/pdns.conf']
for items in impFile: for items in impFile:
command = 'chmod 600 %s' % (items) command = 'chmod 600 %s' % (items)

View File

@@ -1443,7 +1443,7 @@ class Upgrade:
impFile = ['/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf', impFile = ['/etc/pure-ftpd/pure-ftpd.conf', '/etc/pure-ftpd/pureftpd-pgsql.conf',
'/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf', '/etc/pure-ftpd/pureftpd-mysql.conf', '/etc/pure-ftpd/pureftpd-ldap.conf',
'/etc/dovecot/dovecot.conf', '/etc/pdns/pdns.conf', '/etc/pure-ftpd/db/mysql.conf'] '/etc/dovecot/dovecot.conf', '/etc/pdns/pdns.conf', '/etc/pure-ftpd/db/mysql.conf', '/etc/powerdns/pdns.conf']
for items in impFile: for items in impFile:
command = 'chmod 600 %s' % (items) command = 'chmod 600 %s' % (items)
@@ -1513,16 +1513,18 @@ class Upgrade:
@staticmethod @staticmethod
def upgradeDovecot(): def upgradeDovecot():
try:
Upgrade.stdOut("Upgrading Dovecot..")
CentOSPath = '/etc/redhat-release' CentOSPath = '/etc/redhat-release'
if os.path.exists(CentOSPath): if os.path.exists(CentOSPath):
path = '/etc/yum.repos.d/dovecot.repo' path = '/etc/yum.repos.d/dovecot.repo'
content = """[dovecot-2.3-latest] content = """[dovecot-2.3-latest]
name=Dovecot 2.3 CentOS $releasever - $basearch name=Dovecot 2.3 CentOS $releasever - $basearch
baseurl=http://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch baseurl=http://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch
gpgkey=https://repo.dovecot.org/DOVECOT-REPO-GPG gpgkey=https://repo.dovecot.org/DOVECOT-REPO-GPG
gpgcheck=1 gpgcheck=1
enabled=1""" enabled=1"""
writeToFile = open(path, 'w') writeToFile = open(path, 'w')
writeToFile.write(content) writeToFile.write(content)
writeToFile.close() writeToFile.close()
@@ -1559,6 +1561,62 @@ enabled=1"""
command = "systemctl restart dovecot" command = "systemctl restart dovecot"
Upgrade.executioner(command, 0) Upgrade.executioner(command, 0)
else:
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'
Upgrade.executioner(command, 0)
except:
pass
try:
command = 'apt upgrade -y'
Upgrade.executioner(command, 0)
except:
pass
## Remove Default Password Scheme
path = '/etc/dovecot/dovecot-sql.conf.ext'
data = open(path, 'r').readlines()
updatePasswords = 1
writeToFile = open(path, 'w')
for items in data:
if items.find('default_pass_scheme') > -1:
updatePasswords = 0
continue
else:
writeToFile.writelines(items)
writeToFile.close()
if updatePasswords:
Upgrade.stdOut("Upgrading passwords...")
for items in EUsers.objects.all():
command = 'doveadm pw -p %s' % (items.password)
items.password = subprocess.check_output(shlex.split(command)).strip('\n')
items.save()
command = "systemctl restart dovecot"
Upgrade.executioner(command, 0)
Upgrade.stdOut("Dovecot upgraded.")
except BaseException, msg:
Upgrade.stdOut(str(msg) + " [upgradeDovecot]")
@staticmethod @staticmethod
def upgrade(): def upgrade():

0
static/dockerManager/dockerManager.js Executable file → Normal file
View File