Merge branch 'v2.0.1' of https://github.com/usmannasir/cyberpanel into v2.0.1

This commit is contained in:
Linunaut
2020-04-28 21:10:52 +02:00
18 changed files with 3444 additions and 197 deletions

2984
AllCPUbuntu.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -79,48 +79,51 @@ class CloudLinuxUsers(CLMain):
def fetchJson(self, websites):
users = []
for webs in websites:
itemPackage = webs.package
package = {'name': itemPackage.packageName, 'owner': webs.externalApp}
try:
itemPackage = webs.package
package = {'name': itemPackage.packageName, 'owner': webs.externalApp}
user = {}
user = {}
if self.id:
user['id'] = pwd.getpwnam(webs.externalApp).pw_uid
if self.un:
user['username'] = webs.externalApp
if self.ow:
user['owner'] = webs.externalApp
if self.domain:
user['domain'] = webs.domain
if self.package:
user['package'] = package
if self.email:
user['email'] = webs.adminEmail
if self.localecode:
user['locale_code'] = "EN_us"
if self.packageName != None:
if self.package:
if self.packageName == user['package']['name'] and self.packageOwner == user['package']['owner']:
pass
else:
continue
if self.uid !=None:
if self.id:
if self.uid == user['id']:
user['id'] = pwd.getpwnam(webs.externalApp).pw_uid
if self.un:
user['username'] = webs.externalApp
if self.ow:
user['owner'] = webs.externalApp
if self.domain:
user['domain'] = webs.domain
if self.package:
user['package'] = package
if self.email:
user['email'] = webs.adminEmail
if self.localecode:
user['locale_code'] = "EN_us"
if self.packageName != None:
if self.package:
if self.packageName == user['package']['name'] and self.packageOwner == user['package']['owner']:
pass
else:
continue
if self.uid !=None:
if self.id:
if self.uid == user['id']:
users.append(user)
else:
users.append(user)
else:
users.append(user)
else:
users.append(user)
except BaseException as msg:
pass
final = {'data': users, 'metadata': self.initialMeta}
print(json.dumps(final))

192
CPCent7repo.json Normal file
View File

@@ -0,0 +1,192 @@
[
{
"Package": "MariaDB-client.x86_64",
"Version": "10.1.44-1.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "MariaDB-common.x86_64",
"Version": "10.1.44-1.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "MariaDB-devel.x86_64",
"Version": "10.1.44-1.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "MariaDB-server.x86_64",
"Version": "10.1.44-1.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "MariaDB-shared.x86_64",
"Version": "10.1.44-1.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "compat-libtidy.x86_64",
"Version": "0.99.0-37.20091203.el7",
"Repo": "@CyberPanel"
},
{
"Package": "dovecot.x86_64",
"Version": "2:2.3.10-2",
"Repo": "@CyberPanel"
},
{
"Package": "dovecot-mysql.x86_64",
"Version": "2:2.3.10-2",
"Repo": "@CyberPanel"
},
{
"Package": "fastlz.x86_64",
"Version": "0.1.0-0.1.20070619svnrev12.el7",
"Repo": "@CyberPanel"
},
{
"Package": "galera.x86_64",
"Version": "25.3.28-1.rhel7.el7.centos",
"Repo": "@CyberPanel"
},
{
"Package": "htop.x86_64",
"Version": "2.2.0-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "jemalloc.x86_64",
"Version": "3.6.0-1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libargon2.x86_64",
"Version": "20161029-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libbsd.x86_64",
"Version": "0.8.3-1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libc-client.x86_64",
"Version": "2007f-16.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libdb4.x86_64",
"Version": "4.8.30-13.el7",
"Repo": "@CyberPanel"
},
{
"Package": "liblzf.x86_64",
"Version": "3.6-7.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libmcrypt.x86_64",
"Version": "2.5.8-13.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libopendkim.x86_64",
"Version": "2.11.0-0.1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libsodium.x86_64",
"Version": "1.0.18-1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "libtidy.x86_64",
"Version": "5.4.0-1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "luajit.x86_64",
"Version": "2.0.4-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "oniguruma.x86_64",
"Version": "5.9.5-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "opendbx.x86_64",
"Version": "1.4.6-6.el7",
"Repo": "@CyberPanel"
},
{
"Package": "opendkim.x86_64",
"Version": "2.11.0-0.1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "pdns.x86_64",
"Version": "4.2.2-1pdns.el7",
"Repo": "@CyberPanel"
},
{
"Package": "pdns-backend-mysql.x86_64",
"Version": "4.2.2-1pdns.el7",
"Repo": "@CyberPanel"
},
{
"Package": "postfix3.x86_64",
"Version": "2:3.4.7-1.gf.el7",
"Repo": "@CyberPanel"
},
{
"Package": "postfix3-ldap.x86_64",
"Version": "2:3.4.7-1.gf.el7",
"Repo": "@CyberPanel"
},
{
"Package": "postfix3-mysql.x86_64",
"Version": "2:3.4.7-1.gf.el7",
"Repo": "@CyberPanel"
},
{
"Package": "postfix3-pcre.x86_64",
"Version": "2:3.4.7-1.gf.el7",
"Repo": "@CyberPanel"
},
{
"Package": "pure-ftpd.x86_64",
"Version": "1.0.47-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "redis.x86_64",
"Version": "3.2.12-2.el7",
"Repo": "@CyberPanel"
},
{
"Package": "restic.x86_64",
"Version": "0.9.6-1.el7",
"Repo": "@CyberPanel"
},
{
"Package": "rsync31u.x86_64",
"Version": "3.1.3-1.ius.el7",
"Repo": "@CyberPanel"
},
{
"Package": "udns.x86_64",
"Version": "0.4-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "udns-devel.x86_64",
"Version": "0.4-3.el7",
"Repo": "@CyberPanel"
},
{
"Package": "vim-minimal.x86_64",
"Version": "2:8.0.003-1.gf.el7",
"Repo": "@CyberPanel"
}
]

View File

@@ -407,46 +407,65 @@ class BackupManager:
destinations = backupUtil.backupUtilities.destinationsPath
ipAddress = data['IPAddress']
password = data['password']
finalDic = {}
finalDic['ipAddress'] = data['IPAddress']
finalDic['password'] = data['password']
try:
finalDic['port'] = data['backupSSHPort']
except:
finalDic['port'] = "22"
try:
finalDic['user'] = data['user']
except:
finalDic['user'] = "root"
if dest.objects.all().count() == 2:
final_dic = {'destStatus': 0,
'error_message': "Currently only one remote destination is allowed."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
try:
d = dest.objects.get(destLoc=ipAddress)
d = dest.objects.get(destLoc=finalDic['password'])
final_dic = {'destStatus': 0, 'error_message': "This destination already exists."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except:
try:
port = data['backupSSHPort']
except:
port = "22"
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " submitDestinationCreation --ipAddress " + ipAddress + " --password " \
+ password + " --port " + port
execPath = execPath + " submitDestinationCreation --ipAddress " + finalDic['ipAddress'] + " --password " \
+ finalDic['password'] + " --port " + finalDic['port'] + ' --user %s' % (finalDic['user'])
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(execPath)
output = ProcessUtilities.outputExecutioner(execPath)
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(output)
if output.find('1,') > -1:
try:
writeToFile = open(destinations, "w")
writeToFile.writelines(ipAddress + "\n")
writeToFile.writelines(data['backupSSHPort'] + "\n")
writeToFile.write(json.dumps(finalDic))
writeToFile.close()
newDest = dest(destLoc=ipAddress)
newDest = dest(destLoc=finalDic['ipAddress'])
newDest.save()
final_dic = {'destStatus': 1, 'error_message': "None"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except:
writeToFile = open(destinations, "w")
writeToFile.writelines(ipAddress + "\n")
writeToFile.writelines("22" + "\n")
writeToFile.write(json.dumps(finalDic))
writeToFile.close()
newDest = dest(destLoc=ipAddress)
newDest = dest(destLoc=finalDic['ipAddress'])
newDest.save()
final_dic = {'destStatus': 1, 'error_message': "None"}

View File

@@ -416,7 +416,7 @@ app.controller('restoreWebsiteControl', function ($scope, $http, $timeout) {
});
//*** Resotre site ends here ***///
//*** Restore site ends here ***///
///** Backup Destination ***//
@@ -448,6 +448,7 @@ app.controller('backupDestinations', function ($scope, $http, $timeout) {
var data = {
IPAddress: $scope.IPAddress,
password: $scope.password,
user: $scope.user,
backupSSHPort: $scope.backupSSHPort,
};

View File

@@ -33,6 +33,13 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "User" %}</label>
<div class="col-sm-6">
<input placeholder="{% trans "Backup server SSH User, leave empty for root." %}" type="text" class="form-control" ng-model="user" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
@@ -48,7 +55,6 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">

View File

@@ -5,7 +5,6 @@
SUDO_TEST=$(set)
DEV="OFF"
BRANCH="stable"
POSTFIX_VARIABLE="ON"
POWERDNS_VARIABLE="ON"
PUREFTPD_VARIABLE="ON"

View File

@@ -1,4 +1,5 @@
#!/bin/bash
#CyberPanel Upgrade script
export LC_CTYPE=en_US.UTF-8
@@ -28,13 +29,6 @@ rm -f /etc/yum.repos.d/gf.repo
rm -f /etc/yum.repos.d/powerdns-auth-42.repo
rm -rf /etc/yum.repos.d/powerdns-auth-master.repo
rm -rf /etc/yum.repos.d/gf.repo.rpmnew
#sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-AppStream.repo
yum clean all
yum update -y
yum autoremove epel-release -y
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel.repo.rpmsave
##
@@ -171,18 +165,27 @@ if echo $OUTPUT | grep -q "CentOS Linux 7" ; then
curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo > /etc/yum.repos.d/CyberPanel.repo
yum clean all
yum update -y
yum autoremove epel-release -y
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel.repo.rpmsave
elif echo $OUTPUT | grep -q "CloudLinux 7" ; then
echo -e "\nDetecting CloudLinux 7.X...\n"
SERVER_OS="CentOS7"
curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo > /etc/yum.repos.d/CyberPanel.repo
yum clean all
yum update -y
yum autoremove epel-release -y
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel.repo.rpmsave
elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then
curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel8.repo > /etc/yum.repos.d/CyberPanel.repo
echo -e "\nDetecting CentOS 8.X...\n"
SERVER_OS="CentOS8"
yum clean all
yum update -y
yum autoremove epel-release -y
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel.repo.rpmsave
elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then
echo -e "\nDetecting Ubuntu 18.04...\n"
SERVER_OS="Ubuntu"
@@ -285,6 +288,7 @@ else
fi
check_return
if [ $SERVER_OS = "Ubuntu" ] ; then
. /usr/local/CyberCP/bin/activate
check_return

View File

@@ -385,10 +385,10 @@ class FileManager:
domainName = self.data['domainName']
website = Websites.objects.get(domain=domainName)
command = 'chown %s:%s %s' % (website.externalApp, website.externalApp, self.data['completePath'] + '/' + myfile.name)
command = 'chown %s:%s %s' % (website.externalApp, website.externalApp, self.returnPathEnclosed(self.data['completePath'] + '/' + myfile.name))
ProcessUtilities.executioner(command)
self.changeOwner(self.data['completePath'] + '/' + myfile.name)
self.changeOwner(self.returnPathEnclosed(self.data['completePath'] + '/' + myfile.name))
json_data = json.dumps(finalData)
return HttpResponse(json_data)
@@ -420,7 +420,7 @@ class FileManager:
ProcessUtilities.executioner(command, website.externalApp)
self.changeOwner(self.data['extractionLocation'])
self.fixPermissions(domainName)
json_data = json.dumps(finalData)
return HttpResponse(json_data)

View File

@@ -1479,7 +1479,6 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
// Download files
$scope.downloadFile = function () {
url = "/filemanager/downloadFile";
var downloadURL = $scope.currentPath + "/" + allFilesAndFolders[0];
window.location.href = url + '?domainName=' + domainName + '&fileToDownload=' + downloadURL;

View File

@@ -66,7 +66,9 @@ def downloadFile(request):
admin = Administrator.objects.get(pk=userID)
import urllib.parse
fileToDownload = urllib.parse.unquote(request.GET.get('fileToDownload'))
fileToDownload = request.build_absolute_uri().split('fileToDownload')[1][1:]
fileToDownload = urllib.parse.unquote(fileToDownload)
domainName = request.GET.get('domainName')
currentACL = ACLManager.loadedACL(userID)

View File

@@ -330,14 +330,13 @@ class InstallCyberPanel:
def installPureFTPD(self):
if self.distro == ubuntu:
command = 'DEBIAN_FRONTEND=noninteractive apt install pure-ftpd-mysql -y'
os.system(command)
command = 'wget https://ubuntu.cyberpanel.net/pool/main/p/pure-ftpd/pure-ftpd-common_1.0.47-3_all.deb'
command = 'wget https://rep.cyberpanel.net/pure-ftpd-common_1.0.47-3_all.deb'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
command = 'wget https://ubuntu.cyberpanel.net/pool/main/p/pure-ftpd/pure-ftpd-mysql_1.0.47-3_amd64.deb'
command = 'wget https://rep.cyberpanel.net/pure-ftpd-mysql_1.0.47-3_amd64.deb'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
command = 'dpkg --install --force-confold pure-ftpd-common_1.0.47-3_all.deb'
@@ -354,7 +353,6 @@ class InstallCyberPanel:
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
####### Install pureftpd to system startup
command = "systemctl enable " + install.preFlightsChecks.pureFTPDServiceName(self.distro)

View File

@@ -135,7 +135,7 @@ class backupSchedule:
return 0, str(msg)
@staticmethod
def createBackup(virtualHost, ipAddress, backupLogPath , port):
def createBackup(virtualHost, ipAddress, backupLogPath , port='22', user='root'):
try:
backupSchedule.remoteBackupLogging(backupLogPath, "Preparing to create backup for: " + virtualHost)
@@ -152,7 +152,7 @@ class backupSchedule:
backupSchedule.remoteBackupLogging(backupLogPath, "Preparing to send backup for: " + virtualHost +" to " + ipAddress)
backupSchedule.sendBackup(backupPath+".tar.gz", ipAddress, backupLogPath, port)
backupSchedule.sendBackup(backupPath+".tar.gz", ipAddress, backupLogPath, port, user)
backupSchedule.remoteBackupLogging(backupLogPath, "Backup for: " + virtualHost + " is sent to " + ipAddress)
@@ -180,7 +180,7 @@ class backupSchedule:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupSchedule.createBackup]")
@staticmethod
def sendBackup(backupPath, IPAddress, backupLogPath , port):
def sendBackup(backupPath, IPAddress, backupLogPath , port='22', user='root'):
try:
## IPAddress of local server
@@ -193,7 +193,7 @@ class backupSchedule:
##
writeToFile = open(backupLogPath, "a")
command = "sudo scp -o StrictHostKeyChecking=no -P "+port+" -i /root/.ssh/cyberpanel " + backupPath + " root@"+IPAddress+":/home/backup/" + ipAddressLocal + "/" + time.strftime("%a-%b") + "/"
command = "sudo scp -o StrictHostKeyChecking=no -P "+port+" -i /root/.ssh/cyberpanel " + backupPath + " " + user + "@" + IPAddress+":~/backup/" + ipAddressLocal + "/" + time.strftime("%a-%b") + "/"
subprocess.call(shlex.split(command), stdout=writeToFile)
## Remove backups already sent to remote destinations
@@ -219,9 +219,16 @@ class backupSchedule:
## IP of Remote server.
data = open(destinations,'r').readlines()
ipAddress = data[0].strip("\n")
port = data[1].strip("\n")
destinations = backupUtilities.destinationsPath
data = json.loads(open(destinations, 'r').read())
port = data['port']
try:
user = data['user']
except:
user = 'root'
ipAddress = data['ipAddress']
## IPAddress of local server
@@ -241,16 +248,16 @@ class backupSchedule:
"Connection to: " + ipAddress + " Failed, please resetup this destination from CyberPanel, aborting.")
return 0
else:
## Create backup dir on remote server
## Create backup dir on remote server in ~/backup
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + ipAddress + " mkdir -p /home/backup/" + ipAddressLocal + "/" + time.strftime(
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel " + user + "@" + ipAddress + " mkdir -p ~/backup/" + ipAddressLocal + "/" + time.strftime(
"%a-%b")
subprocess.call(shlex.split(command))
pass
for virtualHost in os.listdir("/home"):
if match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', virtualHost, M | I):
backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port)
backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port, user)
backupSchedule.remoteBackupLogging(backupLogPath, "Remote backup job completed.\n")

View File

@@ -1,6 +1,8 @@
import os,sys
import os, sys
sys.path.append('/usr/local/CyberCP')
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
try:
django.setup()
@@ -10,13 +12,14 @@ import pexpect
from plogical import CyberCPLogFileWriter as logging
import subprocess
import shlex
from shutil import make_archive,rmtree
from shutil import make_archive, rmtree
from plogical import mysqlUtilities
import tarfile
from multiprocessing import Process
import signal
from plogical.installUtilities import installUtilities
import argparse
try:
from plogical.virtualHostUtilities import virtualHostUtilities
from plogical.sslUtilities import sslUtilities
@@ -32,6 +35,7 @@ from shutil import copy
from distutils.dir_util import copy_tree
from random import randint
from plogical.processUtilities import ProcessUtilities
try:
from websiteFunctions.models import Websites, ChildDomains, Backups
from databases.models import Databases
@@ -45,12 +49,13 @@ except:
VERSION = '2.0'
BUILD = 1
## I am not the monster that you think I am..
class backupUtilities:
Server_root = "/usr/local/lsws"
completeKeyPath = "/home/cyberpanel/.ssh"
completeKeyPath = "/home/cyberpanel/.ssh"
destinationsPath = "/home/cyberpanel/destinations"
licenseKey = '/usr/local/lsws/conf/license.key'
@@ -190,11 +195,9 @@ class backupUtilities:
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
'While creating backup for %s, we failed to backup database %s. Error message: %s' % (
backupDomain, items.dbName, str(msg)))
backupDomain, items.dbName, str(msg)))
continue
databaseXML = Element('database')
child = SubElement(databaseXML, 'dbName')
@@ -276,7 +279,6 @@ class backupUtilities:
## Email meta generated!
def prettify(elem):
"""Return a pretty-printed XML string for the Element.
"""
@@ -284,8 +286,6 @@ class backupUtilities:
reparsed = minidom.parseString(rough_string)
return reparsed.toprettyxml(indent=" ")
## /home/example.com/backup/backup-example.com-02.13.2018_10-24-52/meta.xml -- metaPath
metaPath = '/tmp/%s' % (str(randint(1000, 9999)))
@@ -298,22 +298,21 @@ class backupUtilities:
## meta generated
newBackup = Backups(website=website, fileName=backupName, date=time.strftime("%m.%d.%Y_%H-%M-%S"),
size=0, status=1)
newBackup.save()
logging.CyberCPLogFileWriter.statusWriter(status, 'Meta data is ready..')
return 1,'None', metaPath
return 1, 'None', metaPath
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, "%s [207][5009]" % (str(msg)))
return 0,str(msg)
return 0, str(msg)
@staticmethod
def startBackup(tempStoragePath, backupName, backupPath, metaPath = None):
def startBackup(tempStoragePath, backupName, backupPath, metaPath=None):
try:
## /home/example.com/backup/backup-example.com-02.13.2018_10-24-52 -- tempStoragePath
@@ -327,12 +326,12 @@ class backupUtilities:
writeToFile.writelines(str(os.getpid()))
writeToFile.close()
backupFileNamePath = os.path.join(backupPath,"backupFileName")
backupFileNamePath = os.path.join(backupPath, "backupFileName")
logging.CyberCPLogFileWriter.statusWriter(backupFileNamePath, backupName)
#####
status = os.path.join(backupPath,'status')
status = os.path.join(backupPath, 'status')
logging.CyberCPLogFileWriter.statusWriter(status, "Making archive of home directory.\n")
@@ -340,7 +339,7 @@ class backupUtilities:
## /home/example.com/backup/backup-example.com-02.13.2018_10-24-52 -- tempStoragePath
metaPathInBackup = os.path.join(tempStoragePath,'meta.xml')
metaPathInBackup = os.path.join(tempStoragePath, 'meta.xml')
if metaPath != None:
writeToFile = open(metaPathInBackup, 'w')
@@ -349,7 +348,6 @@ class backupUtilities:
backupMetaData = ElementTree.parse(metaPathInBackup)
##### Making archive of home directory
domainName = backupMetaData.find('masterDomain').text
@@ -366,10 +364,9 @@ class backupUtilities:
## Stop making archive of document_root and copy instead
copy_tree('/home/%s/public_html' % domainName, '%s/%s' % (tempStoragePath, 'public_html'))
#make_archive(os.path.join(tempStoragePath,"public_html"), 'gztar', os.path.join("/home",domainName,"public_html"))
# make_archive(os.path.join(tempStoragePath,"public_html"), 'gztar', os.path.join("/home",domainName,"public_html"))
##
@@ -378,7 +375,7 @@ class backupUtilities:
except BaseException as msg:
try:
os.remove(os.path.join(backupPath,backupName+".tar.gz"))
os.remove(os.path.join(backupPath, backupName + ".tar.gz"))
except:
pass
@@ -388,8 +385,8 @@ class backupUtilities:
pass
status = os.path.join(backupPath, 'status')
logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, "+ str(msg) + ".[365] [5009]")
print(("Aborted, "+ str(msg) + ".[365] [5009]"))
logging.CyberCPLogFileWriter.statusWriter(status, "Aborted, " + str(msg) + ".[365] [5009]")
print(("Aborted, " + str(msg) + ".[365] [5009]"))
os.remove(pidFile)
@@ -462,7 +459,8 @@ class backupUtilities:
domainName = backupMetaData.find('masterDomain').text
if os.path.islink(status) or os.path.islink(tempStoragePath or os.path.islink(backupPath)) or os.path.islink(metaPath):
if os.path.islink(status) or os.path.islink(tempStoragePath or os.path.islink(backupPath)) or os.path.islink(
metaPath):
logging.CyberCPLogFileWriter.writeToFile('symlinked.')
logging.CyberCPLogFileWriter.statusWriter(status, 'Symlink attack. [365][5009]')
return 0
@@ -482,37 +480,37 @@ class backupUtilities:
rmtree(tempStoragePath)
###
backupFileNamePath = os.path.join(backupPath,"backupFileName")
fileName = open(backupFileNamePath, 'r').read()
backupObs = Backups.objects.filter(fileName=fileName)
backupObs = Backups.objects.filter(fileName=backupName)
## adding backup data to database.
filePath = '%s/%s.tar.gz' % (backupPath, backupName)
totalSize = '%sMB' % (str(int(os.path.getsize(filePath) / 1048576)))
try:
for items in backupObs:
items.status = 1
items.size = str(int(float(
os.path.getsize(os.path.join(backupPath,backupName+".tar.gz"))) / (
1024.0 * 1024.0))) + "MB"
items.size = totalSize
items.save()
except:
logging.CyberCPLogFileWriter.writeToFile(' again size: %s' % (totalSize))
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile('%s. [backupRoot:499]' % str(msg))
for items in backupObs:
items.status = 1
items.size = str(int(float(
os.path.getsize(os.path.join(backupPath,backupName+".tar.gz"))) / (
1024.0 * 1024.0))) + "MB"
items.size = totalSize
items.save()
command = 'chmod 600 %s' % (os.path.join(backupPath,backupName+".tar.gz"))
command = 'chmod 600 %s' % (os.path.join(backupPath, backupName + ".tar.gz"))
ProcessUtilities.executioner(command)
logging.CyberCPLogFileWriter.statusWriter(status, "Completed\n")
os.remove(pidFile)
@staticmethod
def initiateBackup(tempStoragePath,backupName,backupPath):
def initiateBackup(tempStoragePath, backupName, backupPath):
try:
p = Process(target=backupUtilities.startBackup, args=(tempStoragePath,backupName,backupPath,))
p = Process(target=backupUtilities.startBackup, args=(tempStoragePath, backupName, backupPath,))
p.start()
pid = open(backupPath + 'pid', "w")
pid.write(str(p.pid))
@@ -581,14 +579,11 @@ class backupUtilities:
if Websites.objects.filter(domain=domain).count() > 0:
raise BaseException('This website already exists.')
if ChildDomains.objects.filter(domain=domain).count() > 0:
raise BaseException("This website already exists as child domain.")
####### Pre-creation checks ends
## Create Configurations
result = virtualHostUtilities.createVirtualHost(domain, siteUser.email, phpSelection, externalApp, 0, 1, 0,
@@ -623,7 +618,6 @@ class backupUtilities:
zone = DNS.getZoneObject(domain)
for dnsrecord in dnsrecords:
recordType = dnsrecord.find('type').text
value = dnsrecord.find('name').text
content = dnsrecord.find('content').text
@@ -631,8 +625,7 @@ class backupUtilities:
DNS.createDNSRecord(zone, value, recordType, content, prio, 3600)
return 1,'None'
return 1, 'None'
except BaseException as msg:
return 0, str(msg)
@@ -643,28 +636,28 @@ class backupUtilities:
if dir == "CyberPanelRestore":
backupFileName = backupName.strip(".tar.gz")
completPath = os.path.join("/home","backup",backupFileName) ## without extension
originalFile = os.path.join("/home","backup",backupName) ## with extension
completPath = os.path.join("/home", "backup", backupFileName) ## without extension
originalFile = os.path.join("/home", "backup", backupName) ## with extension
elif dir == 'CLI':
completPath = backupName.strip(".tar.gz") ## without extension
originalFile = backupName ## with extension
else:
backupFileName = backupName.strip(".tar.gz")
completPath = "/home/backup/transfer-"+str(dir)+"/"+backupFileName ## without extension
originalFile = "/home/backup/transfer-"+str(dir)+"/"+backupName ## with extension
completPath = "/home/backup/transfer-" + str(dir) + "/" + backupFileName ## without extension
originalFile = "/home/backup/transfer-" + str(dir) + "/" + backupName ## with extension
pathToCompressedHome = os.path.join(completPath,"public_html.tar.gz")
pathToCompressedHome = os.path.join(completPath, "public_html.tar.gz")
if not os.path.exists(completPath):
os.mkdir(completPath)
## Writing pid of restore process
pid = os.path.join(completPath,'pid')
pid = os.path.join(completPath, 'pid')
logging.CyberCPLogFileWriter.statusWriter(pid, str(os.getpid()))
status = os.path.join(completPath,'status')
status = os.path.join(completPath, 'status')
logging.CyberCPLogFileWriter.statusWriter(status, "Extracting Main Archive!")
## Converting /home/backup/backup-example.com-02.13.2018_10-24-52.tar.gz -> /home/backup/backup-example.com-02.13.2018_10-24-52
@@ -681,7 +674,6 @@ class backupUtilities:
backupMetaData = ElementTree.parse(os.path.join(completPath, "meta.xml"))
masterDomain = backupMetaData.find('masterDomain').text
twoPointO = 0
try:
version = backupMetaData.find('VERSION').text
@@ -713,10 +705,10 @@ class backupUtilities:
logging.CyberCPLogFileWriter.writeToFile('%s. [555:startRestore]' % (str(msg)))
else:
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + result[1] + ". Not able to create Account, Databases and DNS Records, aborting. [575][5009]")
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + result[
1] + ". Not able to create Account, Databases and DNS Records, aborting. [575][5009]")
return 0
########### Creating child/sub/addon/parked domains
logging.CyberCPLogFileWriter.statusWriter(status, "Creating Child Domains!")
@@ -724,7 +716,7 @@ class backupUtilities:
## Reading meta file to create subdomains
externalApp = backupMetaData.find('externalApp').text
websiteHome = os.path.join("/home",masterDomain,"public_html")
websiteHome = os.path.join("/home", masterDomain, "public_html")
### Restoring Child Domains if any.
@@ -747,7 +739,8 @@ class backupUtilities:
phpSelection = childDomain.find('phpSelection').text
path = childDomain.find('path').text
retValues = virtualHostUtilities.createDomain(masterDomain, domain, phpSelection, path, 0, 0, 0, 'admin', 0)
retValues = virtualHostUtilities.createDomain(masterDomain, domain, phpSelection, path, 0, 0, 0,
'admin', 0)
if retValues[0] == 1:
if os.path.exists(websiteHome):
@@ -780,7 +773,8 @@ class backupUtilities:
except:
pass
except:
logging.CyberCPLogFileWriter.writeToFile('While restoring backup we had minor issues for rebuilding vhost conf for: ' + domain + '. However this will be auto healed.')
logging.CyberCPLogFileWriter.writeToFile(
'While restoring backup we had minor issues for rebuilding vhost conf for: ' + domain + '. However this will be auto healed.')
if float(version) > 2.0 or float(build) > 0:
if path.find('/home/%s/public_html' % masterDomain) == -1:
@@ -789,11 +783,12 @@ class backupUtilities:
continue
else:
logging.CyberCPLogFileWriter.writeToFile('Error domain %s' % (domain))
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + retValues[1] + ". Not able to create child domains, aborting. [635][5009]")
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + retValues[
1] + ". Not able to create child domains, aborting. [635][5009]")
return 0
except BaseException as msg:
status = open(os.path.join(completPath,'status'), "w")
status.write("Error Message: " + str(msg) +". Not able to create child domains, aborting. [638][5009]")
status = open(os.path.join(completPath, 'status'), "w")
status.write("Error Message: " + str(msg) + ". Not able to create child domains, aborting. [638][5009]")
status.close()
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]")
return 0
@@ -824,7 +819,8 @@ class backupUtilities:
if result[0] == 0:
raise BaseException(result[1])
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + str(msg) +". Not able to create email accounts, aborting. [671][5009]")
logging.CyberCPLogFileWriter.statusWriter(status, "Error Message: " + str(
msg) + ". Not able to create email accounts, aborting. [671][5009]")
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]")
return 0
@@ -865,7 +861,7 @@ class backupUtilities:
try:
pathToCompressedEmails = os.path.join(completPath, masterDomain + ".tar.gz")
emailHome = os.path.join("/home","vmail",masterDomain)
emailHome = os.path.join("/home", "vmail", masterDomain)
tar = tarfile.open(pathToCompressedEmails)
tar.extractall(emailHome)
@@ -912,7 +908,7 @@ class backupUtilities:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startRestore]")
@staticmethod
def initiateRestore(backupName,dir):
def initiateRestore(backupName, dir):
try:
p = Process(target=backupUtilities.startRestore, args=(backupName, dir,))
p.start()
@@ -920,7 +916,7 @@ class backupUtilities:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateRestore]")
@staticmethod
def sendKey(IPAddress, password,port):
def sendKey(IPAddress, password, port='22', user='root'):
try:
expectation = []
@@ -929,9 +925,12 @@ class backupUtilities:
expectation.append("Permission denied")
expectation.append("100%")
command = "scp -o StrictHostKeyChecking=no -P "+ port +" /root/.ssh/cyberpanel.pub root@" + IPAddress + ":/root/.ssh/authorized_keys"
command = "scp -o StrictHostKeyChecking=no -P " + port + " /root/.ssh/cyberpanel.pub " + user + "@" + IPAddress + ":~/.ssh/authorized_keys"
setupKeys = pexpect.spawn(command, timeout=3)
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
index = setupKeys.expect(expectation)
## on first login attempt send password
@@ -958,13 +957,13 @@ class backupUtilities:
return [0, "TIMEOUT [sendKey]"]
except pexpect.EOF as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]")
return [0, "EOF [sendKey]"]
return [0, "EOF [sendKey]"]
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [sendKey]")
return [0, str(msg) + " [sendKey]"]
@staticmethod
def setupSSHKeys(IPAddress, password,port):
def setupSSHKeys(IPAddress, password, port='22', user='root'):
try:
## Checking for host verification
@@ -974,7 +973,7 @@ class backupUtilities:
pass
else:
logging.CyberCPLogFileWriter.writeToFile("Host is Down.")
#return [0,"Host is Down."]
# return [0,"Host is Down."]
expectation = []
expectation.append("password:")
@@ -982,9 +981,12 @@ class backupUtilities:
expectation.append("Permission denied")
expectation.append("File exists")
command = "ssh -o StrictHostKeyChecking=no -p "+ port +" root@"+IPAddress+' "mkdir /root/.ssh || rm -f /root/.ssh/temp && rm -f /root/.ssh/authorized_temp && cp /root/.ssh/authorized_keys /root/.ssh/temp"'
command = "ssh -o StrictHostKeyChecking=no -p " + port + ' ' + user + "@" + IPAddress + ' "mkdir ~/.ssh || rm -f ~/.ssh/temp && rm -f ~/.ssh/authorized_temp && cp ~/.ssh/authorized_keys ~/.ssh/temp"'
setupKeys = pexpect.spawn(command, timeout=3)
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
index = setupKeys.expect(expectation)
## on first login attempt send password
@@ -1010,18 +1012,18 @@ class backupUtilities:
index = setupKeys.expect(expectation)
if index == 0:
return [0,"Wrong Password!"]
return [0, "Wrong Password!"]
elif index == 1:
return [0, "Wrong Password!"]
elif index == 2:
setupKeys.wait()
sendKey = backupUtilities.sendKey(IPAddress, password, port)
sendKey = backupUtilities.sendKey(IPAddress, password, port, user)
if sendKey[0] == 1:
return [1, "None"]
else:
return [0,sendKey[1]]
return [0, sendKey[1]]
except pexpect.TIMEOUT as msg:
@@ -1040,13 +1042,15 @@ class backupUtilities:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[checkIfHostIsUp]")
@staticmethod
def checkConnection(IPAddress):
def checkConnection(IPAddress, port='22', user='root'):
try:
try:
import json
destinations = backupUtilities.destinationsPath
data = open(destinations, 'r').readlines()
port = data[1].strip("\n")
data = json.loads(open(destinations, 'r').read())
port = data['port']
user = data['user']
except:
port = "22"
@@ -1057,13 +1061,19 @@ class backupUtilities:
expectation.append(pexpect.EOF)
expectation.append(pexpect.TIMEOUT)
checkConn = pexpect.spawn("sudo ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no -p "+ port+" root@"+IPAddress, timeout=3)
command = "sudo ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no -p " + port + ' ' + user + "@" + IPAddress
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
checkConn = pexpect.spawn(command,timeout=3)
index = checkConn.expect(expectation)
if index == 0:
subprocess.call(['kill', str(checkConn.pid)])
logging.CyberCPLogFileWriter.writeToFile("Remote Server is not able to authenticate for transfer to initiate, IP Address:" + IPAddress)
return [0,"Remote Server is not able to authenticate for transfer to initiate."]
logging.CyberCPLogFileWriter.writeToFile(
"Remote Server is not able to authenticate for transfer to initiate, IP Address:" + IPAddress)
return [0, "Remote Server is not able to authenticate for transfer to initiate."]
elif index == 1:
subprocess.call(['kill', str(checkConn.pid)])
logging.CyberCPLogFileWriter.writeToFile(
@@ -1080,28 +1090,28 @@ class backupUtilities:
return [1, "None"]
except pexpect.TIMEOUT as msg:
logging.CyberCPLogFileWriter.writeToFile("Timeout "+IPAddress+ " [checkConnection]")
logging.CyberCPLogFileWriter.writeToFile("Timeout " + IPAddress + " [checkConnection]")
return [0, "371 Timeout while making connection to this server [checkConnection]"]
except pexpect.EOF as msg:
logging.CyberCPLogFileWriter.writeToFile("EOF "+IPAddress+ "[checkConnection]")
logging.CyberCPLogFileWriter.writeToFile("EOF " + IPAddress + "[checkConnection]")
return [0, "374 Remote Server is not able to authenticate for transfer to initiate. [checkConnection]"]
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg)+" " +IPAddress+ " [checkConnection]")
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " " + IPAddress + " [checkConnection]")
return [0, "377 Remote Server is not able to authenticate for transfer to initiate. [checkConnection]"]
@staticmethod
def verifyHostKey(IPAddress):
def verifyHostKey(IPAddress, port='22', user='root'):
try:
backupUtilities.host_key_verification(IPAddress)
password = "hello" ## dumb password, not used anywhere.
password = "hello" ## dumb password, not used anywhere.
expectation = []
expectation.append("continue connecting (yes/no)?")
expectation.append("password:")
setupSSHKeys = pexpect.spawn("ssh cyberpanel@" + IPAddress, timeout=3)
setupSSHKeys = pexpect.spawn("ssh -p " + port + user + "@" + IPAddress, timeout=3)
index = setupSSHKeys.expect(expectation)
@@ -1116,7 +1126,6 @@ class backupUtilities:
expectation.append("password:")
expectation.append(pexpect.EOF)
innerIndex = setupSSHKeys.expect(expectation)
if innerIndex == 0:
@@ -1148,25 +1157,37 @@ class backupUtilities:
except pexpect.TIMEOUT as msg:
logging.CyberCPLogFileWriter.writeToFile("Timeout [verifyHostKey]")
return [0,"Timeout [verifyHostKey]"]
return [0, "Timeout [verifyHostKey]"]
except pexpect.EOF as msg:
logging.CyberCPLogFileWriter.writeToFile("EOF [verifyHostKey]")
return [0,"EOF [verifyHostKey]"]
return [0, "EOF [verifyHostKey]"]
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [verifyHostKey]")
return [0,str(msg)+" [verifyHostKey]"]
return [0, str(msg) + " [verifyHostKey]"]
@staticmethod
def createBackupDir(IPAddress,port):
def createBackupDir(IPAddress, port='22', user='root'):
try:
command = "sudo ssh -o StrictHostKeyChecking=no -p "+ port +" -i /root/.ssh/cyberpanel root@"+IPAddress+" mkdir /home/backup"
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel " + user + "@" + IPAddress + " mkdir ~/backup"
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
subprocess.call(shlex.split(command))
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + IPAddress + ' "cat /root/.ssh/authorized_keys /root/.ssh/temp > /root/.ssh/authorized_temp"'
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel " + user + "@" + IPAddress + ' "cat ~/.ssh/authorized_keys ~/.ssh/temp > ~/.ssh/authorized_temp"'
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
subprocess.call(shlex.split(command))
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + IPAddress + ' "cat /root/.ssh/authorized_temp > /root/.ssh/authorized_keys"'
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel " + user + "@" + IPAddress + ' "cat ~/.ssh/authorized_temp > ~/.ssh/authorized_keys"'
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
subprocess.call(shlex.split(command))
except BaseException as msg:
@@ -1271,10 +1292,8 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
writeToFile.close()
return 0
result = backupUtilities.prepareBackupMeta(backupDomain, backupName, tempStoragePath, backupPath)
if result[0] == 0:
writeToFile = open(schedulerPath, 'w')
writeToFile.writelines('error')
@@ -1287,7 +1306,8 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " startBackup --tempStoragePath " + tempStoragePath + " --backupName " \
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (result[2])
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (
result[2])
output = ProcessUtilities.outputExecutioner(execPath, website.externalApp)
if output.find('[5009') > -1:
@@ -1324,7 +1344,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
execPath = "sudo nice -n 10 /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " BackupRoot --tempStoragePath " + tempStoragePath + " --backupName " \
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain + ' --metaPath %s' % (
result[2])
result[2])
ProcessUtilities.executioner(execPath, 'root')
else:
@@ -1340,7 +1360,8 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [submitBackupCreation]")
def cancelBackupCreation(backupCancellationDomain,fileName):
def cancelBackupCreation(backupCancellationDomain, fileName):
try:
path = "/home/" + backupCancellationDomain + "/backup/pid"
@@ -1372,9 +1393,10 @@ def cancelBackupCreation(backupCancellationDomain,fileName):
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [cancelBackupCreation]")
print("0,"+str(msg))
print("0," + str(msg))
def submitRestore(backupFile,dir):
def submitRestore(backupFile, dir):
try:
p = Process(target=backupUtilities.startRestore, args=(backupFile, dir,))
@@ -1385,13 +1407,14 @@ def submitRestore(backupFile,dir):
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [cancelBackupCreation]")
print("0,"+str(msg))
print("0," + str(msg))
def submitDestinationCreation(ipAddress, password, port):
setupKeys = backupUtilities.setupSSHKeys(ipAddress, password, port)
def submitDestinationCreation(ipAddress, password, port='22', user='root'):
setupKeys = backupUtilities.setupSSHKeys(ipAddress, password, port, user)
if setupKeys[0] == 1:
backupUtilities.createBackupDir(ipAddress, port)
backupUtilities.createBackupDir(ipAddress, port, user)
print("1,None")
else:
print(setupKeys[1])
@@ -1409,8 +1432,8 @@ def getConnectionStatus(ipAddress):
except BaseException as msg:
print(str(msg))
def main():
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
parser.add_argument('function', help='Specific a function to call!')
parser.add_argument('--tempStoragePath', help='')
@@ -1424,6 +1447,7 @@ def main():
parser.add_argument('--ipAddress', help='')
parser.add_argument('--password', help='')
parser.add_argument('--port', help='')
parser.add_argument('--user', help='')
## backup cancellation arguments
@@ -1435,19 +1459,16 @@ def main():
parser.add_argument('--backupFile', help='')
parser.add_argument('--dir', help='')
args = parser.parse_args()
if args.function == "submitBackupCreation":
submitBackupCreation(args.tempStoragePath,args.backupName,args.backupPath, args.backupDomain)
submitBackupCreation(args.tempStoragePath, args.backupName, args.backupPath, args.backupDomain)
elif args.function == "cancelBackupCreation":
cancelBackupCreation(args.backupCancellationDomain,args.fileName)
cancelBackupCreation(args.backupCancellationDomain, args.fileName)
elif args.function == "submitRestore":
submitRestore(args.backupFile,args.dir)
submitRestore(args.backupFile, args.dir)
elif args.function == "submitDestinationCreation":
submitDestinationCreation(args.ipAddress, args.password, args.port)
submitDestinationCreation(args.ipAddress, args.password, args.port, args.user)
elif args.function == "getConnectionStatus":
getConnectionStatus(args.ipAddress)
elif args.function == "startBackup":
@@ -1455,5 +1476,6 @@ def main():
elif args.function == "BackupRoot":
backupUtilities.BackupRoot(args.tempStoragePath, args.backupName, args.backupPath, args.metaPath)
if __name__ == "__main__":
main()
main()

View File

@@ -193,6 +193,9 @@ class remoteTransferUtilities:
command = "sudo scp -o StrictHostKeyChecking=no -i /root/.ssh/cyberpanel " + completedPathToSend + " root@" + IPAddress + ":/home/backup/transfer-" + folderNumber + "/"
subprocess.call(shlex.split(command), stdout=writeToFile)
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
os.remove(completedPathToSend)
except BaseException as msg:

View File

@@ -1,3 +0,0 @@
import urllib.parse
encodedStr = 'ville.laprairie.qc.ca&fileToDownload=/home/ville.laprairie.qc.ca/public_html/app/uploads/2019/05/2019-05-16_Terre-contamine%CC%81e-sur-Goyer-150x150.jpg'
print(urllib.parse.unquote(encodedStr))

View File

@@ -579,6 +579,11 @@ class Upgrade:
except:
pass
try:
cursor.execute("ALTER TABLE websiteFunctions_backups MODIFY fileName varchar(200)")
except:
pass
try:
cursor.execute("ALTER TABLE loginSystem_acl ADD COLUMN listUsers INT DEFAULT 0;")
@@ -1373,8 +1378,6 @@ class Upgrade:
Upgrade.stdOut('Settings file restored!')
## Move static files
Upgrade.staticContent()
except:
@@ -2107,6 +2110,14 @@ vmail
Upgrade.installCLScripts()
Upgrade.runSomeImportantBash()
## Move static files
imunifyPath = '/usr/local/CyberCP/public/imunify'
if os.path.exists(imunifyPath):
command = "yum reinstall imunify360-firewall-generic -y"
Upgrade.executioner(command, command, 1)
Upgrade.stdOut("Upgrade Completed.")

View File

@@ -29,7 +29,7 @@ class ChildDomains(models.Model):
class Backups(models.Model):
website = models.ForeignKey(Websites,on_delete=models.CASCADE)
fileName = models.CharField(max_length=50)
fileName = models.CharField(max_length=200)
date = models.CharField(max_length=50)
size = models.CharField(max_length=50)
status = models.IntegerField(default=0)