Skip to content

Commit

Permalink
v1.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Oct 15, 2019
1 parent eaee1bc commit 28985ae
Show file tree
Hide file tree
Showing 13 changed files with 1,413 additions and 523 deletions.
711 changes: 344 additions & 367 deletions .idea/workspace.xml

Large diffs are not rendered by default.

253 changes: 127 additions & 126 deletions IncBackups/IncBackupsControl.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion IncBackups/templates/IncBackups/backupSchedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<div class="container">
<div id="page-title">
<h2>{% trans "Schedule Back up" %} - <a target="_blank" href="http://go.cyberpanel.net/remote-backup"
<h2>{% trans "Schedule Back up" %} - <a target="_blank" href="http://cyberpanel.net/"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "Remote Backups" %}</span></a></h2>
Expand Down
4 changes: 1 addition & 3 deletions IncBackups/templates/IncBackups/createBackup.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<div class="container">
<div id="page-title">
<h2>{% trans "Back up Website" %} - <a target="_blank" href="http://go.cyberpanel.net/backup"
<h2>{% trans "Back up Website" %} - <a target="_blank" href="https://cyberpanel.net/docs/2-create-restore-incremental-backups/"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "Backup Docs" %}</span></a>
</h2>
Expand Down Expand Up @@ -174,8 +174,6 @@ <h4 class="modal-title">Restore Points
<td>
<a ng-click="restorePoint(job.id, 0)" class="btn btn-border btn-alt border-green btn-link font-green"
title=""><span>Restore</span></a>
<a ng-click="restorePoint(job.id, 1)" class="btn btn-border btn-alt border-green btn-link font-green"
title=""><span>Restore and Reconstruct</span></a>
</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="container">
<div id="page-title">
<h2>{% trans "Set up Incremental Back up Destinations" %} - <a target="_blank"
href="http://go.cyberpanel.net/remote-backup"
href="https://cyberpanel.net/docs/1-add-remove-destinations-for-incremental-backups/"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "Remote Backups" %}</span></a>
Expand Down
34 changes: 21 additions & 13 deletions IncBackups/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.shortcuts import render
from plogical.acl import ACLManager
from django.shortcuts import HttpResponse
from django.shortcuts import HttpResponse, redirect
from plogical.processUtilities import ProcessUtilities
from plogical.virtualHostUtilities import virtualHostUtilities
import json
Expand All @@ -15,6 +15,7 @@
from random import randint
import time
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
from loginSystem.views import loadLoginPage
# Create your views here.


Expand All @@ -36,17 +37,19 @@ def createBackup(request):

path = '/home/cyberpanel/sftp'

for items in os.listdir(path):
destinations.append('sftp:%s' % (items))
if os.path.exists(path):
for items in os.listdir(path):
destinations.append('sftp:%s' % (items))

path = '/home/cyberpanel/aws'

for items in os.listdir(path):
destinations.append('s3:s3.amazonaws.com/%s' % (items))
if os.path.exists(path):
for items in os.listdir(path):
destinations.append('s3:s3.amazonaws.com/%s' % (items))

return defRenderer(request, 'IncBackups/createBackup.html', {'websiteList': websitesName, 'destinations': destinations})
except BaseException, msg:
return HttpResponse(str(msg))
logging.writeToFile(str(msg))
return redirect(loadLoginPage)

def backupDestinations(request):
try:
Expand All @@ -58,7 +61,8 @@ def backupDestinations(request):

return defRenderer(request, 'IncBackups/incrementalDestinations.html', {})
except BaseException, msg:
return HttpResponse(str(msg))
logging.writeToFile(str(msg))
return redirect(loadLoginPage)

def addDestination(request):
try:
Expand Down Expand Up @@ -559,15 +563,19 @@ def scheduleBackups(request):

path = '/home/cyberpanel/sftp'

for items in os.listdir(path):
destinations.append('sftp:%s' % (items))
if os.path.exists(path):
for items in os.listdir(path):
destinations.append('sftp:%s' % (items))

for items in os.listdir(path):
destinations.append('s3:s3.amazonaws.com/%s' % (items))
path = '/home/cyberpanel/aws'
if os.path.exists(path):
for items in os.listdir(path):
destinations.append('s3:s3.amazonaws.com/%s' % (items))

return defRenderer(request, 'IncBackups/backupSchedule.html', {'websiteList': websitesName, 'destinations': destinations})
except BaseException, msg:
return HttpResponse(str(msg))
logging.writeToFile(str(msg))
return redirect(loadLoginPage)

def submitBackupSchedule(request):
try:
Expand Down
6 changes: 3 additions & 3 deletions baseTemplate/templates/baseTemplate/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -588,18 +588,18 @@


<li>
<a href="{% url 'loadBackupHome' %}" title="{% trans 'Incremental Back up' %}">
<a href="{% url 'loadBackupHome' %}" title="{% trans 'Incremental Back up - Beta' %}">
<i class="glyph-icon tooltip-button icon-copy" title=".icon-folder"></i>
<span>{% trans "Incremental Back up" %}</span>
</a>
<div class="sidebar-submenu">

<ul>
<li class="createBackup"><a href="{% url 'createBackupInc' %}"
title="{% trans 'Create Back up' %}"><span>{% trans "Create Back up" %}</span></a>
title="{% trans 'Create Back up' %}"><span>{% trans "Create/Restore Back up" %}</span></a>
</li>
<li class="restoreBackup"><a href="{% url 'backupDestinationsInc' %}"
title="{% trans 'Restore Back up' %}"><span>{% trans "Add Destinations" %}</span></a>
title="{% trans 'Restore Back up' %}"><span>{% trans "Add/Remove Destinations" %}</span></a>
</li>
<li class="restoreBackup"><a href="{% url 'scheduleBackupsInc' %}"
title="{% trans 'Schedule Back ups' %}"><span>{% trans "Schedule Back ups" %}</span></a>
Expand Down
52 changes: 49 additions & 3 deletions install/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ def download_install_CyberPanel(self, mysqlPassword, mysql):

os.chdir(self.path)

command = "wget http://cyberpanel.sh/CyberPanel.1.9.0.tar.gz"
command = "wget http://cyberpanel.sh/CyberPanel.1.9.1.tar.gz"
# command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'CyberPanel Download',
Expand All @@ -960,7 +960,7 @@ def download_install_CyberPanel(self, mysqlPassword, mysql):
##

count = 0
command = "tar zxf CyberPanel.1.9.0.tar.gz"
command = "tar zxf CyberPanel.1.9.1.tar.gz"
# command = "tar zxf CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'Extract CyberPanel', 1, 1, os.EX_OSERR)
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def download_install_CyberPanel(self, mysqlPassword, mysql):
path = "/usr/local/CyberCP/version.txt"
writeToFile = open(path, 'w')
writeToFile.writelines('1.9\n')
writeToFile.writelines('0')
writeToFile.writelines('1')
writeToFile.close()
except:
pass
Expand Down Expand Up @@ -3689,6 +3689,51 @@ def setUpFirstAccount():
except:
pass

def installRestic(self):
try:

CentOSPath = '/etc/redhat-release'

if os.path.exists(CentOSPath):
command = 'yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo'
preFlightsChecks.call(command, self.distro, '[installRestic]',
'Add restic repo.',
1, 0, os.EX_OSERR)

command = 'yum install restic -y'
preFlightsChecks.call(command, self.distro, '[installRestic]',
'Install Restic.',
1, 0, os.EX_OSERR)
else:
command = 'apt-get update -y'
preFlightsChecks.call(command, self.distro, '[installRestic]',
'Install Restic.',
1, 0, os.EX_OSERR)

command = 'apt-get install restic -y'
preFlightsChecks.call(command, self.distro, '[installRestic]',
'Install Restic.',
1, 0, os.EX_OSERR)


cronTab = '/etc/crontab'

data = open(cronTab, 'r').read()

if data.find('IncScheduler') == -1:
cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'

writeToFile = open(cronTab, 'a')
writeToFile.writelines(cronJob)

cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
writeToFile.writelines(cronJob)
writeToFile.close()


except:
pass


def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
Expand Down Expand Up @@ -3813,6 +3858,7 @@ def main():
checks.download_install_phpmyadmin()
checks.setupCLI()
checks.setup_cron()
checks.installRestic()
# checks.installdnsPython()

## Install and Configure OpenDKIM.
Expand Down
2 changes: 1 addition & 1 deletion loginSystem/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def loadLoginPage(request):
firstName="Cyber",lastName="Panel", acl=acl, token=token)
admin.save()

vers = version(currentVersion="1.9", build=0)
vers = version(currentVersion="1.9", build=1)
vers.save()

package = Package(admin=admin, packageName="Default", diskSpace=1000,
Expand Down
2 changes: 1 addition & 1 deletion plogical/adminPass.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def main():
firstName="Cyber", lastName="Panel", acl=acl, token=token)
admin.save()

vers = version(currentVersion="1.9", build=0)
vers = version(currentVersion="1.9", build=1)
vers.save()

package = Package(admin=admin, packageName="Default", diskSpace=1000,
Expand Down
110 changes: 109 additions & 1 deletion plogical/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,73 @@ def GeneralMigrations():
except:
pass

@staticmethod
def IncBackupMigrations():
try:
connection, cursor = Upgrade.setupConnection('cyberpanel')

query = """CREATE TABLE `IncBackups_backupjob` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`destination` varchar(300) NOT NULL,
`frequency` varchar(50) NOT NULL,
`websiteData` int(11) NOT NULL,
`websiteDatabases` int(11) NOT NULL,
`websiteDataEmails` int(11) NOT NULL,
PRIMARY KEY (`id`)
)"""
try:
cursor.execute(query)
except:
pass

query = """CREATE TABLE `IncBackups_incjob` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` datetime(6) NOT NULL,
`website_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `IncBackups_incjob_website_id_aad31bf6_fk_websiteFu` (`website_id`),
CONSTRAINT `IncBackups_incjob_website_id_aad31bf6_fk_websiteFu` FOREIGN KEY (`website_id`) REFERENCES `websiteFunctions_websites` (`id`)
)"""
try:
cursor.execute(query)
except:
pass

query = """CREATE TABLE `IncBackups_jobsites` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`website` varchar(300) NOT NULL,
`job_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `IncBackups_jobsites_job_id_494a1f69_fk_IncBackups_backupjob_id` (`job_id`),
CONSTRAINT `IncBackups_jobsites_job_id_494a1f69_fk_IncBackups_backupjob_id` FOREIGN KEY (`job_id`) REFERENCES `IncBackups_backupjob` (`id`)
)"""
try:
cursor.execute(query)
except:
pass

query = """CREATE TABLE `IncBackups_jobsnapshots` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(300) NOT NULL,
`snapshotid` varchar(50) NOT NULL,
`job_id` int(11) NOT NULL,
`destination` varchar(200) NOT NULL,
PRIMARY KEY (`id`),
KEY `IncBackups_jobsnapshots_job_id_a8237ca8_fk_IncBackups_incjob_id` (`job_id`),
CONSTRAINT `IncBackups_jobsnapshots_job_id_a8237ca8_fk_IncBackups_incjob_id` FOREIGN KEY (`job_id`) REFERENCES `IncBackups_incjob` (`id`)
)"""
try:
cursor.execute(query)
except:
pass

try:
connection.close()
except:
pass
except:
pass

@staticmethod
def enableServices():
try:
Expand Down Expand Up @@ -1267,6 +1334,11 @@ def downloadAndUpgrade(versionNumbring):
if items.find('CLManager') > -1:
CLManager = 0

IncBackups = 1
for items in data:
if items.find('IncBackups') > -1:
IncBackups = 0

Upgrade.stdOut('Restoring settings file!')

writeToFile = open("/usr/local/CyberCP/CyberCP/settings.py", 'w')
Expand Down Expand Up @@ -1295,9 +1367,13 @@ def downloadAndUpgrade(versionNumbring):
if manageServices == 1:
writeToFile.writelines(" 'manageServices',\n")


if CLManager == 1:
writeToFile.writelines(" 'CLManager',\n")

if IncBackups == 1:
writeToFile.writelines(" 'IncBackups',\n")

else:
writeToFile.writelines(items)

Expand Down Expand Up @@ -1542,7 +1618,6 @@ def installPHP73():
Upgrade.executioner(command, 'Set default PHP 7.0, 0')



@staticmethod
def someDirectories():
command = "mkdir -p /usr/local/lscpd/admin/"
Expand Down Expand Up @@ -1741,6 +1816,37 @@ def upgradeDovecot():
except BaseException, msg:
Upgrade.stdOut(str(msg) + " [upgradeDovecot]")

@staticmethod
def installRestic():
CentOSPath = '/etc/redhat-release'

if os.path.exists(CentOSPath):
command = 'yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo'
Upgrade.executioner(command, 'Add restic repo.')

command = 'yum install restic -y'
Upgrade.executioner(command, 'Install Restic')
else:
command = 'apt-get update -y'
Upgrade.executioner(command, 'Install Restic')

command = 'apt-get install restic -y'
Upgrade.executioner(command, 'Install Restic')

cronTab = '/etc/crontab'

data = open(cronTab, 'r').read()

if data.find('IncScheduler') == -1:
cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'

writeToFile = open(cronTab, 'a')
writeToFile.writelines(cronJob)

cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
writeToFile.writelines(cronJob)
writeToFile.close()

@staticmethod
def upgrade():

Expand Down Expand Up @@ -1796,6 +1902,8 @@ def upgrade():
Upgrade.emailMarketingMigrationsa()
Upgrade.dockerMigrations()
Upgrade.CLMigrations()
Upgrade.IncBackupMigrations()
Upgrade.installRestic()

##

Expand Down
Loading

0 comments on commit 28985ae

Please sign in to comment.