mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-19 04:41:23 +02:00
Merge branch 'v2.0.2-dev' of https://github.com/usmannasir/cyberpanel into v2.0.2-dev
This commit is contained in:
@@ -188,6 +188,7 @@ LANGUAGES = (
|
||||
('it', _('Italian')),
|
||||
('de', _('Deutsch')),
|
||||
('id', _('Indonesian')),
|
||||
('bn', _('Bangla')),
|
||||
)
|
||||
|
||||
MEDIA_URL = '/home/cyberpanel/media/'
|
||||
|
||||
@@ -14,6 +14,7 @@ urlpatterns = [
|
||||
url(r'^changeUserPassAPI', views.changeUserPassAPI, name='changeUserPassAPI'),
|
||||
url(r'^submitUserDeletion$', views.submitUserDeletion, name='submitUserDeletion'),
|
||||
|
||||
url(r'^listPackage',views.getPackagesListAPI,name='getPackagesListAPI'),
|
||||
url(r'^changePackageAPI', views.changePackageAPI, name='changePackageAPI'),
|
||||
url(r'^fetchSSHkey', views.fetchSSHkey, name='fetchSSHkey'),
|
||||
url(r'^remoteTransfer', views.remoteTransfer, name='remoteTransfer'),
|
||||
|
||||
20
api/views.py
20
api/views.py
@@ -14,6 +14,7 @@ import os
|
||||
from baseTemplate.models import version
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from websiteFunctions.website import WebsiteManager
|
||||
from packages.packagesManager import PackagesManager
|
||||
from s3Backups.s3Backups import S3Backups
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
@@ -67,6 +68,25 @@ def createWebsite(request):
|
||||
wm = WebsiteManager()
|
||||
return wm.createWebsiteAPI(json.loads(request.body))
|
||||
|
||||
@csrf_exempt
|
||||
def getPackagesListAPI(request):
|
||||
data = json.loads(request.body)
|
||||
adminUser = data['adminUser']
|
||||
adminPass = data['adminPass']
|
||||
admin = Administrator.objects.get(userName=adminUser)
|
||||
if admin.api == 0:
|
||||
data_ret = {"existsStatus": 0, 'listPackages': [],
|
||||
'error_message': "API Access Disabled."}
|
||||
return HttpResponse(json.dumps(data_ret))
|
||||
if hashPassword.check_password(admin.password, adminPass):
|
||||
pm = PackagesManager()
|
||||
return pm.listPackagesAPI(data)
|
||||
else:
|
||||
data_ret = {"status": 0,'error_message': "Could not authorize access to API"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def getUserInfo(request):
|
||||
try:
|
||||
|
||||
@@ -3,6 +3,7 @@ import os
|
||||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
@@ -19,24 +20,29 @@ from plogical.mailUtilities import mailUtilities
|
||||
from random import randint
|
||||
import time
|
||||
import plogical.backupUtilities as backupUtil
|
||||
import requests
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from multiprocessing import Process
|
||||
import requests
|
||||
import google.oauth2.credentials
|
||||
import googleapiclient.discovery
|
||||
from googleapiclient.discovery import build
|
||||
|
||||
|
||||
class BackupManager:
|
||||
localBackupPath = '/home/cyberpanel/localBackupPath'
|
||||
def __init__(self, domain = None, childDomain = None):
|
||||
|
||||
def __init__(self, domain=None, childDomain=None):
|
||||
self.domain = domain
|
||||
self.childDomain = childDomain
|
||||
|
||||
def loadBackupHome(self, request = None, userID = None, data = None):
|
||||
def loadBackupHome(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
return render(request, 'backup/index.html', currentACL)
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def backupSite(self, request = None, userID = None, data = None):
|
||||
def backupSite(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -48,13 +54,13 @@ class BackupManager:
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def gDrive(self, request = None, userID = None, data = None):
|
||||
def gDrive(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'addDeleteDestinations') == 0:
|
||||
if ACLManager.currentContextPermission(currentACL, 'createBackup') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
gDriveAcctsList = []
|
||||
@@ -70,35 +76,30 @@ class BackupManager:
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def gDriveSetup(self, userID = None, request = None):
|
||||
def gDriveSetup(self, userID=None, request=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'addDeleteDestinations') == 0:
|
||||
if ACLManager.currentContextPermission(currentACL, 'createBackup') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
gDriveData = {}
|
||||
gDriveData['name'] = request.GET.get('n')
|
||||
gDriveData['token'] = request.GET.get('t')
|
||||
gDriveData['refresh_token'] = request.GET.get('r')
|
||||
gDriveData['token_uri'] = request.GET.get('to')
|
||||
gDriveData['client_id'] = request.GET.get('c')
|
||||
gDriveData['client_secret'] = request.GET.get('cl')
|
||||
gDriveData['scopes'] = request.GET.get('s')
|
||||
|
||||
gD = GDrive(owner=admin, name=gDriveData['name'],auth=json.dumps(gDriveData))
|
||||
gD = GDrive(owner=admin, name=request.GET.get('n'), auth=json.dumps(gDriveData))
|
||||
gD.save()
|
||||
|
||||
|
||||
final_json = json.dumps({'status': 1, 'message': 'Successfully saved.'})
|
||||
return HttpResponse(final_json)
|
||||
return self.gDrive(request, userID)
|
||||
except BaseException as msg:
|
||||
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def fetchgDriveSites(self, request = None, userID = None, data = None):
|
||||
def fetchDriveLogs(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
@@ -113,6 +114,77 @@ class BackupManager:
|
||||
|
||||
gD = GDrive.objects.get(name=selectedAccount)
|
||||
|
||||
if ACLManager.checkGDriveOwnership(gD, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
logs = gD.gdrivejoblogs_set.all().order_by('-id')
|
||||
|
||||
from s3Backups.s3Backups import S3Backups
|
||||
|
||||
pagination = S3Backups.getPagination(len(logs), recordsToShow)
|
||||
endPageNumber, finalPageNumber = S3Backups.recordsPointer(page, recordsToShow)
|
||||
logs = logs[finalPageNumber:endPageNumber]
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
counter = 0
|
||||
|
||||
from plogical.backupSchedule import backupSchedule
|
||||
|
||||
for log in logs:
|
||||
|
||||
if log.status == backupSchedule.INFO:
|
||||
status = 'INFO'
|
||||
else:
|
||||
status = 'ERROR'
|
||||
|
||||
dic = {
|
||||
'type': status,
|
||||
'message': log.message
|
||||
}
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
counter = counter + 1
|
||||
|
||||
json_data = json_data + ']'
|
||||
|
||||
data_ret = {'status': 1, 'logs': json_data, 'pagination': pagination}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def fetchgDriveSites(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
data = json.loads(request.body)
|
||||
|
||||
selectedAccount = data['selectedAccount']
|
||||
recordsToShow = int(data['recordsToShow'])
|
||||
page = int(str(data['page']).strip('\n'))
|
||||
|
||||
gD = GDrive.objects.get(name=selectedAccount)
|
||||
|
||||
if ACLManager.checkGDriveOwnership(gD, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
websites = gD.gdrivesites_set.all()
|
||||
|
||||
from s3Backups.s3Backups import S3Backups
|
||||
@@ -155,7 +227,7 @@ class BackupManager:
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def addSitegDrive(self, request = None, userID = None, data = None):
|
||||
def addSitegDrive(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
@@ -169,6 +241,11 @@ class BackupManager:
|
||||
|
||||
gD = GDrive.objects.get(name=selectedAccount)
|
||||
|
||||
if ACLManager.checkGDriveOwnership(gD, admin, currentACL) == 1 and ACLManager.checkOwnership(selectedWebsite, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
gdSite = GDriveSites(owner=gD, domain=selectedWebsite)
|
||||
gdSite.save()
|
||||
|
||||
@@ -181,7 +258,7 @@ class BackupManager:
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def deleteAccountgDrive(self, request = None, userID = None, data = None):
|
||||
def deleteAccountgDrive(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
@@ -194,6 +271,11 @@ class BackupManager:
|
||||
|
||||
gD = GDrive.objects.get(name=selectedAccount)
|
||||
|
||||
if ACLManager.checkGDriveOwnership(gD, admin, currentACL):
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
gD.delete()
|
||||
|
||||
data_ret = {'status': 1}
|
||||
@@ -205,7 +287,7 @@ class BackupManager:
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def changeAccountFrequencygDrive(self, request = None, userID = None, data = None):
|
||||
def changeAccountFrequencygDrive(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
@@ -218,6 +300,12 @@ class BackupManager:
|
||||
backupFrequency = data['backupFrequency']
|
||||
|
||||
gD = GDrive.objects.get(name=selectedAccount)
|
||||
|
||||
if ACLManager.checkGDriveOwnership(gD, admin, currentACL):
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
gD.runTime = backupFrequency
|
||||
|
||||
gD.save()
|
||||
@@ -231,7 +319,7 @@ class BackupManager:
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def deleteSitegDrive(self, request = None, userID = None, data = None):
|
||||
def deleteSitegDrive(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
@@ -244,8 +332,16 @@ class BackupManager:
|
||||
website = data['website']
|
||||
|
||||
gD = GDrive.objects.get(name=selectedAccount)
|
||||
gDSite = GDriveSites.objects.get(owner=gD, domain=website)
|
||||
gDSite.delete()
|
||||
|
||||
if ACLManager.checkGDriveOwnership(gD, admin, currentACL) == 1 and ACLManager.checkOwnership(website, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
sites = GDriveSites.objects.filter(owner=gD, domain=website)
|
||||
|
||||
for items in sites:
|
||||
items.delete()
|
||||
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
@@ -256,7 +352,7 @@ class BackupManager:
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def restoreSite(self, request = None, userID = None, data = None):
|
||||
def restoreSite(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -284,7 +380,7 @@ class BackupManager:
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def getCurrentBackups(self, userID = None, data = None):
|
||||
def getCurrentBackups(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
@@ -333,7 +429,7 @@ class BackupManager:
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def submitBackupCreation(self, userID = None, data = None):
|
||||
def submitBackupCreation(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -356,13 +452,14 @@ class BackupManager:
|
||||
## /home/example.com/backup/backup-example.com-02.13.2018_10-24-52
|
||||
tempStoragePath = os.path.join(backupPath, backupName)
|
||||
|
||||
|
||||
p = Process(target=backupUtil.submitBackupCreation, args=(tempStoragePath, backupName, backupPath,backupDomain))
|
||||
p = Process(target=backupUtil.submitBackupCreation,
|
||||
args=(tempStoragePath, backupName, backupPath, backupDomain))
|
||||
p.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
final_json = json.dumps({'status': 1, 'metaStatus': 1, 'error_message': "None", 'tempStorage': tempStoragePath})
|
||||
final_json = json.dumps(
|
||||
{'status': 1, 'metaStatus': 1, 'error_message': "None", 'tempStorage': tempStoragePath})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException as msg:
|
||||
@@ -371,7 +468,7 @@ class BackupManager:
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def backupStatus(self, userID = None, data = None):
|
||||
def backupStatus(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
backupDomain = data['websiteToBeBacked']
|
||||
@@ -454,7 +551,7 @@ class BackupManager:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupStatus]")
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def cancelBackupCreation(self, userID = None, data = None):
|
||||
def cancelBackupCreation(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
backupCancellationDomain = data['backupCancellationDomain']
|
||||
@@ -478,7 +575,7 @@ class BackupManager:
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def deleteBackup(self, userID = None, data = None):
|
||||
def deleteBackup(self, userID=None, data=None):
|
||||
try:
|
||||
backupID = data['backupID']
|
||||
backup = Backups.objects.get(id=backupID)
|
||||
@@ -505,7 +602,7 @@ class BackupManager:
|
||||
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def submitRestore(self, data = None, userID = None):
|
||||
def submitRestore(self, data=None, userID=None):
|
||||
try:
|
||||
backupFile = data['backupFile']
|
||||
originalFile = "/home/backup/" + backupFile
|
||||
@@ -534,7 +631,7 @@ class BackupManager:
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def restoreStatus(self, data = None):
|
||||
def restoreStatus(self, data=None):
|
||||
try:
|
||||
backupFile = data['backupFile'].strip(".tar.gz")
|
||||
|
||||
@@ -594,7 +691,7 @@ class BackupManager:
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def backupDestinations(self, request = None, userID = None, data = None):
|
||||
def backupDestinations(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -606,7 +703,7 @@ class BackupManager:
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def submitDestinationCreation(self, userID = None, data = None):
|
||||
def submitDestinationCreation(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -631,7 +728,6 @@ class BackupManager:
|
||||
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)
|
||||
@@ -656,7 +752,6 @@ class BackupManager:
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(output)
|
||||
|
||||
|
||||
if output.find('1,') > -1:
|
||||
try:
|
||||
writeToFile = open(destinations, "w")
|
||||
@@ -689,7 +784,7 @@ class BackupManager:
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def getCurrentBackupDestinations(self, userID = None, data = None):
|
||||
def getCurrentBackupDestinations(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -724,7 +819,7 @@ class BackupManager:
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def getConnectionStatus(self, userID = None, data = None):
|
||||
def getConnectionStatus(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -752,7 +847,7 @@ class BackupManager:
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def deleteDestination(self, userID = None, data = None):
|
||||
def deleteDestination(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -805,7 +900,7 @@ class BackupManager:
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def scheduleBackup(self, request, userID = None, data = None):
|
||||
def scheduleBackup(self, request, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -830,7 +925,7 @@ class BackupManager:
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def getCurrentBackupSchedules(self, userID = None, data = None):
|
||||
def getCurrentBackupSchedules(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -863,7 +958,7 @@ class BackupManager:
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def submitBackupSchedule(self, userID = None, data = None):
|
||||
def submitBackupSchedule(self, userID=None, data=None):
|
||||
try:
|
||||
backupDest = data['backupDest']
|
||||
backupFreq = data['backupFreq']
|
||||
@@ -972,7 +1067,7 @@ class BackupManager:
|
||||
final_json = json.dumps({'scheduleStatus': 0, 'error_message': str(msg)})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def scheduleDelete(self, userID = None, data = None):
|
||||
def scheduleDelete(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -1006,7 +1101,8 @@ class BackupManager:
|
||||
writeToFile = open(tempCronPath, 'w')
|
||||
|
||||
for items in output:
|
||||
if (items.find(findTxt) > -1 and items.find("backupScheduleLocal.py") > -1) or (items.find(findTxt) > -1 and items.find('backupSchedule.py')):
|
||||
if (items.find(findTxt) > -1 and items.find("backupScheduleLocal.py") > -1) or (
|
||||
items.find(findTxt) > -1 and items.find('backupSchedule.py')):
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items + '\n')
|
||||
@@ -1033,7 +1129,7 @@ class BackupManager:
|
||||
final_json = json.dumps({'delStatus': 0, 'error_message': str(msg)})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def remoteBackups(self, request, userID = None, data = None):
|
||||
def remoteBackups(self, request, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -1045,7 +1141,7 @@ class BackupManager:
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def submitRemoteBackups(self, userID = None, data = None):
|
||||
def submitRemoteBackups(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -1168,7 +1264,7 @@ class BackupManager:
|
||||
final_json = json.dumps({'status': 0, 'error_message': str(msg)})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def starRemoteTransfer(self, userID = None, data = None):
|
||||
def starRemoteTransfer(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -1232,7 +1328,7 @@ class BackupManager:
|
||||
final_json = json.dumps({'remoteTransferStatus': 0, 'error_message': str(msg)})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def getRemoteTransferStatus(self, userID = None, data = None):
|
||||
def getRemoteTransferStatus(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -1277,7 +1373,7 @@ class BackupManager:
|
||||
json_data = json.dumps(data)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def remoteBackupRestore(self, userID = None, data = None):
|
||||
def remoteBackupRestore(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ACLManager.currentContextPermission(currentACL, 'remoteBackups') == 0:
|
||||
@@ -1307,7 +1403,7 @@ class BackupManager:
|
||||
json_data = json.dumps(data)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def localRestoreStatus(self, userID = None, data = None):
|
||||
def localRestoreStatus(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -1349,7 +1445,7 @@ class BackupManager:
|
||||
json_data = json.dumps(data)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def cancelRemoteBackup(self, userID = None, data = None):
|
||||
def cancelRemoteBackup(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -1395,7 +1491,7 @@ class BackupManager:
|
||||
json_data = json.dumps(data)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def backupLogs(self, request = None, userID = None, data = None):
|
||||
def backupLogs(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -1409,14 +1505,14 @@ class BackupManager:
|
||||
logFiles = BackupJob.objects.all().order_by('-id')
|
||||
|
||||
for logFile in logFiles:
|
||||
all_files.append(logFile.logFile)
|
||||
all_files.append(logFile.logFile)
|
||||
|
||||
return render(request, 'backup/backupLogs.html', {'backups': all_files})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def fetchLogs(self, userID = None, data = None):
|
||||
def fetchLogs(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
@@ -1468,17 +1564,15 @@ class BackupManager:
|
||||
else:
|
||||
location = 'remote'
|
||||
|
||||
|
||||
data = {
|
||||
'status': 1,
|
||||
'error_message': 'None',
|
||||
'logs': json_data,
|
||||
'pagination': pagination,
|
||||
'jobSuccessSites': logJob.jobSuccessSites,
|
||||
'jobFailedSites': logJob.jobFailedSites,
|
||||
'location': location
|
||||
}
|
||||
|
||||
'status': 1,
|
||||
'error_message': 'None',
|
||||
'logs': json_data,
|
||||
'pagination': pagination,
|
||||
'jobSuccessSites': logJob.jobSuccessSites,
|
||||
'jobFailedSites': logJob.jobFailedSites,
|
||||
'location': location
|
||||
}
|
||||
|
||||
json_data = json.dumps(data)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@@ -1611,7 +1611,7 @@ app.controller('googleDrive', function ($scope, $http) {
|
||||
|
||||
$scope.fetchWebsites = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
@@ -1631,7 +1631,7 @@ app.controller('googleDrive', function ($scope, $http) {
|
||||
$http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.driveHidden = false;
|
||||
new PNotify({
|
||||
@@ -1652,7 +1652,7 @@ app.controller('googleDrive', function ($scope, $http) {
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
@@ -1854,4 +1854,60 @@ app.controller('googleDrive', function ($scope, $http) {
|
||||
|
||||
};
|
||||
|
||||
$scope.currentPageLogs = 1;
|
||||
$scope.recordsToShowLogs = 10;
|
||||
|
||||
$scope.fetchLogs = function () {
|
||||
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
selectedAccount: $scope.selectedAccount,
|
||||
page: $scope.currentPageLogs,
|
||||
recordsToShow: $scope.recordsToShowLogs
|
||||
};
|
||||
|
||||
|
||||
dataurl = "/backup/fetchDriveLogs";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.driveHidden = false;
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Successfully fetched.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.logs = JSON.parse(response.data.logs);
|
||||
$scope.paginationLogs = response.data.pagination;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<button ng-hide="driveHidden" type="button" ng-click="deleteAccount()"
|
||||
<button ng-hide="driveHidden" type="button" ng-click="deleteAccount()"
|
||||
class="btn btn-danger">{% trans "Delete" %}</button>
|
||||
</div>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<div ng-hide="driveHidden" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Add Sites for Backup" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="fetchWebsites()" ng-model="selectedWebsite" class="form-control">
|
||||
<select ng-model="selectedWebsite" class="form-control">
|
||||
{% for items in websites %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
@@ -114,7 +114,82 @@
|
||||
|
||||
<div ng-hide="driveHidden" class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-sm-9">
|
||||
<div style="margin-left: 2%" class="col-sm-3">
|
||||
<button data-toggle="modal" data-target="#backupLogs" ng-hide="driveHidden"
|
||||
type="button" ng-click="fetchLogs()"
|
||||
class="btn btn-gray">{% trans "View Logs" %}</button>
|
||||
<div id="backupLogs" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×
|
||||
</button>
|
||||
<h4 class="modal-title">{% trans "Git Logs" %} <img
|
||||
ng-hide="cyberPanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-9">
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="form-group">
|
||||
<select ng-model="recordsToShowLogs"
|
||||
ng-change="fetchLogs()"
|
||||
class="form-control" id="example-select">
|
||||
<option>10</option>
|
||||
<option>50</option>
|
||||
<option>100</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table style="margin: 0px; padding-bottom: 2%" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="log in logs track by $index">
|
||||
<td ng-bind="log.type"></td>
|
||||
<td ng-bind="log.message"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div style="margin-top: 2%" class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<select ng-model="currentPageLogs"
|
||||
class="form-control"
|
||||
ng-change="fetchLogs()">
|
||||
<option ng-repeat="page in paginationLogs">{$
|
||||
$index + 1
|
||||
$}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="form-group">
|
||||
@@ -139,8 +214,10 @@
|
||||
<tbody>
|
||||
<tr ng-repeat="website in websites track by $index">
|
||||
<td ng-bind="website.name"></td>
|
||||
<td ><button type="button" ng-click="deleteSite(website.name)"
|
||||
class="btn btn-danger">{% trans "Delete" %}</button></td>
|
||||
<td>
|
||||
<button type="button" ng-click="deleteSite(website.name)"
|
||||
class="btn btn-danger">{% trans "Delete" %}</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -13,6 +13,7 @@ urlpatterns = [
|
||||
url(r'^deleteAccountgDrive$', views.deleteAccountgDrive, name='deleteAccountgDrive'),
|
||||
url(r'^changeAccountFrequencygDrive$', views.changeAccountFrequencygDrive, name='changeAccountFrequencygDrive'),
|
||||
url(r'^deleteSitegDrive$', views.deleteSitegDrive, name='deleteSitegDrive'),
|
||||
url(r'^fetchDriveLogs$', views.fetchDriveLogs, name='fetchDriveLogs'),
|
||||
|
||||
|
||||
url(r'^submitBackupCreation', views.submitBackupCreation, name='submitBackupCreation'),
|
||||
|
||||
@@ -86,6 +86,14 @@ def deleteSitegDrive(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def fetchDriveLogs(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = BackupManager()
|
||||
return wm.fetchDriveLogs(request, userID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def restoreSite(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
@@ -580,7 +580,7 @@
|
||||
<li class="addDeleteDestinations"><a href="{% url 'backupDestinations' %}"
|
||||
title="{% trans 'Add Destination' %}"><span>{% trans "Add/Delete Destination" %}</span></a>
|
||||
</li>
|
||||
<li class="addDeleteDestinations"><a href="{% url 'gDrive' %}"
|
||||
<li class="createBackup"><a href="{% url 'gDrive' %}"
|
||||
title="{% trans 'Setup Google Drive' %}"><span>{% trans "Setup Google Drive" %}</span></a>
|
||||
</li>
|
||||
<li class="scheDuleBackups"><a href="{% url 'scheduleBackup' %}"
|
||||
|
||||
@@ -19,7 +19,7 @@ from plogical.processUtilities import ProcessUtilities
|
||||
# Create your views here.
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 1
|
||||
BUILD = 2
|
||||
|
||||
@ensure_csrf_cookie
|
||||
def renderBase(request):
|
||||
|
||||
106
cyberpanel.sh
106
cyberpanel.sh
@@ -8,6 +8,16 @@ DEV="OFF"
|
||||
POSTFIX_VARIABLE="ON"
|
||||
POWERDNS_VARIABLE="ON"
|
||||
PUREFTPD_VARIABLE="ON"
|
||||
|
||||
### Remote MySQL Variables
|
||||
|
||||
REMOTE_MYSQL='OFF'
|
||||
MYSQL_HOST=''
|
||||
MYSQL_DB=''
|
||||
MYSQL_USER=''
|
||||
MYSQL_PASSWORD=''
|
||||
MYSQL_PORT=''
|
||||
|
||||
PROVIDER="undefined"
|
||||
SERIAL_NO=""
|
||||
DIR=$(pwd)
|
||||
@@ -379,19 +389,18 @@ fi
|
||||
|
||||
echo -e "\nInstalling necessary components..."
|
||||
if [[ $SERVER_OS == "CentOS" ]] ; then
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/mariadb/RPM-GPG-KEY-MariaDB
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/litespeed/RPM-GPG-KEY-litespeed
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/powerdns/FD380FBB-pub.asc
|
||||
timeout 10 rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/gf-plus/RPM-GPG-KEY-gf.el7
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/lux/RPM-GPG-KEY-LUX
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/ius/RPM-GPG-KEY-IUS-7
|
||||
timeout 10 rpm --import https://repo.dovecot.org/DOVECOT-REPO-GPG
|
||||
timeout 10 rpm --import https://copr-be.cloud.fedoraproject.org/results/copart/restic/pubkey.gpg
|
||||
timeout 10 rpm --import https://rep8.cyberpanel.net/RPM-GPG-KEY-CP-EP-8
|
||||
timeout 10 rpm --import https://rep8.cyberpanel.net/RPM-GPG-KEY-CP-GF-8
|
||||
timeout 10 rpm --import https://rep8.cyberpanel.net/RPM-GPG-KEY-centosofficialcp
|
||||
curl https://getfedora.org/static/fedora.gpg | gpg --import
|
||||
if [[ $CENTOS_8 == "False" ]] ; then
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/mariadb/RPM-GPG-KEY-MariaDB
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/litespeed/RPM-GPG-KEY-litespeed
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/powerdns/FD380FBB-pub.asc
|
||||
timeout 10 rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/gf-plus/RPM-GPG-KEY-gf.el7
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/lux/RPM-GPG-KEY-LUX
|
||||
timeout 10 rpm --import https://$DOWNLOAD_SERVER/ius/RPM-GPG-KEY-IUS-7
|
||||
timeout 10 rpm --import https://repo.dovecot.org/DOVECOT-REPO-GPG
|
||||
timeout 10 rpm --import https://copr-be.cloud.fedoraproject.org/results/copart/restic/pubkey.gpg
|
||||
curl https://getfedora.org/static/fedora.gpg | gpg --import
|
||||
fi
|
||||
|
||||
yum clean all
|
||||
yum update -y
|
||||
@@ -471,7 +480,12 @@ if [[ $SERVER_OS == "CentOS" ]] ; then
|
||||
fi
|
||||
fi
|
||||
if [[ $SERVER_OS == "Ubuntu" ]] ; then
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp74-memcached lsphp73-memcached lsphp72-memcached lsphp71-memcached lsphp70-memcached
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp74-memcached
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp73-memcached
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp72-memcached
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp71-memcached
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp70-memcached
|
||||
|
||||
if [[ $TOTAL_RAM -eq "2048" ]] || [[ $TOTAL_RAM -gt "2048" ]] ; then
|
||||
DEBIAN_FRONTEND=noninteractive apt install build-essential zlib1g-dev libexpat1-dev openssl libssl-dev libsasl2-dev libpcre3-dev git -y
|
||||
wget https://$DOWNLOAD/litespeed/lsmcd.tar.gz
|
||||
@@ -507,7 +521,12 @@ if [[ $SERVER_OS == "CentOS" ]] ; then
|
||||
yum install -y lsphp74-redis lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis lsphp56-redis lsphp55-redis lsphp54-redis redis
|
||||
fi
|
||||
if [[ $SERVER_OS == "Ubuntu" ]] ; then
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp74-redis lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis redis
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp74-redis
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp73-redis
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp72-redis
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp71-redis
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y lsphp70-redis
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y redis
|
||||
fi
|
||||
|
||||
if ifconfig -a | grep inet6 ; then
|
||||
@@ -856,6 +875,46 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
### Ask if you want to set up this CyberPanel with remote MySQL
|
||||
|
||||
echo -e "\nDo you want to setup Remote MySQL? (This will skip installation of local MySQL)"
|
||||
echo -e ""
|
||||
printf "%s" "(Default = No) Remote MySQL [Y/n]: "
|
||||
read TMP_YN
|
||||
if [[ `expr "x$TMP_YN" : 'x[Yy]'` -gt 1 ]] || [[ $TMP_YN == "" ]] ; then
|
||||
echo -e "\nRemote MySQL selected..."
|
||||
REMOTE_MYSQL='ON'
|
||||
|
||||
echo -e ""
|
||||
printf "%s" "Remote MySQL Hostname: "
|
||||
read MYSQL_HOST
|
||||
|
||||
echo -e ""
|
||||
printf "%s" "Remote MySQL Database that contains meta information regarding MYSQL. (usually mysql): "
|
||||
read MYSQL_DB
|
||||
|
||||
echo -e ""
|
||||
printf "%s" "Remote MySQL Username: "
|
||||
read MYSQL_USER
|
||||
|
||||
echo -e ""
|
||||
printf "%s" "Remote MySQL Password: "
|
||||
read MYSQL_PASSWORD
|
||||
|
||||
echo -e ""
|
||||
printf "%s" "Remote MySQL Port: "
|
||||
read MYSQL_PORT
|
||||
|
||||
else
|
||||
|
||||
echo -e ""
|
||||
printf "%s" "Local MySQL selected.."
|
||||
echo -e ""
|
||||
|
||||
fi
|
||||
|
||||
###
|
||||
|
||||
#above comment for future use
|
||||
|
||||
#if [[ $DEV_ARG == "ON" ]] ; then
|
||||
@@ -1029,9 +1088,18 @@ if [[ $debug == "1" ]] ; then
|
||||
fi
|
||||
|
||||
if [[ $REDIS_HOSTING == "Yes" ]] ; then
|
||||
/usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --postfix $POSTFIX_VARIABLE --powerdns $POWERDNS_VARIABLE --ftp $PUREFTPD_VARIABLE --redis enable
|
||||
if [[ $REMOTE_MYSQL == "ON" ]] ; then
|
||||
/usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --postfix $POSTFIX_VARIABLE --powerdns $POWERDNS_VARIABLE --ftp $PUREFTPD_VARIABLE --redis enable --remotemysql $REMOTE_MYSQL --mysqlhost $MYSQL_HOST --mysqldb $MYSQL_DB --mysqluser $MYSQL_USER --mysqlpassword $MYSQL_PASSWORD --mysqlport $MYSQL_PORT
|
||||
else
|
||||
/usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --postfix $POSTFIX_VARIABLE --powerdns $POWERDNS_VARIABLE --ftp $PUREFTPD_VARIABLE --redis enable --remotemysql $REMOTE_MYSQL
|
||||
fi
|
||||
else
|
||||
/usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --postfix $POSTFIX_VARIABLE --powerdns $POWERDNS_VARIABLE --ftp $PUREFTPD_VARIABLE
|
||||
if [[ $REMOTE_MYSQL == "ON" ]] ; then
|
||||
echo "/usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --postfix $POSTFIX_VARIABLE --powerdns $POWERDNS_VARIABLE --ftp $PUREFTPD_VARIABLE --remotemysql $REMOTE_MYSQL --mysqlhost $MYSQL_HOST --mysqluser $MYSQL_USER --mysqlpassword $MYSQL_PASSWORD --mysqlport $MYSQL_PORT"
|
||||
/usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --postfix $POSTFIX_VARIABLE --powerdns $POWERDNS_VARIABLE --ftp $PUREFTPD_VARIABLE --remotemysql $REMOTE_MYSQL --mysqlhost $MYSQL_HOST --mysqldb $MYSQL_DB --mysqluser $MYSQL_USER --mysqlpassword $MYSQL_PASSWORD --mysqlport $MYSQL_PORT
|
||||
else
|
||||
/usr/local/CyberPanel/bin/python install.py $SERVER_IP $SERIAL_NO $LICENSE_KEY --postfix $POSTFIX_VARIABLE --powerdns $POWERDNS_VARIABLE --ftp $PUREFTPD_VARIABLE --remotemysql $REMOTE_MYSQL
|
||||
fi
|
||||
fi
|
||||
|
||||
if grep "CyberPanel installation successfully completed" /var/log/installLogs.txt > /dev/null; then
|
||||
@@ -1070,7 +1138,7 @@ if [[ $DEV == "ON" ]] ; then
|
||||
|
||||
if [[ $UBUNTU_20 == "False" ]] ; then
|
||||
source /usr/local/CyberPanel/bin/activate
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip-2.zip
|
||||
check_return
|
||||
unzip /usr/local/cyberpanel-pip.zip -d /usr/local
|
||||
check_return
|
||||
@@ -1078,7 +1146,7 @@ if [[ $DEV == "ON" ]] ; then
|
||||
check_return
|
||||
else
|
||||
. /usr/local/CyberPanel/bin/activate
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/ubuntu-pip.zip
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/ubuntu-pip-2.zip
|
||||
check_return
|
||||
unzip /usr/local/cyberpanel-pip.zip -d /usr/local
|
||||
check_return
|
||||
|
||||
@@ -192,6 +192,18 @@ elif echo $OUTPUT | grep -q "CentOS Linux 8"; then
|
||||
rm -f /etc/yum.repos.d/epel.repo.rpmsave
|
||||
yum autoremove epel-release -y
|
||||
dnf install epel-release -y
|
||||
elif echo $OUTPUT | grep -q "CloudLinux 8"; then
|
||||
rm -f /etc/yum.repos.d/CyberPanel.repo
|
||||
dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm
|
||||
echo -e "\nDetecting Cloudlinux 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
|
||||
yum autoremove epel-release -y
|
||||
dnf install epel-release -y
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 18.04"; then
|
||||
echo -e "\nDetecting Ubuntu 18.04...\n"
|
||||
SERVER_OS="Ubuntu"
|
||||
@@ -247,9 +259,9 @@ fi
|
||||
rm -f requirments.txt
|
||||
|
||||
if [[ $UBUNTU_20 == "False" ]]; then
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip-2.zip
|
||||
else
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/ubuntu-pip.zip
|
||||
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/ubuntu-pip-2.zip
|
||||
fi
|
||||
|
||||
check_return
|
||||
|
||||
@@ -23,10 +23,13 @@ elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then
|
||||
echo -e "\nDetecting Ubuntu 18.04...\n"
|
||||
SERVER_OS="Ubuntu"
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 20.04" ; then
|
||||
echo -e "\nDetecting Ubuntu 20.04...\n"
|
||||
SERVER_OS="Ubuntu"
|
||||
else
|
||||
cat /etc/*release
|
||||
echo -e "\nUnable to detect your OS...\n"
|
||||
echo -e "\nCyberPanel is supported on Ubuntu 18.04, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n"
|
||||
echo -e "\nCyberPanel is supported on Ubuntu 18.04, Ubuntu 20.04, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@@ -141,9 +144,9 @@ if [[ $SERVER_COUNTRY == "CN" ]] ; then
|
||||
GIT_CONTENT_URL="gitee.com/qtwrk/cyberpanel/raw"
|
||||
fi
|
||||
|
||||
echo -e "CyberPanel Upgrade will start in 10 seconds"
|
||||
echo -e "If you want to cancel, please press CTRL + C to cancel it"
|
||||
sleep 10
|
||||
#echo -e "CyberPanel Upgrade will start in 10 seconds"
|
||||
#echo -e "If you want to cancel, please press CTRL + C to cancel it"
|
||||
#sleep 10
|
||||
echo -e "CyberPanel upgrading..."
|
||||
rm -f /usr/local/cyberpanel_upgrade.sh
|
||||
wget -O /usr/local/cyberpanel_upgrade.sh -q https://$GIT_CONTENT_URL/${BRANCH_NAME}/cyberpanel_upgrade.sh
|
||||
|
||||
@@ -12,13 +12,15 @@ from plogical.acl import ACLManager
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.mysqlUtilities import mysqlUtilities
|
||||
from websiteFunctions.models import Websites
|
||||
from databases.models import Databases
|
||||
from databases.models import Databases, DBMeta
|
||||
import argparse
|
||||
from loginSystem.models import Administrator
|
||||
import plogical.randomPassword as randomPassword
|
||||
|
||||
class DatabaseManager:
|
||||
|
||||
REMOTE_ACCESS = 'remote_access'
|
||||
|
||||
def loadDatabaseHome(self, request = None, userID = None):
|
||||
try:
|
||||
return render(request, 'databases/index.html')
|
||||
@@ -215,6 +217,77 @@ class DatabaseManager:
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def remoteAccess(self, userID = None, data = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'listDatabases') == 0:
|
||||
return ACLManager.loadErrorJson('changePasswordStatus', 0)
|
||||
|
||||
userName = data['dbUserName']
|
||||
|
||||
db = Databases.objects.filter(dbUser=userName)
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
if ACLManager.checkOwnership(db[0].website.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
try:
|
||||
meta = DBMeta.objects.get(database=db[0], key=DatabaseManager.REMOTE_ACCESS)
|
||||
data_ret = {'status': 1, 'dbHost': json.loads(meta.value)['remoteIP']}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 1, 'dbHost': 'localhost'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0,'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def allowRemoteIP(self, userID = None, data = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'listDatabases') == 0:
|
||||
return ACLManager.loadErrorJson('changePasswordStatus', 0)
|
||||
|
||||
userName = data['dbUserName']
|
||||
remoteIP = data['remoteIP']
|
||||
|
||||
db = Databases.objects.filter(dbUser=userName)
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
if ACLManager.checkOwnership(db[0].website.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
mysqlUtilities.allowRemoteAccess(db[0].dbName, userName, remoteIP)
|
||||
|
||||
metaData = {'remoteIP': remoteIP}
|
||||
|
||||
try:
|
||||
meta = DBMeta.objects.get(database=db[0], key=DatabaseManager.REMOTE_ACCESS)
|
||||
meta.value = json.dumps(metaData)
|
||||
meta.save()
|
||||
except:
|
||||
DBMeta(database=db[0], value = json.dumps(metaData), key=DatabaseManager.REMOTE_ACCESS).save()
|
||||
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0,'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@staticmethod
|
||||
def generatePHPMYAdminData(userID):
|
||||
try:
|
||||
|
||||
@@ -10,3 +10,8 @@ class Databases(models.Model):
|
||||
website = models.ForeignKey(Websites, on_delete=models.CASCADE)
|
||||
dbName = models.CharField(max_length=50,unique=True)
|
||||
dbUser = models.CharField(max_length=50)
|
||||
|
||||
class DBMeta(models.Model):
|
||||
database = models.ForeignKey(Databases, on_delete=models.CASCADE)
|
||||
key = models.CharField(max_length=200)
|
||||
value = models.TextField()
|
||||
|
||||
@@ -454,6 +454,113 @@ app.controller('listDBs', function ($scope, $http) {
|
||||
$scope.generatedPasswordView = true;
|
||||
};
|
||||
|
||||
$scope.remoteAccess = function (userName) {
|
||||
|
||||
$scope.dbUsername = userName;
|
||||
$scope.dbLoading = false;
|
||||
|
||||
|
||||
url = "/dataBases/remoteAccess";
|
||||
|
||||
var data = {
|
||||
dbUserName: $scope.dbUsername
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.dbLoading = true;
|
||||
|
||||
if (response.data.status === 1) {
|
||||
|
||||
$scope.dbHost = response.data.dbHost;
|
||||
|
||||
}
|
||||
else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
$scope.dbLoading = true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.allowRemoteIP = function () {
|
||||
|
||||
$scope.dbLoading = false;
|
||||
|
||||
url = "/dataBases/allowRemoteIP";
|
||||
|
||||
var data = {
|
||||
dbUserName: $scope.dbUsername,
|
||||
remoteIP: $scope.remoteIP
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.dbLoading = true;
|
||||
|
||||
if (response.data.status === 1) {
|
||||
|
||||
$scope.remoteAccess($scope.dbUsername);
|
||||
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Changes applied.',
|
||||
type: 'success'
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
$scope.dbLoading = true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -70,18 +70,19 @@
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<button type="button" ng-click="generatePassword()"
|
||||
class="btn btn-primary">{% trans "Generate" %}</button>
|
||||
<button type="button" ng-click="generatePassword()"
|
||||
class="btn btn-primary">{% trans "Generate" %}</button>
|
||||
</div>
|
||||
|
||||
<label ng-hide="generatedPasswordView" style="margin-top: 1%" class="col-sm-3 control-label">{% trans "Generated Password" %}</label>
|
||||
<label ng-hide="generatedPasswordView" style="margin-top: 1%"
|
||||
class="col-sm-3 control-label">{% trans "Generated Password" %}</label>
|
||||
<div ng-hide="generatedPasswordView" style="margin-top: 1%" class="col-sm-6">
|
||||
<input name="dom" type="text" class="form-control" ng-model="dbPassword" required>
|
||||
</div>
|
||||
|
||||
<div ng-hide="generatedPasswordView" style="margin-top: 1%" class="col-sm-3">
|
||||
<button type="button" ng-click="usePassword()"
|
||||
class="btn btn-primary">{% trans "Use" %}</button>
|
||||
<button type="button" ng-click="usePassword()"
|
||||
class="btn btn-primary">{% trans "Use" %}</button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -105,6 +106,7 @@
|
||||
<th>{% trans "Database Name" %}</th>
|
||||
<th>{% trans "Database User" %}</th>
|
||||
<th>{% trans "Password" %}</th>
|
||||
<th>{% trans "Remote Access" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -116,6 +118,75 @@
|
||||
<button type="button" ng-click="changePassword(record.dbUser)"
|
||||
class="btn ra-100 btn-purple">{% trans "Change" %}</button>
|
||||
</td>
|
||||
<td>
|
||||
<button ng-click="remoteAccess(record.dbUser)" data-toggle="modal"
|
||||
data-target="#remoteAccess" type="button"
|
||||
class="btn ra-100 btn-purple">{% trans "Manage" %}</button>
|
||||
<div id="remoteAccess" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
×
|
||||
</button>
|
||||
<h4 class="modal-title">{% trans "Remote Access" %} <img
|
||||
ng-hide="dbLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form name="containerSettingsForm" action="/"
|
||||
class="form-horizontal">
|
||||
<div ng-hide="installationDetailsForm"
|
||||
class="form-group">
|
||||
<label class="col-sm-5 control-label">{% trans "Allow Remote Access on following IP" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input placeholder="IP Address"
|
||||
name="remoteIP" type="text"
|
||||
class="form-control"
|
||||
ng-model="$parent.remoteIP"
|
||||
required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<label class="col-sm-5 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="allowRemoteIP()"
|
||||
class="btn btn-primary btn-lg">{% trans "Save Changes" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
|
||||
<table style="margin-top: 2%" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Host</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{$ dbUsername $}</td>
|
||||
<td>{$ dbHost $}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -13,7 +13,9 @@ urlpatterns = [
|
||||
|
||||
url(r'^listDBs', views.listDBs, name='listDBs'),
|
||||
|
||||
url(r'^changePassword', views.changePassword, name='changePassword'),
|
||||
url(r'^changePassword$', views.changePassword, name='changePassword'),
|
||||
url(r'^remoteAccess$', views.remoteAccess, name='remoteAccess'),
|
||||
url(r'^allowRemoteIP$', views.allowRemoteIP, name='allowRemoteIP'),
|
||||
url(r'^phpMyAdmin$', views.phpMyAdmin, name='phpMyAdmin'),
|
||||
url(r'^setupPHPMYAdminSession$', views.setupPHPMYAdminSession, name='setupPHPMYAdminSession'),
|
||||
]
|
||||
@@ -120,6 +120,28 @@ def changePassword(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def remoteAccess(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
dm = DatabaseManager()
|
||||
coreResult = dm.remoteAccess(userID, json.loads(request.body))
|
||||
|
||||
return coreResult
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def allowRemoteIP(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
dm = DatabaseManager()
|
||||
coreResult = dm.allowRemoteIP(userID, json.loads(request.body))
|
||||
|
||||
return coreResult
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def phpMyAdmin(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
@@ -5,7 +5,7 @@ import time
|
||||
import csv
|
||||
import re
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from .models import EmailMarketing, EmailLists, EmailsInList, EmailTemplate, EmailJobs, SMTPHosts, ValidationLog
|
||||
from .models import EmailLists, EmailsInList, EmailTemplate, EmailJobs, SMTPHosts, ValidationLog
|
||||
from plogical.backupSchedule import backupSchedule
|
||||
from websiteFunctions.models import Websites
|
||||
import threading as multi
|
||||
@@ -164,7 +164,7 @@ class emailMarketing(multi.Thread):
|
||||
email = items.email
|
||||
self.currentEmail = email
|
||||
domainName = email.split('@')[1]
|
||||
records = DNS.dnslookup(domainName, 'MX')
|
||||
records = DNS.dnslookup(domainName, 'MX', 15)
|
||||
|
||||
counterGlobal = counterGlobal + 1
|
||||
|
||||
@@ -191,9 +191,9 @@ class emailMarketing(multi.Thread):
|
||||
message='IP being used for validation until next sleep: %s.' % (str(self.currentIP))).save()
|
||||
|
||||
if self.currentIP == None:
|
||||
server = smtplib.SMTP()
|
||||
server = smtplib.SMTP(timeout=10)
|
||||
else:
|
||||
server = smtplib.SMTP(self.currentIP)
|
||||
server = smtplib.SMTP(self.currentIP, timeout=10)
|
||||
else:
|
||||
|
||||
if self.currentIP == '':
|
||||
@@ -203,9 +203,9 @@ class emailMarketing(multi.Thread):
|
||||
str(self.currentIP))).save()
|
||||
|
||||
if self.currentIP == None:
|
||||
server = smtplib.SMTP()
|
||||
server = smtplib.SMTP(timeout=10)
|
||||
else:
|
||||
server = smtplib.SMTP(self.currentIP)
|
||||
server = smtplib.SMTP(self.currentIP, timeout=10)
|
||||
else:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
'Delay not configured..')
|
||||
@@ -213,15 +213,15 @@ class emailMarketing(multi.Thread):
|
||||
ValidationLog(owner=verificationList, status=backupSchedule.INFO,
|
||||
message='Delay not configured..').save()
|
||||
|
||||
server = smtplib.SMTP()
|
||||
server = smtplib.SMTP(timeout=10)
|
||||
except BaseException as msg:
|
||||
|
||||
ValidationLog(owner=verificationList, status=backupSchedule.ERROR,
|
||||
message='Delay not configured. Error message: %s' % (str(msg))).save()
|
||||
|
||||
server = smtplib.SMTP()
|
||||
server = smtplib.SMTP(timeout=10)
|
||||
else:
|
||||
server = smtplib.SMTP()
|
||||
server = smtplib.SMTP(timeout=10)
|
||||
|
||||
###
|
||||
|
||||
@@ -271,27 +271,35 @@ class emailMarketing(multi.Thread):
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return 0
|
||||
|
||||
def setupSMTPConnection(self):
|
||||
try:
|
||||
if self.extraArgs['host'] == 'localhost':
|
||||
self.smtpServer = smtplib.SMTP('127.0.0.1')
|
||||
return 1
|
||||
else:
|
||||
self.verifyHost = SMTPHosts.objects.get(host=self.extraArgs['host'])
|
||||
self.smtpServer = smtplib.SMTP(str(self.verifyHost.host), int(self.verifyHost.port))
|
||||
self.smtpServer.login(str(self.verifyHost.userName), str(self.verifyHost.password))
|
||||
return 1
|
||||
except smtplib.SMTPHeloError:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'The server didnt reply properly to the HELO greeting.')
|
||||
return 0
|
||||
except smtplib.SMTPAuthenticationError:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Username and password combination not accepted.')
|
||||
return 0
|
||||
except smtplib.SMTPException:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'No suitable authentication method was found.')
|
||||
return 0
|
||||
|
||||
def startEmailJob(self):
|
||||
try:
|
||||
try:
|
||||
if self.extraArgs['host'] == 'localhost':
|
||||
smtpServer = smtplib.SMTP('127.0.0.1')
|
||||
else:
|
||||
verifyHost = SMTPHosts.objects.get(host=self.extraArgs['host'])
|
||||
smtpServer = smtplib.SMTP(str(verifyHost.host), int(verifyHost.port))
|
||||
smtpServer.login(str(verifyHost.userName), str(verifyHost.password))
|
||||
except smtplib.SMTPHeloError:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'The server didnt reply properly to the HELO greeting.')
|
||||
return
|
||||
except smtplib.SMTPAuthenticationError:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Username and password combination not accepted.')
|
||||
return
|
||||
except smtplib.SMTPException:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'No suitable authentication method was found.')
|
||||
return
|
||||
|
||||
if self.setupSMTPConnection() == 0:
|
||||
logging.CyberCPLogFileWriter.writeToFile('SMTP Connection failed. [301]')
|
||||
return 0
|
||||
|
||||
emailList = EmailLists.objects.get(listName=self.extraArgs['listName'])
|
||||
allEmails = emailList.emailsinlist_set.all()
|
||||
@@ -364,7 +372,16 @@ class emailMarketing(multi.Thread):
|
||||
html = MIMEText(finalMessage, 'plain')
|
||||
message.attach(html)
|
||||
|
||||
smtpServer.sendmail(message['From'], items.email, message.as_string())
|
||||
try:
|
||||
status = self.smtpServer.noop()[0]
|
||||
self.smtpServer.sendmail(message['From'], items.email, message.as_string())
|
||||
except: # smtplib.SMTPServerDisconnected
|
||||
if self.setupSMTPConnection() == 0:
|
||||
logging.CyberCPLogFileWriter.writeToFile('SMTP Connection failed. [301]')
|
||||
return 0
|
||||
self.smtpServer.sendmail(message['From'], items.email, message.as_string())
|
||||
|
||||
|
||||
sent = sent + 1
|
||||
emailJob.sent = sent
|
||||
emailJob.save()
|
||||
@@ -379,7 +396,10 @@ class emailMarketing(multi.Thread):
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Successfully sent: ' + str(
|
||||
sent) + ', Failed: ' + str(failed))
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
if self.setupSMTPConnection() == 0:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
'SMTP Connection failed. Error: %s. [392]' % (str(msg)))
|
||||
return 0
|
||||
except BaseException as msg:
|
||||
failed = failed + 1
|
||||
emailJob.failed = failed
|
||||
@@ -387,13 +407,13 @@ class emailMarketing(multi.Thread):
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Successfully sent: ' + str(
|
||||
sent) + ', Failed: ' + str(failed))
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
if self.setupSMTPConnection() == 0:
|
||||
logging.CyberCPLogFileWriter.writeToFile('SMTP Connection failed. Error: %s. [399]' % (str(msg)))
|
||||
return 0
|
||||
|
||||
|
||||
emailJob = EmailJobs(owner=emailMessage, date=time.strftime("%I-%M-%S-%a-%b-%Y"),
|
||||
host=self.extraArgs['host'], totalEmails=totalEmails,
|
||||
sent=sent, failed=failed
|
||||
)
|
||||
emailJob.sent = sent
|
||||
emailJob.failed = failed
|
||||
emailJob.save()
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
|
||||
@@ -15,7 +15,7 @@ from stat import *
|
||||
import stat
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 1
|
||||
BUILD = 2
|
||||
|
||||
char_set = {'small': 'abcdefghijklmnopqrstuvwxyz',
|
||||
'nums': '0123456789',
|
||||
@@ -92,16 +92,23 @@ def get_Ubuntu_release():
|
||||
|
||||
|
||||
class preFlightsChecks:
|
||||
debug = 1
|
||||
cyberPanelMirror = "mirror.cyberpanel.net/pip"
|
||||
cdn = 'cyberpanel.sh'
|
||||
|
||||
def __init__(self, rootPath, ip, path, cwd, cyberPanelPath, distro):
|
||||
def __init__(self, rootPath, ip, path, cwd, cyberPanelPath, distro, remotemysql = None , mysqlhost = None, mysqldb = None, mysqluser = None, mysqlpassword = None, mysqlport = None):
|
||||
self.ipAddr = ip
|
||||
self.path = path
|
||||
self.cwd = cwd
|
||||
self.server_root_path = rootPath
|
||||
self.cyberPanelPath = cyberPanelPath
|
||||
self.distro = distro
|
||||
self.remotemysql = remotemysql
|
||||
self.mysqlhost = mysqlhost
|
||||
self.mysqluser = mysqluser
|
||||
self.mysqlpassword = mysqlpassword
|
||||
self.mysqlport = mysqlport
|
||||
self.mysqldb = mysqldb
|
||||
|
||||
@staticmethod
|
||||
def stdOut(message, log=0, do_exit=0, code=os.EX_OK):
|
||||
@@ -373,11 +380,14 @@ class preFlightsChecks:
|
||||
|
||||
### update password:
|
||||
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
if self.remotemysql == 'OFF':
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
else:
|
||||
password = self.mysqlpassword
|
||||
|
||||
### Put correct mysql passwords in settings file!
|
||||
|
||||
@@ -396,6 +406,7 @@ class preFlightsChecks:
|
||||
SK = "SECRET_KEY = '%s'\n" % (generate_pass(50))
|
||||
writeDataToFile.writelines(SK)
|
||||
continue
|
||||
|
||||
if mysql == 'Two':
|
||||
if items.find("'PASSWORD':") > -1:
|
||||
if counter == 0:
|
||||
@@ -411,7 +422,6 @@ class preFlightsChecks:
|
||||
if counter == 0:
|
||||
writeDataToFile.writelines(" 'PASSWORD': '" + mysqlPassword + "'," + "\n")
|
||||
counter = counter + 1
|
||||
|
||||
else:
|
||||
writeDataToFile.writelines(" 'PASSWORD': '" + password + "'," + "\n")
|
||||
elif items.find('127.0.0.1') > -1:
|
||||
@@ -426,6 +436,19 @@ class preFlightsChecks:
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
if self.remotemysql == 'ON':
|
||||
command = "sed -i 's|localhost|%s|g' %s" % (self.mysqlhost, path)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
# command = "sed -i 's|'mysql'|'%s'|g' %s" % (self.mysqldb, path)
|
||||
# preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = "sed -i 's|'USER': 'root',|'USER': '%s',|g' %s" % (self.mysqluser, path)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = "sed -i 's|'PORT':''|'PORT':'%s'|g' %s" % (self.mysqlport, path)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
logging.InstallLog.writeToFile("settings.py updated!")
|
||||
|
||||
#self.setupVirtualEnv(self.distro)
|
||||
@@ -596,6 +619,13 @@ class preFlightsChecks:
|
||||
command = "find /usr/local/CyberCP/ -name '*.pyc' -delete"
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
if self.distro == cent8:
|
||||
command = 'chown root:pdns /etc/pdns/pdns.conf'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
command = 'chmod 640 /etc/pdns/pdns.conf'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
def install_unzip(self):
|
||||
self.stdOut("Install unzip")
|
||||
try:
|
||||
@@ -668,6 +698,10 @@ class preFlightsChecks:
|
||||
preFlightsChecks.call(command, self.distro, '[chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin]',
|
||||
'chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin', 1, 0, os.EX_OSERR)
|
||||
|
||||
if self.remotemysql == 'ON':
|
||||
command = "sed -i 's|'localhost'|'%s'|g' %s" % (self.mysqlhost, '/usr/local/CyberCP/public/phpmyadmin/config.inc.php')
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [download_install_phpmyadmin]")
|
||||
return 0
|
||||
@@ -887,6 +921,32 @@ class preFlightsChecks:
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
|
||||
|
||||
if self.remotemysql == 'ON':
|
||||
command = "sed -i 's|host=localhost|host=%s|g' %s" % (self.mysqlhost, davecotmysql)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = "sed -i 's|port=3306|port=%s|g' %s" % (self.mysqlport, davecotmysql)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
##
|
||||
|
||||
command = "sed -i 's|localhost|%s:%s|g' %s" % (self.mysqlhost, self.mysqlport, mysql_virtual_domains)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = "sed -i 's|localhost|%s:%s|g' %s" % (
|
||||
self.mysqlhost, self.mysqlport, mysql_virtual_forwardings)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = "sed -i 's|localhost|%s:%s|g' %s" % (
|
||||
self.mysqlhost, self.mysqlport, mysql_virtual_mailboxes)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = "sed -i 's|localhost|%s:%s|g' %s" % (
|
||||
self.mysqlhost, self.mysqlport, mysql_virtual_email2email)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
logging.InstallLog.writeToFile("Authentication for Postfix and Dovecot set.")
|
||||
|
||||
except BaseException as msg:
|
||||
@@ -1338,13 +1398,13 @@ imap_folder_list_limit = 0
|
||||
|
||||
lscpdPath = '/usr/local/lscp/bin/lscpd'
|
||||
|
||||
command = 'cp -f /usr/local/CyberCP/lscpd-0.2.5 /usr/local/lscp/bin/lscpd-0.2.5'
|
||||
command = 'cp -f /usr/local/CyberCP/lscpd-0.2.7 /usr/local/lscp/bin/lscpd-0.2.7'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = 'rm -f /usr/local/lscp/bin/lscpd'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = 'mv /usr/local/lscp/bin/lscpd-0.2.5 /usr/local/lscp/bin/lscpd'
|
||||
command = 'mv /usr/local/lscp/bin/lscpd-0.2.7 /usr/local/lscp/bin/lscpd'
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = 'chmod 755 %s' % (lscpdPath)
|
||||
@@ -2093,6 +2153,12 @@ def main():
|
||||
parser.add_argument('--serial', help='Install LS Ent or OpenLiteSpeed')
|
||||
parser.add_argument('--port', help='LSCPD Port')
|
||||
parser.add_argument('--redis', help='vHosts on Redis - Requires LiteSpeed Enterprise')
|
||||
parser.add_argument('--remotemysql', help='Opt to choose local or remote MySQL')
|
||||
parser.add_argument('--mysqlhost', help='MySQL host if remote is chosen.')
|
||||
parser.add_argument('--mysqldb', help='MySQL DB if remote is chosen.')
|
||||
parser.add_argument('--mysqluser', help='MySQL user if remote is chosen.')
|
||||
parser.add_argument('--mysqlpassword', help='MySQL password if remote is chosen.')
|
||||
parser.add_argument('--mysqlport', help='MySQL port if remote is chosen.')
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.InstallLog.writeToFile("Starting CyberPanel installation..")
|
||||
@@ -2128,12 +2194,29 @@ def main():
|
||||
|
||||
cwd = os.getcwd()
|
||||
|
||||
distro = get_distro()
|
||||
checks = preFlightsChecks("/usr/local/lsws/", args.publicip, "/usr/local", cwd, "/usr/local/CyberCP", distro)
|
||||
checks.mountTemp()
|
||||
if args.remotemysql == 'ON':
|
||||
remotemysql = args.remotemysql
|
||||
mysqlhost = args.mysqlhost
|
||||
mysqluser = args.mysqluser
|
||||
mysqlpassword = args.mysqlpassword
|
||||
mysqlport = args.mysqlport
|
||||
mysqldb = args.mysqldb
|
||||
|
||||
# if distro == ubuntu:
|
||||
# os.chdir("/etc/cyberpanel")
|
||||
if preFlightsChecks.debug:
|
||||
print('mysqlhost: %s, mysqldb: %s, mysqluser: %s, mysqlpassword: %s, mysqlport: %s' % (mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport))
|
||||
time.sleep(10)
|
||||
|
||||
else:
|
||||
remotemysql = args.remotemysql
|
||||
mysqlhost = ''
|
||||
mysqluser = ''
|
||||
mysqlpassword = ''
|
||||
mysqlport = ''
|
||||
mysqldb = ''
|
||||
|
||||
distro = get_distro()
|
||||
checks = preFlightsChecks("/usr/local/lsws/", args.publicip, "/usr/local", cwd, "/usr/local/CyberCP", distro, remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)
|
||||
checks.mountTemp()
|
||||
|
||||
if args.port == None:
|
||||
port = "8090"
|
||||
@@ -2153,10 +2236,11 @@ def main():
|
||||
|
||||
import installCyberPanel
|
||||
|
||||
|
||||
if ent == 0:
|
||||
installCyberPanel.Main(cwd, mysql, distro, ent, None, port, args.ftp, args.powerdns, args.publicip)
|
||||
installCyberPanel.Main(cwd, mysql, distro, ent, None, port, args.ftp, args.powerdns, args.publicip, remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)
|
||||
else:
|
||||
installCyberPanel.Main(cwd, mysql, distro, ent, serial, port, args.ftp, args.powerdns, args.publicip)
|
||||
installCyberPanel.Main(cwd, mysql, distro, ent, serial, port, args.ftp, args.powerdns, args.publicip, remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)
|
||||
|
||||
checks.setupPHPAndComposer()
|
||||
checks.fix_selinux_issue()
|
||||
|
||||
@@ -8,6 +8,7 @@ import errno
|
||||
import MySQLdb as mariadb
|
||||
import install
|
||||
from os.path import exists
|
||||
import time
|
||||
|
||||
#distros
|
||||
centos=0
|
||||
@@ -38,7 +39,7 @@ class InstallCyberPanel:
|
||||
mysql_Root_password = ""
|
||||
mysqlPassword = ""
|
||||
|
||||
def __init__(self, rootPath, cwd, distro, ent, serial = None, port = None, ftp = None, dns = None, publicip = None):
|
||||
def __init__(self, rootPath, cwd, distro, ent, serial = None, port = None, ftp = None, dns = None, publicip = None, remotemysql = None , mysqlhost = None, mysqldb = None, mysqluser = None, mysqlpassword = None, mysqlport = None):
|
||||
self.server_root_path = rootPath
|
||||
self.cwd = cwd
|
||||
self.distro = distro
|
||||
@@ -48,6 +49,12 @@ class InstallCyberPanel:
|
||||
self.ftp = None
|
||||
self.dns = dns
|
||||
self.publicip = publicip
|
||||
self.remotemysql = remotemysql
|
||||
self.mysqlhost = mysqlhost
|
||||
self.mysqluser = mysqluser
|
||||
self.mysqlpassword = mysqlpassword
|
||||
self.mysqlport = mysqlport
|
||||
self.mysqldb = mysqldb
|
||||
|
||||
@staticmethod
|
||||
def stdOut(message, log=0, exit=0, code=os.EX_OK):
|
||||
@@ -242,85 +249,45 @@ class InstallCyberPanel:
|
||||
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
## Fix configurations if two MYSQL are used
|
||||
|
||||
if mysql == 'Two':
|
||||
logging.InstallLog.writeToFile("Setting up MariaDB configurations!")
|
||||
InstallCyberPanel.stdOut("Setting up MariaDB configurations!")
|
||||
|
||||
pathConf = "/etc/my.cnf"
|
||||
pathServiceFile = "/etc/systemd/system/mysqld@.service"
|
||||
|
||||
if os.path.exists(pathConf):
|
||||
os.remove(pathConf)
|
||||
|
||||
if os.path.exists(pathServiceFile):
|
||||
os.remove(pathServiceFile)
|
||||
|
||||
os.chdir(self.cwd)
|
||||
|
||||
shutil.copy("mysql/my.cnf", pathConf)
|
||||
shutil.copy("mysql/mysqld@.service", pathServiceFile)
|
||||
|
||||
logging.InstallLog.writeToFile("MariaDB configurations set!")
|
||||
InstallCyberPanel.stdOut("MariaDB configurations set!")
|
||||
|
||||
##
|
||||
|
||||
command = "mysql_install_db --user=mysql --datadir=/var/lib/mysql1"
|
||||
install.preFlightsChecks.call(command, self.distro, '[installMySQL]',
|
||||
'Install MySQL',
|
||||
1, 1, os.EX_OSERR)
|
||||
|
||||
|
||||
##
|
||||
|
||||
command = "systemctl start mysqld@1"
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
##
|
||||
|
||||
command = "systemctl enable mysqld@1"
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
|
||||
|
||||
############## Start mariadb ######################
|
||||
|
||||
self.startMariaDB()
|
||||
|
||||
|
||||
def changeMYSQLRootPassword(self):
|
||||
if self.distro == ubuntu:
|
||||
passwordCMD = "use mysql;update user set password=PASSWORD('" + InstallCyberPanel.mysql_Root_password + "') where User='root';UPDATE user SET plugin='' WHERE User='root';flush privileges;"
|
||||
else:
|
||||
passwordCMD = "use mysql;update user set password=PASSWORD('" + InstallCyberPanel.mysql_Root_password + "') where User='root';flush privileges;"
|
||||
if self.remotemysql == 'OFF':
|
||||
if self.distro == ubuntu:
|
||||
passwordCMD = "use mysql;update user set password=PASSWORD('" + InstallCyberPanel.mysql_Root_password + "') where User='root';UPDATE user SET plugin='' WHERE User='root';flush privileges;"
|
||||
else:
|
||||
passwordCMD = "use mysql;update user set password=PASSWORD('" + InstallCyberPanel.mysql_Root_password + "') where User='root';flush privileges;"
|
||||
|
||||
command = 'mysql -u root -e "' + passwordCMD + '"'
|
||||
command = 'mysql -u root -e "' + passwordCMD + '"'
|
||||
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 0, 0, os.EX_OSERR)
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 0, 0, os.EX_OSERR)
|
||||
|
||||
def startMariaDB(self):
|
||||
|
||||
############## Start mariadb ######################
|
||||
if self.distro == cent8 or self.distro == ubuntu:
|
||||
command = 'systemctl start mariadb'
|
||||
else:
|
||||
command = "systemctl start mysql"
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
if self.remotemysql == 'OFF':
|
||||
############## Start mariadb ######################
|
||||
if self.distro == cent8 or self.distro == ubuntu:
|
||||
command = 'systemctl start mariadb'
|
||||
else:
|
||||
command = "systemctl start mysql"
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
############## Enable mariadb at system startup ######################
|
||||
############## Enable mariadb at system startup ######################
|
||||
|
||||
if os.path.exists('/etc/systemd/system/mysqld.service'):
|
||||
os.remove('/etc/systemd/system/mysqld.service')
|
||||
if os.path.exists('/etc/systemd/system/mariadb.service'):
|
||||
os.remove('/etc/systemd/system/mariadb.service')
|
||||
if os.path.exists('/etc/systemd/system/mysqld.service'):
|
||||
os.remove('/etc/systemd/system/mysqld.service')
|
||||
if os.path.exists('/etc/systemd/system/mariadb.service'):
|
||||
os.remove('/etc/systemd/system/mariadb.service')
|
||||
|
||||
if self.distro == ubuntu:
|
||||
command = "systemctl enable mariadb"
|
||||
else:
|
||||
command = "systemctl enable mariadb"
|
||||
if self.distro == ubuntu:
|
||||
command = "systemctl enable mariadb"
|
||||
else:
|
||||
command = "systemctl enable mariadb"
|
||||
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
def fixMariaDB(self):
|
||||
self.stdOut("Setup MariaDB so it can support Cyberpanel's needs")
|
||||
@@ -453,6 +420,18 @@ class InstallCyberPanel:
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
ftpConfPath = '/etc/pure-ftpd/pureftpd-mysql.conf'
|
||||
|
||||
if self.remotemysql == 'ON':
|
||||
command = "sed -i 's|localhost|%s|g' %s" % (self.mysqlhost, ftpConfPath)
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = "sed -i 's|3306|%s|g' %s" % (self.mysqlport, ftpConfPath)
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = "sed -i 's|MYSQLSocket /var/lib/mysql/mysql.sock||g' %s" % (ftpConfPath)
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
if self.distro == ubuntu:
|
||||
|
||||
if os.path.exists('/etc/pure-ftpd/db/mysql.conf'):
|
||||
@@ -584,6 +563,14 @@ class InstallCyberPanel:
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
|
||||
if self.remotemysql == 'ON':
|
||||
command = "sed -i 's|gmysql-host=localhost|gmysql-host=%s|g' %s" % (self.mysqlhost, dnsPath)
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = "sed -i 's|gmysql-port=3306|gmysql-port=%s|g' %s" % (self.mysqlport, dnsPath)
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
InstallCyberPanel.stdOut("PowerDNS configured!", 1)
|
||||
|
||||
except IOError as msg:
|
||||
@@ -602,41 +589,53 @@ class InstallCyberPanel:
|
||||
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
|
||||
def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns = None, publicip = None):
|
||||
def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns = None, publicip = None, remotemysql = None , mysqlhost = None, mysqldb = None, mysqluser = None, mysqlpassword = None, mysqlport = None):
|
||||
|
||||
InstallCyberPanel.mysqlPassword = randomPassword.generate_pass()
|
||||
InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass()
|
||||
|
||||
file_name = '/etc/cyberpanel/mysqlPassword'
|
||||
if os.access(file_name, os.F_OK):
|
||||
password = open(file_name, 'r')
|
||||
InstallCyberPanel.mysql_Root_password = password.readline()
|
||||
password.close()
|
||||
|
||||
if remotemysql == 'OFF':
|
||||
if os.access(file_name, os.F_OK):
|
||||
password = open(file_name, 'r')
|
||||
InstallCyberPanel.mysql_Root_password = password.readline()
|
||||
password.close()
|
||||
else:
|
||||
password = open(file_name, "w")
|
||||
password.writelines(InstallCyberPanel.mysql_Root_password)
|
||||
password.close()
|
||||
else:
|
||||
password = open(file_name, "w")
|
||||
password.writelines(InstallCyberPanel.mysql_Root_password)
|
||||
mysqlData = {'remotemysql': remotemysql, 'mysqlhost': mysqlhost, 'mysqldb':mysqldb, 'mysqluser': mysqluser, 'mysqlpassword': mysqlpassword, 'mysqlport': mysqlport}
|
||||
from json import dumps
|
||||
writeToFile = open(file_name, 'w')
|
||||
writeToFile.write(dumps(mysqlData))
|
||||
writeToFile.close()
|
||||
|
||||
if install.preFlightsChecks.debug:
|
||||
print(open(file_name, 'r').read())
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
|
||||
try:
|
||||
command = 'chmod 640 %s' % (file_name)
|
||||
password.close()
|
||||
try:
|
||||
install.preFlightsChecks.call(command, distro, '[chmod]',
|
||||
'',
|
||||
1, 0, os.EX_OSERR)
|
||||
command = 'chown root:cyberpanel %s' % (file_name)
|
||||
install.preFlightsChecks.call(command, distro, '[chmod]',
|
||||
'',
|
||||
1, 0, os.EX_OSERR)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
install.preFlightsChecks.call(command, distro, '[chmod]',
|
||||
'',
|
||||
1, 0, os.EX_OSERR)
|
||||
command = 'chown root:cyberpanel %s' % (file_name)
|
||||
install.preFlightsChecks.call(command, distro, '[chmod]',
|
||||
'',
|
||||
1, 0, os.EX_OSERR)
|
||||
except:
|
||||
pass
|
||||
|
||||
if distro == centos:
|
||||
InstallCyberPanel.mysqlPassword = randomPassword.generate_pass()
|
||||
else:
|
||||
InstallCyberPanel.mysqlPassword = InstallCyberPanel.mysql_Root_password
|
||||
|
||||
installer = InstallCyberPanel("/usr/local/lsws/",cwd, distro, ent, serial, port, ftp, dns, publicip)
|
||||
installer = InstallCyberPanel("/usr/local/lsws/",cwd, distro, ent, serial, port, ftp, dns, publicip, remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)
|
||||
|
||||
installer.installLiteSpeed()
|
||||
if ent == 0:
|
||||
@@ -647,12 +646,14 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
|
||||
|
||||
installer.installMySQL(mysql)
|
||||
installer.changeMYSQLRootPassword()
|
||||
#installer.changeMYSQLRootPasswordCyberPanel(mysql)
|
||||
installer.startMariaDB()
|
||||
if distro == ubuntu:
|
||||
installer.fixMariaDB()
|
||||
|
||||
mysqlUtilities.createDatabase("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword)
|
||||
installer.startMariaDB()
|
||||
|
||||
if remotemysql == 'OFF':
|
||||
if distro == ubuntu:
|
||||
installer.fixMariaDB()
|
||||
|
||||
mysqlUtilities.createDatabase("cyberpanel","cyberpanel", InstallCyberPanel.mysqlPassword, publicip)
|
||||
|
||||
if ftp == None:
|
||||
installer.installPureFTPD()
|
||||
|
||||
@@ -1,30 +1,54 @@
|
||||
import subprocess, shlex
|
||||
import install
|
||||
import time
|
||||
|
||||
class mysqlUtilities:
|
||||
|
||||
@staticmethod
|
||||
def createDatabase(dbname, dbuser, dbpassword):
|
||||
def createDatabase(dbname, dbuser, dbpassword, publicip):
|
||||
|
||||
try:
|
||||
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
|
||||
createDB = "CREATE DATABASE " + dbname
|
||||
|
||||
command = 'mysql -u root -p' + password + ' -e "' + createDB + '"'
|
||||
try:
|
||||
from json import loads
|
||||
mysqlData = loads(open("/etc/cyberpanel/mysqlPassword", 'r').read())
|
||||
|
||||
|
||||
initCommand = 'mysql -h %s --port %s -u %s -p%s -e "' % (mysqlData['mysqlhost'], mysqlData['mysqlport'], mysqlData['mysqluser'], mysqlData['mysqlpassword'])
|
||||
remote = 1
|
||||
except:
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
|
||||
initCommand = 'mysql -u root -p' + password + ' -e "'
|
||||
remote = 0
|
||||
|
||||
command = initCommand + createDB + '"'
|
||||
|
||||
if install.preFlightsChecks.debug:
|
||||
print(command)
|
||||
time.sleep(10)
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
return 0
|
||||
|
||||
createUser = "CREATE USER '" + dbuser + "'@'localhost' IDENTIFIED BY '" + dbpassword + "'"
|
||||
if remote:
|
||||
createUser = "CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (publicip) + dbpassword + "'"
|
||||
else:
|
||||
createUser = "CREATE USER '" + dbuser + "'@'localhost' IDENTIFIED BY '" + dbpassword + "'"
|
||||
|
||||
command = 'mysql -u root -p' + password + ' -e "' + createUser + '"'
|
||||
command = initCommand + createUser + '"'
|
||||
|
||||
if install.preFlightsChecks.debug:
|
||||
print(command)
|
||||
time.sleep(10)
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = subprocess.call(cmd)
|
||||
@@ -32,8 +56,17 @@ class mysqlUtilities:
|
||||
if res == 1:
|
||||
return 0
|
||||
else:
|
||||
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'"
|
||||
command = 'mysql -u root -p' + password + ' -e "' + dropDB + '"'
|
||||
if remote:
|
||||
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip)
|
||||
else:
|
||||
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'"
|
||||
|
||||
command = initCommand + dropDB + '"'
|
||||
|
||||
if install.preFlightsChecks.debug:
|
||||
print(command)
|
||||
time.sleep(10)
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
|
||||
BIN
locale/bn/LC_MESSAGES/django.mo
Normal file
BIN
locale/bn/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
6677
locale/bn/LC_MESSAGES/django.po
Normal file
6677
locale/bn/LC_MESSAGES/django.po
Normal file
File diff suppressed because it is too large
Load Diff
@@ -197,6 +197,7 @@
|
||||
<select ng-model="languageSelection" ng-init="languageSelection='english'"
|
||||
class="form-control">
|
||||
<option value="english">English</option>
|
||||
<option>Bangla</option>
|
||||
<option>Bosnian</option>
|
||||
<option>Bulgarian</option>
|
||||
<option>Chinese</option>
|
||||
@@ -235,4 +236,4 @@
|
||||
<script src="{% static 'loginSystem/login-systen.js' %}"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -19,7 +19,7 @@ from django.utils import translation
|
||||
# Create your views here.
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 1
|
||||
BUILD = 2
|
||||
|
||||
def verifyLogin(request):
|
||||
try:
|
||||
@@ -71,6 +71,8 @@ def verifyLogin(request):
|
||||
user_Language = "de"
|
||||
elif data['languageSelection'] == "Indonesian":
|
||||
user_Language = "id"
|
||||
elif data['languageSelection'] == "Bangla":
|
||||
user_Language = "bn"
|
||||
|
||||
translation.activate(user_Language)
|
||||
response = HttpResponse()
|
||||
@@ -215,4 +217,4 @@ def logout(request):
|
||||
del request.session['userID']
|
||||
return render(request, 'loginSystem/login.html', {})
|
||||
except:
|
||||
return render(request,'loginSystem/login.html',{})
|
||||
return render(request,'loginSystem/login.html',{})
|
||||
Binary file not shown.
@@ -15,7 +15,7 @@ class PHPManager:
|
||||
if distro == ProcessUtilities.centos:
|
||||
return ['PHP 5.3', 'PHP 5.4', 'PHP 5.5', 'PHP 5.6', 'PHP 7.0', 'PHP 7.1', 'PHP 7.2', 'PHP 7.3', 'PHP 7.4']
|
||||
elif distro == ProcessUtilities.cent8:
|
||||
return ['PHP 7.2', 'PHP 7.3', 'PHP 7.4']
|
||||
return ['PHP 7.1','PHP 7.2', 'PHP 7.3', 'PHP 7.4']
|
||||
elif distro == ProcessUtilities.ubuntu20:
|
||||
return ['PHP 7.2', 'PHP 7.3', 'PHP 7.4']
|
||||
else:
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
from plogical import hashPassword
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
@@ -235,6 +238,23 @@ class PackagesManager:
|
||||
except BaseException as msg:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def listPackagesAPI(self,data=None):
|
||||
"""
|
||||
List of packages for API
|
||||
:param data:
|
||||
:return HttpResponse:
|
||||
"""
|
||||
try:
|
||||
adminUser = data['adminUser']
|
||||
admin = Administrator.objects.get(userName=adminUser)
|
||||
currentACL = ACLManager.loadedACL(admin.id)
|
||||
packageList = ACLManager.loadPackages(admin.id, currentACL)
|
||||
return HttpResponse(json.dumps(packageList))
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def fetchPackagesTable(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
|
||||
@@ -10,10 +10,14 @@ from IncBackups.models import BackupJob
|
||||
from random import randint
|
||||
import argparse
|
||||
import json
|
||||
from websiteFunctions.models import GitLogs, Websites
|
||||
from websiteFunctions.models import GitLogs, Websites, GDrive, GDriveJobLogs
|
||||
from websiteFunctions.website import WebsiteManager
|
||||
import time
|
||||
|
||||
import google.oauth2.credentials
|
||||
from googleapiclient.discovery import build
|
||||
from googleapiclient.http import MediaFileUpload
|
||||
from plogical.backupSchedule import backupSchedule
|
||||
import requests
|
||||
try:
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
@@ -192,6 +196,142 @@ class IncScheduler():
|
||||
except BaseException as msg:
|
||||
logging.writeToFile('[IncScheduler:193:checkDiskUsage] %s.' % str(msg))
|
||||
|
||||
@staticmethod
|
||||
def runGoogleDriveBackups(type):
|
||||
|
||||
backupRunTime = time.strftime("%m.%d.%Y_%H-%M-%S")
|
||||
backupLogPath = "/usr/local/lscp/logs/local_backup_log." + backupRunTime
|
||||
|
||||
for items in GDrive.objects.all():
|
||||
try:
|
||||
if items.runTime == type:
|
||||
gDriveData = json.loads(items.auth)
|
||||
try:
|
||||
credentials = google.oauth2.credentials.Credentials(gDriveData['token'], gDriveData['refresh_token'],
|
||||
gDriveData['token_uri'], None, None, gDriveData['scopes'])
|
||||
|
||||
|
||||
drive = build('drive', 'v3', credentials=credentials)
|
||||
drive.files().list(pageSize=10, fields="files(id, name)").execute()
|
||||
except BaseException as msg:
|
||||
try:
|
||||
|
||||
finalData = json.dumps({'refresh_token': gDriveData['refresh_token']})
|
||||
r = requests.post("https://platform.cyberpanel.net/refreshToken", data=finalData
|
||||
)
|
||||
gDriveData['token'] = json.loads(r.text)['access_token']
|
||||
|
||||
credentials = google.oauth2.credentials.Credentials(gDriveData['token'],
|
||||
gDriveData['refresh_token'],
|
||||
gDriveData['token_uri'],
|
||||
None,
|
||||
None,
|
||||
gDriveData['scopes'])
|
||||
|
||||
drive = build('drive', 'v3', credentials=credentials)
|
||||
drive.files().list(pageSize=5, fields="files(id, name)").execute()
|
||||
|
||||
items.auth = json.dumps(gDriveData)
|
||||
items.save()
|
||||
except BaseException as msg:
|
||||
GDriveJobLogs(owner=items, status=backupSchedule.ERROR, message='Connection to this account failed. Delete and re-setup this account. Error: %s' % (str(msg))).save()
|
||||
continue
|
||||
|
||||
try:
|
||||
folderIDIP = gDriveData['folderIDIP']
|
||||
except:
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
## Create CyberPanel Folder
|
||||
|
||||
file_metadata = {
|
||||
'name': 'CyberPanel-%s' % (ipAddress),
|
||||
'mimeType': 'application/vnd.google-apps.folder'
|
||||
}
|
||||
file = drive.files().create(body=file_metadata,
|
||||
fields='id').execute()
|
||||
folderIDIP = file.get('id')
|
||||
|
||||
gDriveData['folderIDIP'] = folderIDIP
|
||||
|
||||
items.auth = json.dumps(gDriveData)
|
||||
items.save()
|
||||
|
||||
### Current folder to store files
|
||||
|
||||
file_metadata = {
|
||||
'name': time.strftime("%m.%d.%Y_%H-%M-%S"),
|
||||
'mimeType': 'application/vnd.google-apps.folder',
|
||||
'parents': [folderIDIP]
|
||||
}
|
||||
file = drive.files().create(body=file_metadata,
|
||||
fields='id').execute()
|
||||
folderID = file.get('id')
|
||||
|
||||
###
|
||||
|
||||
GDriveJobLogs(owner=items, status=backupSchedule.INFO, message='Starting backup job..').save()
|
||||
|
||||
for website in items.gdrivesites_set.all():
|
||||
try:
|
||||
GDriveJobLogs(owner=items, status=backupSchedule.INFO, message='Local backup creation started for %s..' % (website.domain)).save()
|
||||
|
||||
retValues = backupSchedule.createLocalBackup(website.domain, backupLogPath)
|
||||
|
||||
if retValues[0] == 0:
|
||||
GDriveJobLogs(owner=items, status=backupSchedule.ERROR,
|
||||
message='[ERROR] Backup failed for %s, error: %s moving on..' % (website.domain, retValues[1])).save()
|
||||
continue
|
||||
|
||||
completeFileToSend = retValues[1] + ".tar.gz"
|
||||
fileName = completeFileToSend.split('/')[-1]
|
||||
|
||||
file_metadata = {
|
||||
'name': '%s' % (fileName),
|
||||
'parents': [folderID]
|
||||
}
|
||||
media = MediaFileUpload(completeFileToSend, mimetype='application/gzip', resumable=True)
|
||||
try:
|
||||
drive.files().create(body=file_metadata, media_body=media, fields='id').execute()
|
||||
except:
|
||||
finalData = json.dumps({'refresh_token': gDriveData['refresh_token']})
|
||||
r = requests.post("https://platform.cyberpanel.net/refreshToken", data=finalData
|
||||
)
|
||||
gDriveData['token'] = json.loads(r.text)['access_token']
|
||||
|
||||
credentials = google.oauth2.credentials.Credentials(gDriveData['token'],
|
||||
gDriveData['refresh_token'],
|
||||
gDriveData['token_uri'],
|
||||
None,
|
||||
None,
|
||||
gDriveData['scopes'])
|
||||
|
||||
drive = build('drive', 'v3', credentials=credentials)
|
||||
drive.files().create(body=file_metadata, media_body=media, fields='id').execute()
|
||||
|
||||
items.auth = json.dumps(gDriveData)
|
||||
items.save()
|
||||
|
||||
GDriveJobLogs(owner=items, status=backupSchedule.INFO,
|
||||
message='Backup for %s successfully sent to Google Drive.' % (website.domain)).save()
|
||||
|
||||
os.remove(completeFileToSend)
|
||||
|
||||
except BaseException as msg:
|
||||
GDriveJobLogs(owner=items, status=backupSchedule.ERROR,
|
||||
message='[Site] Site backup failed, Error message: %s.' % (str(msg))).save()
|
||||
|
||||
|
||||
GDriveJobLogs(owner=items, status=backupSchedule.INFO,
|
||||
message='Job Completed').save()
|
||||
except BaseException as msg:
|
||||
GDriveJobLogs(owner=items, status=backupSchedule.ERROR,
|
||||
message='[Completely] Job failed, Error message: %s.' % (str(msg))).save()
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -200,6 +340,7 @@ def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
IncScheduler.startBackup(args.function)
|
||||
IncScheduler.runGoogleDriveBackups(args.function)
|
||||
IncScheduler.git(args.function)
|
||||
IncScheduler.checkDiskUsage()
|
||||
|
||||
|
||||
@@ -562,6 +562,22 @@ class ACLManager:
|
||||
else:
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def checkGDriveOwnership(gD, admin, currentACL):
|
||||
|
||||
try:
|
||||
if currentACL['admin'] == 1:
|
||||
return 1
|
||||
elif gD.owner == admin:
|
||||
return 1
|
||||
elif gD.owner.owner == admin.pk:
|
||||
return 1
|
||||
|
||||
return 0
|
||||
except:
|
||||
return 0
|
||||
|
||||
|
||||
@staticmethod
|
||||
def checkOwnershipZone(domain, admin, currentACL):
|
||||
domain = Websites.objects.get(domain=domain)
|
||||
|
||||
@@ -13,7 +13,7 @@ from packages.models import Package
|
||||
from baseTemplate.models import version
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 1
|
||||
BUILD = 2
|
||||
|
||||
if not os.geteuid() == 0:
|
||||
sys.exit("\nOnly root can run this script\n")
|
||||
|
||||
@@ -16,11 +16,12 @@ from plogical.mysqlUtilities import mysqlUtilities
|
||||
from databases.models import Databases
|
||||
from plogical.installUtilities import installUtilities
|
||||
import shutil
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
class ApplicationInstaller(multi.Thread):
|
||||
|
||||
LOCALHOST = 'localhost'
|
||||
|
||||
def __init__(self, installApp, extraArgs):
|
||||
multi.Thread.__init__(self)
|
||||
self.installApp = installApp
|
||||
@@ -220,6 +221,17 @@ class ApplicationInstaller(multi.Thread):
|
||||
logging.writeToFile(str(msg) + ' [ApplicationInstaller.installGit]')
|
||||
|
||||
def dbCreation(self, tempStatusPath, website):
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
try:
|
||||
import json
|
||||
jsonData = json.loads(open(passFile, 'r').read())
|
||||
|
||||
mysqlhost = jsonData['mysqlhost']
|
||||
ApplicationInstaller.LOCALHOST = mysqlhost
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
dbName = randomPassword.generate_pass()
|
||||
dbUser = dbName
|
||||
@@ -367,7 +379,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
statusFile.writelines('Configuring the installation,40')
|
||||
statusFile.close()
|
||||
|
||||
command = "wp core config --dbname=" + dbName + " --dbuser=" + dbUser + " --dbpass=" + dbPassword + " --dbhost=localhost --dbprefix=wp_ --allow-root --path=" + finalPath
|
||||
command = "wp core config --dbname=" + dbName + " --dbuser=" + dbUser + " --dbpass=" + dbPassword + " --dbhost=%s --dbprefix=wp_ --allow-root --path=" % (ApplicationInstaller.LOCALHOST) + finalPath
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
|
||||
if home == '0':
|
||||
|
||||
@@ -49,8 +49,6 @@ class backupSchedule:
|
||||
def createLocalBackup(virtualHost, backupLogPath):
|
||||
try:
|
||||
|
||||
startingTime = datetime.now()
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Starting local backup for: " + virtualHost)
|
||||
|
||||
###
|
||||
@@ -75,7 +73,6 @@ class backupSchedule:
|
||||
killCounter = 0
|
||||
|
||||
while (1):
|
||||
diff = datetime.now() - startingTime
|
||||
|
||||
backupDomain = virtualHost
|
||||
status = os.path.join("/home", backupDomain, "backup/status")
|
||||
@@ -91,10 +88,7 @@ class backupSchedule:
|
||||
ifRunning = ProcessUtilities.outputExecutioner('ps aux')
|
||||
|
||||
if (ifRunning.find('startBackup') > -1 or ifRunning.find('BackupRoot') > -1) and ifRunning.find('/%s/' % (backupDomain)):
|
||||
pass
|
||||
else:
|
||||
if os.path.exists(status):
|
||||
|
||||
status = open(status, 'r').read()
|
||||
time.sleep(2)
|
||||
|
||||
@@ -117,44 +111,51 @@ class backupSchedule:
|
||||
except:
|
||||
pass
|
||||
return 1, tempStoragePath
|
||||
else:
|
||||
return 0, 'Backup process killed without reporting any error.'
|
||||
else:
|
||||
if killCounter == 1:
|
||||
return 0, 'Backup process killed without reporting any error.'
|
||||
else:
|
||||
time.sleep(10)
|
||||
killCounter = 1
|
||||
|
||||
## file name read ends
|
||||
elif status.find("[5009]") > -1:
|
||||
## removing status file, so that backup can re-run
|
||||
try:
|
||||
command = 'sudo rm -f ' + status
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
if os.path.exists(status):
|
||||
status = open(status, 'r').read()
|
||||
time.sleep(2)
|
||||
command = 'sudo rm -f ' + backupFileNamePath
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
if status.find("Completed") > -1:
|
||||
command = 'sudo rm -f ' + pid
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
### Removing Files
|
||||
backupObs = Backups.objects.filter(fileName=fileName)
|
||||
for items in backupObs:
|
||||
items.delete()
|
||||
|
||||
command = 'sudo rm -f ' + status
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
except:
|
||||
pass
|
||||
|
||||
command = 'sudo rm -f ' + backupFileNamePath
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
backupSchedule.remoteBackupLogging(backupLogPath,
|
||||
"Local backup creating failed for %s, Error message: %s" % (
|
||||
virtualHost, status), backupSchedule.ERROR)
|
||||
|
||||
command = 'sudo rm -f ' + pid
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
try:
|
||||
os.remove(pathToFile)
|
||||
except:
|
||||
pass
|
||||
return 0, tempStoragePath
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Backup Completed for: " + virtualHost)
|
||||
try:
|
||||
os.remove(pathToFile)
|
||||
except:
|
||||
pass
|
||||
return 1, tempStoragePath
|
||||
elif os.path.exists(schedulerPath):
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed. Error: %s' % (
|
||||
open(schedulerPath, 'r').read()),
|
||||
backupSchedule.ERROR)
|
||||
os.remove(schedulerPath)
|
||||
return 0, 'Backup process killed.'
|
||||
else:
|
||||
if os.path.exists(status):
|
||||
status = open(status, 'r').read()
|
||||
time.sleep(2)
|
||||
|
||||
if status.find("Completed") > -1:
|
||||
|
||||
### Removing Files
|
||||
|
||||
elif status.find("[5009]") > -1:
|
||||
## removing status file, so that backup can re-run
|
||||
try:
|
||||
command = 'sudo rm -f ' + status
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
@@ -164,26 +165,29 @@ class backupSchedule:
|
||||
command = 'sudo rm -f ' + pid
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
backupObs = Backups.objects.filter(fileName=fileName)
|
||||
for items in backupObs:
|
||||
items.delete()
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Local backup creating failed for %s, Error message: %s" % (virtualHost, status), backupSchedule.ERROR)
|
||||
|
||||
try:
|
||||
os.remove(pathToFile)
|
||||
except:
|
||||
pass
|
||||
return 0, tempStoragePath
|
||||
|
||||
elif os.path.exists(schedulerPath):
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed without reporting any error.',
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Backup Completed for: " + virtualHost)
|
||||
try:
|
||||
os.remove(pathToFile)
|
||||
except:
|
||||
pass
|
||||
return 1, tempStoragePath
|
||||
elif os.path.exists(schedulerPath):
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed. Error: %s' % (open(schedulerPath, 'r').read()),
|
||||
backupSchedule.ERROR)
|
||||
os.remove(schedulerPath)
|
||||
return 0, 'Backup process killed without reporting any error.'
|
||||
os.remove(schedulerPath)
|
||||
return 0, 'Backup process killed.'
|
||||
else:
|
||||
if killCounter == 1:
|
||||
return 0, 'Backup process killed without reporting any error. [184]'
|
||||
elif os.path.exists(schedulerPath):
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, 'Backup process killed. Error: %s' % (
|
||||
open(schedulerPath, 'r').read()),
|
||||
backupSchedule.ERROR)
|
||||
os.remove(schedulerPath)
|
||||
return 0, 'Backup process killed.'
|
||||
else:
|
||||
time.sleep(10)
|
||||
killCounter = 1
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [119:startBackup]")
|
||||
|
||||
@@ -47,7 +47,7 @@ except:
|
||||
pass
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 1
|
||||
BUILD = 2
|
||||
|
||||
|
||||
## I am not the monster that you think I am..
|
||||
@@ -478,6 +478,8 @@ class backupUtilities:
|
||||
|
||||
## shutil.make_archive. Creating final package.
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, "Preparing final compressed package..\n")
|
||||
|
||||
make_archive(os.path.join(backupPath, backupName), 'gztar', tempStoragePath)
|
||||
rmtree(tempStoragePath)
|
||||
|
||||
@@ -485,8 +487,6 @@ class backupUtilities:
|
||||
|
||||
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)))
|
||||
|
||||
@@ -1266,7 +1266,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
writeToFile = open(schedulerPath, 'w')
|
||||
writeToFile.writelines('error')
|
||||
writeToFile.writelines('1269')
|
||||
writeToFile.close()
|
||||
return 0
|
||||
|
||||
@@ -1275,7 +1275,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
writeToFile = open(schedulerPath, 'w')
|
||||
writeToFile.writelines('error')
|
||||
writeToFile.writelines('1278')
|
||||
writeToFile.close()
|
||||
return 0
|
||||
|
||||
@@ -1286,7 +1286,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
writeToFile = open(schedulerPath, 'w')
|
||||
writeToFile.writelines('error')
|
||||
writeToFile.writelines('1289')
|
||||
writeToFile.close()
|
||||
return 0
|
||||
|
||||
@@ -1295,7 +1295,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
writeToFile = open(schedulerPath, 'w')
|
||||
writeToFile.writelines('error')
|
||||
writeToFile.writelines('1298')
|
||||
writeToFile.close()
|
||||
return 0
|
||||
|
||||
@@ -1305,7 +1305,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
writeToFile = open(schedulerPath, 'w')
|
||||
writeToFile.writelines('error')
|
||||
writeToFile.writelines('1308')
|
||||
writeToFile.close()
|
||||
return 0
|
||||
|
||||
@@ -1314,7 +1314,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
writeToFile = open(schedulerPath, 'w')
|
||||
writeToFile.writelines('error')
|
||||
writeToFile.writelines('1317')
|
||||
writeToFile.close()
|
||||
return 0
|
||||
|
||||
@@ -1322,7 +1322,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
|
||||
if result[0] == 0:
|
||||
writeToFile = open(schedulerPath, 'w')
|
||||
writeToFile.writelines('error')
|
||||
writeToFile.writelines('1325')
|
||||
writeToFile.close()
|
||||
logging.CyberCPLogFileWriter.statusWriter(status, str(result[1]) + ' [1084][5009]')
|
||||
return 0
|
||||
@@ -1339,7 +1339,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
if output.find('[5009') > -1:
|
||||
logging.CyberCPLogFileWriter.writeToFile(output)
|
||||
writeToFile = open(schedulerPath, 'w')
|
||||
writeToFile.writelines('error')
|
||||
writeToFile.writelines(output)
|
||||
writeToFile.close()
|
||||
return 0
|
||||
|
||||
@@ -1355,7 +1355,7 @@ def submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain):
|
||||
|
||||
if mysqlUtilities.mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel') == 0:
|
||||
writeToFile = open(schedulerPath, 'w')
|
||||
writeToFile.writelines('error')
|
||||
writeToFile.writelines('1358')
|
||||
writeToFile.close()
|
||||
return 0
|
||||
|
||||
|
||||
@@ -670,7 +670,7 @@ class cPanelImporter:
|
||||
cDBName = inItems.split('`')[1].replace('\\', '')
|
||||
logging.statusWriter(self.logFile, inItems, 1)
|
||||
if cDBName == items.replace('.sql', ''):
|
||||
cDBUser = inItems.split("'")[1]
|
||||
cDBUser = inItems.replace("`","'").replace("\\","").split("'")[1]
|
||||
message = 'Database user for %s is %s.' % (cDBName, cDBUser)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
if Databases.objects.filter(dbUser=cDBUser).count() > 0:
|
||||
@@ -718,6 +718,55 @@ class cPanelImporter:
|
||||
from filemanager.filemanager import FileManager
|
||||
fm = FileManager(None, None)
|
||||
fm.fixPermissions(self.mainDomain)
|
||||
|
||||
def createCronJobs(self):
|
||||
try:
|
||||
|
||||
message = 'Restoring cron jobs from %s.' % (self.backupFile)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
CompletPathToExtractedArchive = cPanelImporter.mainBackupPath + self.fileName
|
||||
cronPath = '%s/cron' % (CompletPathToExtractedArchive)
|
||||
|
||||
|
||||
if len(os.listdir(cronPath)) == 0:
|
||||
message = 'No Cron Job file found.'
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
return 1
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
localCronPath = "/var/spool/cron/" + self.externalApp
|
||||
else:
|
||||
localCronPath = "/var/spool/cron/crontabs/" + self.externalApp
|
||||
|
||||
localCronFile = open(localCronPath, "a+")
|
||||
|
||||
commandT = 'touch %s' % (localCronPath)
|
||||
ProcessUtilities.executioner(commandT, 'root')
|
||||
commandT = 'chown %s:%s %s' % (self.externalApp, self.externalApp, localCronPath)
|
||||
ProcessUtilities.executioner(commandT, 'root')
|
||||
|
||||
# There's only single file usually but running for all found
|
||||
for item in os.listdir(cronPath):
|
||||
cronFile = open('%s/%s' % (cronPath, item), 'r')
|
||||
cronJobs = cronFile.readlines()
|
||||
|
||||
# Filter actual jobs and remove variables and last new line character
|
||||
for job in cronJobs:
|
||||
if len(job.split(' ')) > 1:
|
||||
# Valid enough, add it to user
|
||||
localCronFile.write(job)
|
||||
|
||||
message = 'Cron Jobs successfully restored.'
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
return 1
|
||||
|
||||
except BaseException as msg:
|
||||
message = 'Failed to restore Cron Jobs from file %s, error message: %s.' % (
|
||||
self.backupFile, str(msg))
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
return 0
|
||||
|
||||
def MainController(self):
|
||||
|
||||
@@ -746,6 +795,11 @@ class cPanelImporter:
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
if self.createCronJobs():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
self.RestoreEmails()
|
||||
self.FixPermissions()
|
||||
|
||||
@@ -62,7 +62,6 @@ class findBWUsage:
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
@staticmethod
|
||||
def startCalculations():
|
||||
try:
|
||||
|
||||
@@ -21,9 +21,12 @@ from random import randint
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
import MySQLdb.cursors as cursors
|
||||
from math import ceil
|
||||
import argparse
|
||||
|
||||
class mysqlUtilities:
|
||||
|
||||
LOCALHOST = 'localhost'
|
||||
|
||||
@staticmethod
|
||||
def getPagination(records, toShow):
|
||||
pages = float(records) / float(toShow)
|
||||
@@ -53,17 +56,45 @@ class mysqlUtilities:
|
||||
@staticmethod
|
||||
def setupConnection():
|
||||
try:
|
||||
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
password = password.strip('\n').strip('\r')
|
||||
try:
|
||||
jsonData = json.loads(open(passFile, 'r').read())
|
||||
|
||||
conn = mysql.connect(user='root', passwd=password, cursorclass=cursors.SSCursor)
|
||||
cursor = conn.cursor()
|
||||
mysqluser = jsonData['mysqluser']
|
||||
mysqlpassword = jsonData['mysqlpassword']
|
||||
mysqlport = jsonData['mysqlport']
|
||||
mysqlhost = jsonData['mysqlhost']
|
||||
|
||||
return conn, cursor
|
||||
## Also set localhost to this server
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddressLocal = ipData.split('\n', 1)[0]
|
||||
|
||||
mysqlUtilities.LOCALHOST = ipAddressLocal
|
||||
|
||||
conn = mysql.connect(host=mysqlhost ,user=mysqluser, passwd=mysqlpassword, port=int(mysqlport), cursorclass=cursors.SSCursor)
|
||||
cursor = conn.cursor()
|
||||
|
||||
return conn, cursor
|
||||
|
||||
except BaseException as msg:
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile('%s. [setupConnection:75]' % (str(msg)))
|
||||
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
password = password.strip('\n').strip('\r')
|
||||
|
||||
conn = mysql.connect(user='root', passwd=password, cursorclass=cursors.SSCursor)
|
||||
cursor = conn.cursor()
|
||||
|
||||
return conn, cursor
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
@@ -79,8 +110,8 @@ class mysqlUtilities:
|
||||
return 0
|
||||
|
||||
cursor.execute("CREATE DATABASE " + dbname)
|
||||
cursor.execute("CREATE USER '" + dbuser + "'@'localhost' IDENTIFIED BY '"+dbpassword+"'")
|
||||
cursor.execute("GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'")
|
||||
cursor.execute("CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (mysqlUtilities.LOCALHOST) +dbpassword+"'")
|
||||
cursor.execute("GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (mysqlUtilities.LOCALHOST))
|
||||
connection.close()
|
||||
|
||||
return 1
|
||||
@@ -100,7 +131,7 @@ class mysqlUtilities:
|
||||
return 0
|
||||
|
||||
cursor.execute("CREATE DATABASE " + dbuser)
|
||||
cursor.execute("CREATE USER '" + dbuser + "'@'localhost' IDENTIFIED BY '" + dbpassword + "'")
|
||||
cursor.execute("CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (mysqlUtilities.LOCALHOST) + dbpassword + "'")
|
||||
|
||||
return 1
|
||||
|
||||
@@ -117,7 +148,7 @@ class mysqlUtilities:
|
||||
if connection == 0:
|
||||
return 0
|
||||
|
||||
cursor.execute("GRANT ALL PRIVILEGES ON " + dbName + ".* TO '" + globalUser + "'@'localhost'")
|
||||
cursor.execute("GRANT ALL PRIVILEGES ON " + dbName + ".* TO '" + globalUser + "'@'%s'" % (mysqlUtilities.LOCALHOST))
|
||||
connection.close()
|
||||
|
||||
return 1
|
||||
@@ -145,7 +176,7 @@ class mysqlUtilities:
|
||||
return 0
|
||||
|
||||
cursor.execute("DROP DATABASE `%s`" % (dbname))
|
||||
cursor.execute("DROP USER '"+dbuser+"'@'localhost'")
|
||||
cursor.execute("DROP USER '"+dbuser+"'@'%s'" % (mysqlUtilities.LOCALHOST))
|
||||
connection.close()
|
||||
|
||||
return 1
|
||||
@@ -158,9 +189,24 @@ class mysqlUtilities:
|
||||
def createDatabaseBackup(databaseName, tempStoragePath):
|
||||
try:
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
|
||||
try:
|
||||
jsonData = json.loads(open(passFile, 'r').read())
|
||||
|
||||
mysqluser = jsonData['mysqluser']
|
||||
mysqlpassword = jsonData['mysqlpassword']
|
||||
mysqlport = jsonData['mysqlport']
|
||||
mysqlhost = jsonData['mysqlhost']
|
||||
password = mysqlpassword
|
||||
except:
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
mysqlhost = 'localhost'
|
||||
mysqlport = '3306'
|
||||
mysqluser = 'root'
|
||||
|
||||
|
||||
cnfPath = '/home/cyberpanel/.my.cnf'
|
||||
|
||||
@@ -178,7 +224,7 @@ password=%s
|
||||
|
||||
os.chmod(cnfPath, 0o600)
|
||||
|
||||
command = 'mysqldump --defaults-extra-file=/home/cyberpanel/.my.cnf --host=localhost ' + databaseName
|
||||
command = 'mysqldump --defaults-extra-file=/home/cyberpanel/.my.cnf -u %s --host=%s --port %s %s' % (mysqluser, mysqlhost, mysqlport, databaseName)
|
||||
cmd = shlex.split(command)
|
||||
|
||||
try:
|
||||
@@ -205,9 +251,22 @@ password=%s
|
||||
try:
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
try:
|
||||
jsonData = json.loads(open(passFile, 'r').read())
|
||||
|
||||
mysqluser = jsonData['mysqluser']
|
||||
mysqlpassword = jsonData['mysqlpassword']
|
||||
mysqlport = jsonData['mysqlport']
|
||||
mysqlhost = jsonData['mysqlhost']
|
||||
password = mysqlpassword
|
||||
except:
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
mysqlhost = 'localhost'
|
||||
mysqlport = '3306'
|
||||
mysqluser = 'root'
|
||||
|
||||
cnfPath = '/home/cyberpanel/.my.cnf'
|
||||
|
||||
@@ -227,7 +286,7 @@ password=%s
|
||||
command = 'chown cyberpanel:cyberpanel %s' % (cnfPath)
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = 'mysql --defaults-extra-file=/home/cyberpanel/.my.cnf --host=localhost ' + databaseName
|
||||
command = 'mysql --defaults-extra-file=/home/cyberpanel/.my.cnf -u %s --host=%s --port %s %s' % (mysqluser, mysqlhost, mysqlport, databaseName)
|
||||
cmd = shlex.split(command)
|
||||
|
||||
if additionalName == None:
|
||||
@@ -250,7 +309,7 @@ password=%s
|
||||
if connection == 0:
|
||||
return 0
|
||||
|
||||
passwordCMD = "use mysql;SET PASSWORD FOR '" + databaseName + "'@'localhost' = '" + dbPassword + "';FLUSH PRIVILEGES;"
|
||||
passwordCMD = "use mysql;SET PASSWORD FOR '" + databaseName + "'@'%s' = '" % (mysqlUtilities.LOCALHOST) + dbPassword + "';FLUSH PRIVILEGES;"
|
||||
|
||||
cursor.execute(passwordCMD)
|
||||
connection.close()
|
||||
@@ -720,12 +779,12 @@ password=%s
|
||||
if encrypt == None:
|
||||
try:
|
||||
dbuser = DBUsers.objects.get(user=userName)
|
||||
cursor.execute("SET PASSWORD FOR '" + userName + "'@'localhost' = PASSWORD('" + dbPassword + "')")
|
||||
cursor.execute("SET PASSWORD FOR '" + userName + "'@'%s' = PASSWORD('" % (mysqlUtilities.LOCALHOST) + dbPassword + "')")
|
||||
except:
|
||||
userName = mysqlUtilities.fetchuser(userName)
|
||||
cursor.execute("SET PASSWORD FOR '" + userName + "'@'localhost' = PASSWORD('" + dbPassword + "')")
|
||||
cursor.execute("SET PASSWORD FOR '" + userName + "'@'%s' = PASSWORD('" % (mysqlUtilities.LOCALHOST) + dbPassword + "')")
|
||||
else:
|
||||
cursor.execute("SET PASSWORD FOR '" + userName + "'@'localhost' = '" + dbPassword + "'")
|
||||
cursor.execute("SET PASSWORD FOR '" + userName + "'@'%s' = '" % (mysqlUtilities.LOCALHOST) + dbPassword + "'")
|
||||
|
||||
connection.close()
|
||||
|
||||
@@ -773,3 +832,81 @@ password=%s
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[mysqlUtilities.fetchuser]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def allowRemoteAccess(dbName, userName, remoteIP):
|
||||
try:
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/mysqlUtilities.py enableRemoteMYSQL"
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
connection, cursor = mysqlUtilities.setupConnection()
|
||||
|
||||
if connection == 0:
|
||||
return 0
|
||||
cursor.execute("use mysql")
|
||||
|
||||
cursor.execute("update db set Host='%s' where Db='%s'" % (remoteIP, dbName))
|
||||
cursor.execute("update user set Host='%s' where user='%s'" % (remoteIP, userName))
|
||||
cursor.execute("FLUSH PRIVILEGES")
|
||||
|
||||
connection.close()
|
||||
|
||||
return 1
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[mysqlUtilities.allowRemoteAccess]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def enableRemoteMYSQL():
|
||||
try:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20 or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
cnfPath = '/etc/mysql/my.cnf'
|
||||
else:
|
||||
cnfPath = '/etc/my.cnf'
|
||||
|
||||
data = open(cnfPath, 'r').read()
|
||||
|
||||
if data.find('bind-address') > -1 and data.find('skip-name-resolve') > -1:
|
||||
print('1,None')
|
||||
return 1
|
||||
else:
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddressLocal = ipData.split('\n', 1)[0]
|
||||
|
||||
mysqldContent = '''
|
||||
[mysqld]
|
||||
bind-address=%s
|
||||
skip-name-resolve
|
||||
''' % (ipAddressLocal)
|
||||
|
||||
writeToFile = open(cnfPath, 'a')
|
||||
writeToFile.write(mysqldContent)
|
||||
writeToFile.close()
|
||||
|
||||
print('1,None')
|
||||
|
||||
from time import sleep
|
||||
sleep(5)
|
||||
ProcessUtilities.popenExecutioner('systemctl restart mariadb')
|
||||
return 1
|
||||
|
||||
except BaseException as msg:
|
||||
print('0,%s "[mysqlUtilities.enableRemoteMYSQL]' % (str(msg)))
|
||||
return 0
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='CyberPanel')
|
||||
parser.add_argument('function', help='Specific a function to call!')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.function == "enableRemoteMYSQL":
|
||||
mysqlUtilities.enableRemoteMYSQL()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -179,7 +179,7 @@ class ProcessUtilities(multi.Thread):
|
||||
time.sleep(2)
|
||||
|
||||
@staticmethod
|
||||
def sendCommand(command, user=None):
|
||||
def sendCommand(command, user=None, dir=None):
|
||||
try:
|
||||
ret = ProcessUtilities.setupUDSConnection()
|
||||
|
||||
@@ -201,12 +201,20 @@ class ProcessUtilities(multi.Thread):
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(ProcessUtilities.token + command)
|
||||
|
||||
sock.sendall((ProcessUtilities.token + command).encode('utf-8'))
|
||||
if dir == None:
|
||||
sock.sendall((ProcessUtilities.token + command).encode('utf-8'))
|
||||
else:
|
||||
command = '%s-d %s %s' % (ProcessUtilities.token, dir, command)
|
||||
sock.sendall(command.encode('utf-8'))
|
||||
else:
|
||||
command = '%s-u %s %s' % (ProcessUtilities.token, user, command)
|
||||
if dir == None:
|
||||
command = '%s-u %s %s' % (ProcessUtilities.token, user, command)
|
||||
else:
|
||||
command = '%s-u %s -d %s %s' % (ProcessUtilities.token, user, dir, command)
|
||||
command = command.replace('sudo', '')
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(command)
|
||||
|
||||
sock.sendall(command.encode('utf-8'))
|
||||
|
||||
data = ""
|
||||
@@ -250,7 +258,7 @@ class ProcessUtilities(multi.Thread):
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def outputExecutioner(command, user=None, shell = None):
|
||||
def outputExecutioner(command, user=None, shell = None, dir = None):
|
||||
try:
|
||||
if getpass.getuser() == 'root':
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
@@ -264,7 +272,7 @@ class ProcessUtilities(multi.Thread):
|
||||
if type(command) == list:
|
||||
command = " ".join(command)
|
||||
|
||||
return ProcessUtilities.sendCommand(command, user)[:-1]
|
||||
return ProcessUtilities.sendCommand(command, user, dir)[:-1]
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg) + "[outputExecutioner:188]")
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ from plogical import backupUtilities as backupUtil
|
||||
import subprocess
|
||||
import shlex
|
||||
from multiprocessing import Process
|
||||
from shutil import move,rmtree
|
||||
from plogical.backupSchedule import backupSchedule
|
||||
from shutil import rmtree
|
||||
|
||||
class remoteBackup:
|
||||
|
||||
@@ -227,14 +228,13 @@ class remoteBackup:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||
|
||||
@staticmethod
|
||||
def backupProcess(ipAddress, dir, backupLogPath,folderNumber,accountsToTransfer):
|
||||
def backupProcess(ipAddress, dir, backupLogPath,folderNumber, accountsToTransfer):
|
||||
try:
|
||||
## dir is without forward slash
|
||||
|
||||
for virtualHost in accountsToTransfer:
|
||||
|
||||
try:
|
||||
|
||||
if virtualHost == "vmail" or virtualHost == "backup":
|
||||
continue
|
||||
|
||||
@@ -243,59 +243,37 @@ class remoteBackup:
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + " Currently generating local backups for: " + virtualHost + "\n")
|
||||
writeToFile.close()
|
||||
|
||||
retValues = backupSchedule.createLocalBackup(virtualHost, backupLogPath)
|
||||
|
||||
finalData = json.dumps({'websiteToBeBacked': virtualHost})
|
||||
r = requests.post("http://localhost:5003/backup/submitBackupCreation", data=finalData,verify=False)
|
||||
|
||||
data = json.loads(r.text)
|
||||
|
||||
fileName = data['tempStorage']+".tar.gz"
|
||||
|
||||
completePathToBackupFile = fileName
|
||||
|
||||
|
||||
while (1):
|
||||
time.sleep(2)
|
||||
r = requests.post("http://localhost:5003/backup/backupStatus", data= finalData,verify=False)
|
||||
data = json.loads(r.text)
|
||||
|
||||
if retValues[0] == 1:
|
||||
writeToFile = open(backupLogPath, "a")
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + " Waiting for backup to complete.. " + "\n")
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + " Local Backup Completed for: " + virtualHost + "\n")
|
||||
|
||||
## move the generated backup file to specified destination
|
||||
|
||||
completedPathToSend = retValues[1] + ".tar.gz"
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + " Sending " + completedPathToSend + " to " + ipAddress + ".\n")
|
||||
|
||||
remoteBackup.sendBackup(completedPathToSend, ipAddress, str(folderNumber), writeToFile)
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + " Sent " + completedPathToSend + " to " + ipAddress + ".\n")
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + " #############################################" + "\n")
|
||||
|
||||
writeToFile.close()
|
||||
else:
|
||||
writeToFile = open(backupLogPath, "a")
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + 'Local backup failed for %s. Error message: %s' % (virtualHost, retValues[1]) )
|
||||
writeToFile.close()
|
||||
|
||||
if data['abort'] == 1:
|
||||
|
||||
writeToFile = open(backupLogPath, "a")
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + " Local Backup Completed for: " +virtualHost + " with status: "+ data['status'] +"\n")
|
||||
|
||||
|
||||
## move the generated backup file to specified destination
|
||||
|
||||
if os.path.exists(completePathToBackupFile):
|
||||
move(completePathToBackupFile,dir)
|
||||
|
||||
completedPathToSend = dir +"/" + completePathToBackupFile.split("/")[-1]
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + " Sending " + completedPathToSend +" to "+ipAddress +".\n")
|
||||
|
||||
|
||||
remoteBackup.sendBackup(completedPathToSend,ipAddress,str(folderNumber),writeToFile)
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + " Sent " + completedPathToSend + " to " + ipAddress + ".\n")
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%m.%d.%Y_%H-%M-%S") + "]" + " #############################################" + "\n")
|
||||
|
||||
writeToFile.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -306,7 +284,7 @@ class remoteBackup:
|
||||
|
||||
## removing local directory where backups were generated
|
||||
time.sleep(5)
|
||||
#rmtree(dir)
|
||||
rmtree(dir)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupProcess]")
|
||||
|
||||
@@ -14,7 +14,7 @@ import random
|
||||
import string
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 1
|
||||
BUILD = 2
|
||||
|
||||
CENTOS7 = 0
|
||||
CENTOS8 = 1
|
||||
@@ -1304,6 +1304,52 @@ class Upgrade:
|
||||
CONSTRAINT `websiteFunctions_bac_owner_id_af3d15f9_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_backupjob` (`id`)
|
||||
)"""
|
||||
|
||||
try:
|
||||
cursor.execute(query)
|
||||
except:
|
||||
pass
|
||||
|
||||
query = """CREATE TABLE `websiteFunctions_gdrive` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`auth` longtext NOT NULL,
|
||||
`runTime` varchar(20) NOT NULL,
|
||||
`owner_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`),
|
||||
KEY `websiteFunctions_gdr_owner_id_b5b1e86f_fk_loginSyst` (`owner_id`),
|
||||
CONSTRAINT `websiteFunctions_gdr_owner_id_b5b1e86f_fk_loginSyst` FOREIGN KEY (`owner_id`) REFERENCES `loginSystem_administrator` (`id`)
|
||||
)"""
|
||||
|
||||
try:
|
||||
cursor.execute(query)
|
||||
except:
|
||||
pass
|
||||
|
||||
query = """CREATE TABLE `websiteFunctions_gdrivesites` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`domain` varchar(200) NOT NULL,
|
||||
`owner_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `websiteFunctions_gdr_owner_id_ff78b305_fk_websiteFu` (`owner_id`),
|
||||
CONSTRAINT `websiteFunctions_gdr_owner_id_ff78b305_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_gdrive` (`id`)
|
||||
)"""
|
||||
|
||||
try:
|
||||
cursor.execute(query)
|
||||
except:
|
||||
pass
|
||||
|
||||
query = """CREATE TABLE `websiteFunctions_gdrivejoblogs` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`status` int(11) NOT NULL,
|
||||
`message` longtext NOT NULL,
|
||||
`owner_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `websiteFunctions_gdr_owner_id_4cf7983e_fk_websiteFu` (`owner_id`),
|
||||
CONSTRAINT `websiteFunctions_gdr_owner_id_4cf7983e_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_gdrive` (`id`)
|
||||
)"""
|
||||
|
||||
try:
|
||||
cursor.execute(query)
|
||||
except:
|
||||
@@ -1346,6 +1392,8 @@ class Upgrade:
|
||||
dbName = settings.DATABASES['default']['NAME']
|
||||
dbUser = settings.DATABASES['default']['USER']
|
||||
password = settings.DATABASES['default']['PASSWORD']
|
||||
host = settings.DATABASES['default']['HOST']
|
||||
port = settings.DATABASES['default']['PORT']
|
||||
|
||||
## Root DB Creds
|
||||
|
||||
@@ -1361,18 +1409,18 @@ class Upgrade:
|
||||
'NAME': '%s',
|
||||
'USER': '%s',
|
||||
'PASSWORD': '%s',
|
||||
'HOST': 'localhost',
|
||||
'PORT':''
|
||||
'HOST': '%s',
|
||||
'PORT':'%s'
|
||||
},
|
||||
'rootdb': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': '%s',
|
||||
'USER': '%s',
|
||||
'PASSWORD': '%s',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '',
|
||||
'HOST': '%s',
|
||||
'PORT': '%s',
|
||||
},
|
||||
}\n""" % (dbName, dbUser, password, rootdbName, rootdbdbUser, rootdbpassword)
|
||||
}\n""" % (dbName, dbUser, password, host, port, rootdbName, rootdbdbUser, rootdbpassword, host, port)
|
||||
|
||||
settingsFile = '/usr/local/CyberCP/CyberCP/settings.py'
|
||||
|
||||
@@ -1382,7 +1430,7 @@ class Upgrade:
|
||||
|
||||
os.chdir('/usr/local/CyberCP')
|
||||
|
||||
command = 'git config --global user.email "support@cyberpanel.met"'
|
||||
command = 'git config --global user.email "support@cyberpanel.net"'
|
||||
Upgrade.executioner(command, command, 1)
|
||||
|
||||
command = 'git config --global user.name "CyberPanel"'
|
||||
@@ -1474,13 +1522,13 @@ class Upgrade:
|
||||
if os.path.exists(lscpdPath):
|
||||
os.remove(lscpdPath)
|
||||
|
||||
command = 'cp -f /usr/local/CyberCP/lscpd-0.2.5 /usr/local/lscp/bin/lscpd-0.2.5'
|
||||
command = 'cp -f /usr/local/CyberCP/lscpd-0.2.7 /usr/local/lscp/bin/lscpd-0.2.7'
|
||||
Upgrade.executioner(command, command, 0)
|
||||
|
||||
command = 'rm -f /usr/local/lscp/bin/lscpd'
|
||||
Upgrade.executioner(command, command, 0)
|
||||
|
||||
command = 'mv /usr/local/lscp/bin/lscpd-0.2.5 /usr/local/lscp/bin/lscpd'
|
||||
command = 'mv /usr/local/lscp/bin/lscpd-0.2.7 /usr/local/lscp/bin/lscpd'
|
||||
Upgrade.executioner(command, command, 0)
|
||||
|
||||
command = 'chmod 755 %s' % (lscpdPath)
|
||||
@@ -1659,6 +1707,14 @@ class Upgrade:
|
||||
command = "find /usr/local/CyberCP/ -name '*.pyc' -delete"
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
if os.path.exists(Upgrade.CentOSPath):
|
||||
if Upgrade.decideCentosVersion() == CENTOS8:
|
||||
command = 'chown root:pdns /etc/pdns/pdns.conf'
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
command = 'chmod 640 /etc/pdns/pdns.conf'
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
Upgrade.stdOut("Permissions updated.")
|
||||
|
||||
except BaseException as msg:
|
||||
|
||||
@@ -32,7 +32,8 @@ accesslog $VH_ROOT/logs/$VH_NAME.access_log {
|
||||
logFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
|
||||
logHeaders 5
|
||||
rollingSize 10M
|
||||
keepDays 10 compressArchive 1
|
||||
keepDays 10
|
||||
compressArchive 1
|
||||
}
|
||||
|
||||
scripthandler {
|
||||
@@ -101,7 +102,8 @@ accesslog $VH_ROOT/logs/{masterDomain}.access_log {
|
||||
logFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
|
||||
logHeaders 5
|
||||
rollingSize 10M
|
||||
keepDays 10 compressArchive 1
|
||||
keepDays 10
|
||||
compressArchive 1
|
||||
}
|
||||
|
||||
phpIniOverride {
|
||||
@@ -427,4 +429,4 @@ pm.max_spare_servers = {pmMaxSpareServers}
|
||||
CacheRoot /home/{masterDomain}/lscache
|
||||
</IfModule>
|
||||
}
|
||||
}'"""
|
||||
}'"""
|
||||
|
||||
@@ -20,6 +20,9 @@ docutils==0.14
|
||||
enum34==1.1.6
|
||||
funcsigs==1.0.2
|
||||
future==0.18.2
|
||||
google-api-python-client==1.9.3
|
||||
google-auth-httplib2==0.0.3
|
||||
google-auth-oauthlib==0.4.1
|
||||
idna==2.6
|
||||
ipaddress==1.0.16
|
||||
IPy==0.75
|
||||
@@ -61,4 +64,4 @@ websocket-client==0.56.0
|
||||
zope.component==4.4.1
|
||||
zope.event==4.3.0
|
||||
zope.interface==4.5.0
|
||||
validators==0.14.2
|
||||
validators==0.14.2
|
||||
@@ -523,12 +523,6 @@ def topProcessesStatus(request):
|
||||
loadNow = data[2].split(' ')
|
||||
loadNow = [a for a in loadNow if a != '']
|
||||
|
||||
memory = data[3].split(' ')
|
||||
memory = [a for a in memory if a != '']
|
||||
|
||||
swap = data[4].split(' ')
|
||||
swap = [a for a in swap if a != '']
|
||||
|
||||
processes = data[1].split(' ')
|
||||
processes = [a for a in processes if a != '']
|
||||
|
||||
@@ -573,56 +567,55 @@ def topProcessesStatus(request):
|
||||
|
||||
## Memory
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(memory))
|
||||
memoryInf0 = ProcessUtilities.outputExecutioner('free -m').splitlines()
|
||||
|
||||
if memory[3].find('+') > -1:
|
||||
memoryFinal = memory[3].split('+')[0]
|
||||
else:
|
||||
memoryFinal = memory[3]
|
||||
|
||||
data['totalMemory'] = str(int(float(memoryFinal) / 1024)) + 'MB'
|
||||
|
||||
|
||||
##
|
||||
|
||||
if memory[5].find('free') > -1:
|
||||
data['freeMemory'] = str(int(float(memory[4]) / 1024)) + 'MB'
|
||||
else:
|
||||
data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB'
|
||||
|
||||
|
||||
##
|
||||
|
||||
if memory[7].find('used') > -1:
|
||||
data['usedMemory'] = str(int(float(memory[6]) / 1024)) + 'MB'
|
||||
else:
|
||||
data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB'
|
||||
memoryInf0[1] = list(filter(None, memoryInf0[1].split(' ')))
|
||||
memoryInf0[2] = list(filter(None, memoryInf0[2].split(' ')))
|
||||
|
||||
|
||||
try:
|
||||
if memory[9].find('buff') > -1:
|
||||
data['buffCache'] = str(int(float(memory[8]) / 1024)) + 'MB'
|
||||
else:
|
||||
data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB'
|
||||
data['totalMemory'] = '%sMB' % (memoryInf0[1][1])
|
||||
except:
|
||||
logging.CyberCPLogFileWriter.writeToFile(memory[8])
|
||||
data['buffCache'] = str(int(float(memory[8].split('+')[0]) / 1024)) + 'MB'
|
||||
data['totalMemory'] = '%sMB' % ('0')
|
||||
try:
|
||||
data['usedMemory'] = '%sMB' % (memoryInf0[1][2])
|
||||
except:
|
||||
data['usedMemory'] = '%sMB' % ('0')
|
||||
|
||||
try:
|
||||
data['freeMemory'] = '%sMB' % (memoryInf0[1][3])
|
||||
except:
|
||||
data['freeMemory'] = '%sMB' % ('0')
|
||||
|
||||
try:
|
||||
data['buffCache'] = '%sMB' % (memoryInf0[1][5])
|
||||
except:
|
||||
data['buffCache'] = '%sMB' % ('0')
|
||||
|
||||
|
||||
|
||||
## Swap
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(swap))
|
||||
try:
|
||||
data['swapTotalMemory'] = '%sMB' % (memoryInf0[2][1])
|
||||
except:
|
||||
data['swapTotalMemory'] = '%sMB' % ('0')
|
||||
|
||||
try:
|
||||
data['swapUsedMemory'] = '%sMB' % (memoryInf0[2][2])
|
||||
except:
|
||||
data['swapUsedMemory'] = '%sMB' % ('0')
|
||||
|
||||
data['swapTotalMemory'] = str(int(float(swap[2]) / 1024)) + 'MB'
|
||||
data['swapFreeMemory'] = str(int(float(swap[4]) / 1024)) + 'MB'
|
||||
data['swapUsedMemory'] = str(int(float(swap[6]) / 1024)) + 'MB'
|
||||
try:
|
||||
data['swapFreeMemory'] = '%sMB' % (memoryInf0[2][3])
|
||||
except:
|
||||
data['swapFreeMemory'] = '%sMB' % ('0')
|
||||
|
||||
try:
|
||||
data['swapBuffCache'] = '%sMB' % (memoryInf0[2][5])
|
||||
except:
|
||||
data['swapBuffCache'] = '%sMB' % ('0')
|
||||
|
||||
if swap[8].find('+') > -1:
|
||||
finalBuffCache = swap[8].split('+')[0]
|
||||
data['swapBuffCache'] = str(int(float(finalBuffCache) / 1024)) + 'MB'
|
||||
else:
|
||||
data['swapBuffCache'] = str(int(float(swap[8]) / 1024)) + 'MB'
|
||||
|
||||
## Processes
|
||||
|
||||
|
||||
@@ -489,7 +489,6 @@ app.controller('listCloudLinuxPackages', function ($scope, $http) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
app.controller('websiteContainerLimitCL', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
|
||||
|
||||
@@ -1534,6 +1534,7 @@ app.controller('remoteBackupControl', function ($scope, $http, $timeout) {
|
||||
///** Backup site ends **///
|
||||
|
||||
//*** Remote Backup site ****//
|
||||
|
||||
app.controller('backupLogsScheduled', function ($scope, $http, $timeout) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
@@ -1595,3 +1596,318 @@ app.controller('backupLogsScheduled', function ($scope, $http, $timeout) {
|
||||
});
|
||||
|
||||
///** Backup site ends **///
|
||||
|
||||
app.controller('googleDrive', function ($scope, $http) {
|
||||
|
||||
$scope.cyberPanelLoading = true;
|
||||
$scope.driveHidden = true;
|
||||
|
||||
$scope.setupAccount = function(){
|
||||
window.open("https://platform.cyberpanel.net/gDrive?name=" + $scope.accountName + '&server=' + window.location.href + 'Setup');
|
||||
};
|
||||
|
||||
$scope.currentPage = 1;
|
||||
$scope.recordsToShow = 10;
|
||||
|
||||
$scope.fetchWebsites = function () {
|
||||
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
selectedAccount: $scope.selectedAccount,
|
||||
page: $scope.currentPage,
|
||||
recordsToShow: $scope.recordsToShow
|
||||
};
|
||||
|
||||
|
||||
dataurl = "/backup/fetchgDriveSites";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.driveHidden = false;
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Successfully fetched.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.websites = JSON.parse(response.data.websites);
|
||||
$scope.pagination = response.data.pagination;
|
||||
$scope.currently = response.data.currently;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.addSite = function () {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
var data = {
|
||||
selectedWebsite: $scope.selectedWebsite,
|
||||
selectedAccount: $scope.selectedAccount
|
||||
};
|
||||
|
||||
dataurl = "/backup/addSitegDrive";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Site successfully added.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.fetchWebsites();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.deleteAccount = function () {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
var data = {
|
||||
selectedAccount: $scope.selectedAccount
|
||||
};
|
||||
|
||||
dataurl = "/backup/deleteAccountgDrive";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Account successfully deleted.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.changeFrequency = function () {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
var data = {
|
||||
selectedAccount: $scope.selectedAccount,
|
||||
backupFrequency: $scope.backupFrequency
|
||||
};
|
||||
|
||||
dataurl = "/backup/changeAccountFrequencygDrive";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Changes successfully applied',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.fetchWebsites();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.deleteSite = function (website) {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
var data = {
|
||||
selectedAccount: $scope.selectedAccount,
|
||||
website: website
|
||||
};
|
||||
|
||||
dataurl = "/backup/deleteSitegDrive";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Website Deleted.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.fetchWebsites();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.currentPageLogs = 1;
|
||||
$scope.recordsToShowLogs = 10;
|
||||
|
||||
$scope.fetchLogs = function () {
|
||||
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
var data = {
|
||||
selectedAccount: $scope.selectedAccount,
|
||||
page: $scope.currentPageLogs,
|
||||
recordsToShow: $scope.recordsToShowLogs
|
||||
};
|
||||
|
||||
|
||||
dataurl = "/backup/fetchDriveLogs";
|
||||
|
||||
$http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.driveHidden = false;
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Successfully fetched.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.logs = JSON.parse(response.data.logs);
|
||||
$scope.paginationLogs = response.data.pagination;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
@@ -454,6 +454,113 @@ app.controller('listDBs', function ($scope, $http) {
|
||||
$scope.generatedPasswordView = true;
|
||||
};
|
||||
|
||||
$scope.remoteAccess = function (userName) {
|
||||
|
||||
$scope.dbUsername = userName;
|
||||
$scope.dbLoading = false;
|
||||
|
||||
|
||||
url = "/dataBases/remoteAccess";
|
||||
|
||||
var data = {
|
||||
dbUserName: $scope.dbUsername
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.dbLoading = true;
|
||||
|
||||
if (response.data.status === 1) {
|
||||
|
||||
$scope.dbHost = response.data.dbHost;
|
||||
|
||||
}
|
||||
else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
$scope.dbLoading = true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.allowRemoteIP = function () {
|
||||
|
||||
$scope.dbLoading = false;
|
||||
|
||||
url = "/dataBases/allowRemoteIP";
|
||||
|
||||
var data = {
|
||||
dbUserName: $scope.dbUsername,
|
||||
remoteIP: $scope.remoteIP
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.dbLoading = true;
|
||||
|
||||
if (response.data.status === 1) {
|
||||
|
||||
$scope.remoteAccess($scope.dbUsername);
|
||||
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Changes applied.',
|
||||
type: 'success'
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
$scope.dbLoading = true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class GDrive(models.Model):
|
||||
|
||||
class GDriveSites(models.Model):
|
||||
owner = models.ForeignKey(GDrive, on_delete=models.CASCADE)
|
||||
domain = models.CharField(max_length=200, unique=True)
|
||||
domain = models.CharField(max_length=200)
|
||||
|
||||
class GDriveJobLogs(models.Model):
|
||||
owner = models.ForeignKey(GDrive, on_delete=models.CASCADE)
|
||||
|
||||
@@ -4208,14 +4208,14 @@ StrictHostKeyChecking no
|
||||
GitLogs(owner=self.web, type='INFO',
|
||||
message='Running: %s' % (command)).save()
|
||||
|
||||
result = ProcessUtilities.outputExecutioner(command, self.web.externalApp)
|
||||
result = ProcessUtilities.outputExecutioner(command, self.web.externalApp, None, self.folder)
|
||||
GitLogs(owner=self.web, type='INFO',
|
||||
message='Result: %s' % (result)).save()
|
||||
else:
|
||||
GitLogs(owner=self.web, type='INFO',
|
||||
message='Running: %s' % (gitConf['commands'])).save()
|
||||
|
||||
result = ProcessUtilities.outputExecutioner(gitConf['commands'], self.web.externalApp)
|
||||
result = ProcessUtilities.outputExecutioner(gitConf['commands'], self.web.externalApp, None, self.folder)
|
||||
GitLogs(owner=self.web, type='INFO',
|
||||
message='Result: %s' % (result)).save()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user