mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-06-02 01:04:04 +02:00
centralized execution ph2
This commit is contained in:
@@ -28,9 +28,6 @@ DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
|
||||
48
api/views.py
48
api/views.py
@@ -12,8 +12,6 @@ from random import randint
|
||||
from websiteFunctions.models import Websites
|
||||
import os
|
||||
from baseTemplate.models import version
|
||||
import subprocess
|
||||
import shlex
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from plogical.website import WebsiteManager
|
||||
from loginSystem.models import ACL
|
||||
@@ -121,6 +119,8 @@ def changeUserPassAPI(request):
|
||||
websiteOwn.password = hashPassword.hash_password(ownerPassword)
|
||||
websiteOwn.save()
|
||||
|
||||
|
||||
|
||||
data_ret = {'changeStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
@@ -380,8 +380,8 @@ def FetchRemoteTransferStatus(request):
|
||||
dir = "/home/backup/transfer-"+str(data['dir'])+"/backup_log"
|
||||
|
||||
try:
|
||||
execPath = "sudo cat "+ dir
|
||||
status = ProcessUtilities.outputExecutioner(execPath)
|
||||
command = "sudo cat "+ dir
|
||||
status = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
admin = Administrator.objects.get(userName=username)
|
||||
if hashPassword.check_password(admin.password, password):
|
||||
@@ -417,14 +417,14 @@ def cancelRemoteTransfer(request):
|
||||
|
||||
path = dir + "/pid"
|
||||
|
||||
execPath = "sudo cat " + path
|
||||
pid = ProcessUtilities.outputExecutioner(execPath)
|
||||
command = "sudo cat " + path
|
||||
pid = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
execPath = "sudo kill -KILL " + pid
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo kill -KILL " + pid
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
execPath = "sudo rm -rf " + dir
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo rm -rf " + dir
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
data = {'cancelStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data)
|
||||
@@ -524,8 +524,8 @@ def putSSHkey(request):
|
||||
|
||||
##
|
||||
|
||||
execPath = "sudo chmod g-w /home/cyberpanel"
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo chmod g-w /home/cyberpanel"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
os.chmod(keyPath,0700)
|
||||
os.chmod(authorized_keys, 0600)
|
||||
@@ -588,6 +588,30 @@ def changeAdminPassword(request):
|
||||
newFWRule = FirewallRules(name="ftp", proto="tcp", port="21")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="smtp", proto="tcp", port="25")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="smtps", proto="tcp", port="587")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="ssmtp", proto="tcp", port="465")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="pop3", proto="tcp", port="110")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="imap", proto="tcp", port="143")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="simap", proto="tcp", port="993")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="dns", proto="udp", port="53")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="dnstcp", proto="tcp", port="53")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="ftptls", proto="tcp", port="40110-40210")
|
||||
newFWRule.save()
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class BackupManager:
|
||||
ext = ".tar.gz"
|
||||
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel ' + path
|
||||
ProcessUtilities.executioner(command)
|
||||
ACLManager.executeCall(command)
|
||||
|
||||
files = os.listdir(path)
|
||||
for filename in files:
|
||||
@@ -169,16 +169,16 @@ class BackupManager:
|
||||
## read file name
|
||||
|
||||
try:
|
||||
execPath = "sudo cat " + backupFileNamePath
|
||||
fileName = ProcessUtilities.outputExecutioner(execPath)
|
||||
command = "sudo cat " + backupFileNamePath
|
||||
fileName = subprocess.check_output(shlex.split(command))
|
||||
except:
|
||||
fileName = "Fetching.."
|
||||
|
||||
## file name read ends
|
||||
|
||||
if os.path.exists(status):
|
||||
execPath = "sudo cat " + status
|
||||
status = ProcessUtilities.outputExecutioner(execPath)
|
||||
command = "sudo cat " + status
|
||||
status = subprocess.check_output(shlex.split(command))
|
||||
|
||||
if status.find("Completed") > -1:
|
||||
|
||||
@@ -202,14 +202,14 @@ class BackupManager:
|
||||
|
||||
### Removing Files
|
||||
|
||||
execPath = 'sudo rm -f ' + status
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = 'sudo rm -f ' + status
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
execPath = 'sudo rm -f ' + backupFileNamePath
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = 'sudo rm -f ' + backupFileNamePath
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
execPath = 'sudo rm -f ' + pid
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = 'sudo rm -f ' + pid
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
final_json = json.dumps(
|
||||
{'backupStatus': 1, 'error_message': "None", "status": status, "abort": 1,
|
||||
@@ -219,14 +219,14 @@ class BackupManager:
|
||||
elif status.find("[5009]") > -1:
|
||||
## removing status file, so that backup can re-run
|
||||
try:
|
||||
execPath = 'sudo rm -f ' + status
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = 'sudo rm -f ' + status
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
execPath = 'sudo rm -f ' + backupFileNamePath
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = 'sudo rm -f ' + backupFileNamePath
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
execPath = 'sudo rm -f ' + pid
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = 'sudo rm -f ' + pid
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
backupObs = Backups.objects.filter(fileName=fileName)
|
||||
for items in backupObs:
|
||||
@@ -261,9 +261,10 @@ class BackupManager:
|
||||
fileName = data['fileName']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
|
||||
|
||||
execPath = execPath + " cancelBackupCreation --backupCancellationDomain " + backupCancellationDomain + " --fileName " + fileName
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
subprocess.call(shlex.split(execPath))
|
||||
|
||||
try:
|
||||
backupOb = Backups.objects.get(fileName=fileName)
|
||||
@@ -287,8 +288,8 @@ class BackupManager:
|
||||
domainName = backup.website.domain
|
||||
|
||||
path = "/home/" + domainName + "/backup/" + backup.fileName + ".tar.gz"
|
||||
execPath = 'sudo rm -f ' + path
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = 'sudo rm -f ' + path
|
||||
ACLManager.executeCall(command)
|
||||
|
||||
backup.delete()
|
||||
|
||||
@@ -340,12 +341,12 @@ class BackupManager:
|
||||
if os.path.exists(path):
|
||||
try:
|
||||
execPath = "sudo cat " + path + "/status"
|
||||
status = ProcessUtilities.outputExecutioner(execPath)
|
||||
status = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if status.find("Done") > -1:
|
||||
|
||||
execPath = "sudo rm -rf " + path
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo rm -rf " + path
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
final_json = json.dumps(
|
||||
{'restoreStatus': 1, 'error_message': "None", "status": status, 'abort': 1,
|
||||
@@ -353,8 +354,8 @@ class BackupManager:
|
||||
return HttpResponse(final_json)
|
||||
elif status.find("[5009]") > -1:
|
||||
## removing temporarily generated files while restoring
|
||||
execPath = "sudo rm -rf " + path
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo rm -rf " + path
|
||||
subprocess.call(shlex.split(command))
|
||||
final_json = json.dumps({'restoreStatus': 1, 'error_message': "None",
|
||||
"status": status, 'abort': 1, 'alreadyRunning': 0,
|
||||
'running': 'Error'})
|
||||
@@ -506,7 +507,7 @@ class BackupManager:
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
|
||||
execPath = execPath + " getConnectionStatus --ipAddress " + ipAddress
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find('1,') > -1:
|
||||
final_dic = {'connStatus': 1, 'error_message': "None"}
|
||||
@@ -648,6 +649,7 @@ class BackupManager:
|
||||
## check if already exists
|
||||
try:
|
||||
schedule = backupSchedules.objects.get(frequency=backupFreq)
|
||||
|
||||
if schedule.dest.destLoc == backupDest:
|
||||
final_json = json.dumps(
|
||||
{'scheduleStatus': 0, 'error_message': "This schedule already exists"})
|
||||
@@ -655,175 +657,68 @@ class BackupManager:
|
||||
else:
|
||||
if backupDest == "Home" and backupFreq == "Daily":
|
||||
cronJob = "0 3 * * 0-6 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py"
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
|
||||
writeToFile = open(path, 'a')
|
||||
writeToFile.writelines(cronJob + "\n")
|
||||
writeToFile.close()
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
|
||||
newSchedule.save()
|
||||
|
||||
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
elif backupDest == "Home" and backupFreq == "Weekly":
|
||||
cronJob = "0 3 * * 3 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py "
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
|
||||
writeToFile = open(path, 'a')
|
||||
writeToFile.writelines(cronJob + "\n")
|
||||
writeToFile.close()
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
|
||||
newSchedule.save()
|
||||
|
||||
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
elif backupDest != "Home" and backupFreq == "Daily":
|
||||
cronJob = "0 3 * * 0-6 root python /usr/local/CyberCP/plogical/backupSchedule.py"
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
|
||||
writeToFile = open(path, 'a')
|
||||
writeToFile.writelines(cronJob + "\n")
|
||||
writeToFile.close()
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
|
||||
newSchedule.save()
|
||||
|
||||
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
elif backupDest != "Home" and backupFreq == "Weekly":
|
||||
cronJob = "0 3 * * 3 root python /usr/local/CyberCP/plogical/backupSchedule.py "
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
command = "cat " + path
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
writeToFile = open(path, 'a')
|
||||
writeToFile.writelines(cronJob + "\n")
|
||||
writeToFile.close()
|
||||
finalCronJob = output + cronJob
|
||||
tempCronPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
writeToFile = open(tempCronPath, 'a')
|
||||
writeToFile.writelines(finalCronJob + "\n")
|
||||
writeToFile.close()
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo mv " + tempCronPath + " " + path
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
|
||||
newSchedule.save()
|
||||
command = "sudo systemctl restart crond"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
|
||||
newSchedule.save()
|
||||
|
||||
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
except:
|
||||
if backupDest == "Home" and backupFreq == "Daily":
|
||||
cronJob = "0 3 * * 0-6 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py"
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
|
||||
writeToFile = open(path, 'a')
|
||||
writeToFile.writelines(cronJob + "\n")
|
||||
writeToFile.close()
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
|
||||
newSchedule.save()
|
||||
|
||||
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
elif backupDest == "Home" and backupFreq == "Weekly":
|
||||
cronJob = "0 3 * * 3 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py "
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
|
||||
writeToFile = open(path, 'a')
|
||||
writeToFile.writelines(cronJob + "\n")
|
||||
writeToFile.close()
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
|
||||
newSchedule.save()
|
||||
|
||||
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
cronJob = "0 3 * * 3 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py"
|
||||
elif backupDest != "Home" and backupFreq == "Daily":
|
||||
cronJob = "0 3 * * 0-6 root python /usr/local/CyberCP/plogical/backupSchedule.py"
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
|
||||
writeToFile = open(path, 'a')
|
||||
writeToFile.writelines(cronJob + "\n")
|
||||
writeToFile.close()
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
|
||||
newSchedule.save()
|
||||
|
||||
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
elif backupDest != "Home" and backupFreq == "Weekly":
|
||||
cronJob = "0 3 * * 3 root python /usr/local/CyberCP/plogical/backupSchedule.py "
|
||||
cronJob = "0 3 * * 3 root python /usr/local/CyberCP/plogical/backupSchedule.py"
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
command = "cat " + path
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
writeToFile = open(path, 'a')
|
||||
writeToFile.writelines(cronJob + "\n")
|
||||
writeToFile.close()
|
||||
finalCronJob = output + cronJob
|
||||
tempCronPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
writeToFile = open(tempCronPath, 'a')
|
||||
writeToFile.writelines(finalCronJob + "\n")
|
||||
writeToFile.close()
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
command = "sudo mv " + tempCronPath + " " + path
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo systemctl restart crond"
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
|
||||
newSchedule.save()
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
|
||||
newSchedule.save()
|
||||
|
||||
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException, msg:
|
||||
final_json = json.dumps({'scheduleStatus': 0, 'error_message': str(msg)})
|
||||
@@ -838,120 +733,48 @@ class BackupManager:
|
||||
|
||||
backupDest = data['destLoc']
|
||||
backupFreq = data['frequency']
|
||||
findTxt = ""
|
||||
|
||||
if backupDest == "Home" and backupFreq == "Daily":
|
||||
findTxt = "0-6"
|
||||
elif backupDest == "Home" and backupFreq == "Weekly":
|
||||
findTxt = "* 3"
|
||||
elif backupDest != "Home" and backupFreq == "Daily":
|
||||
findTxt = "0-6"
|
||||
elif backupDest != "Home" and backupFreq == "Weekly":
|
||||
findTxt = "* 3"
|
||||
|
||||
###
|
||||
|
||||
path = "/etc/crontab"
|
||||
|
||||
if backupDest == "Home" and backupFreq == "Daily":
|
||||
command = "cat " + path
|
||||
output = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
tempCronPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
writeToFile = open(tempCronPath, 'w')
|
||||
|
||||
data = open(path, "r").readlines()
|
||||
writeToFile = open(path, 'w')
|
||||
for items in output:
|
||||
if items.find(findTxt) > -1 and items.find("backupScheduleLocal.py") > -1:
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items + '\n')
|
||||
|
||||
for items in data:
|
||||
if items.find("0-6") > -1 and items.find("backupScheduleLocal.py") > -1:
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
writeToFile.close()
|
||||
|
||||
writeToFile.close()
|
||||
command = "sudo mv " + tempCronPath + " " + path
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
command = "sudo systemctl restart crond"
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules.objects.get(dest=destination, frequency=backupFreq)
|
||||
newSchedule.delete()
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules.objects.get(dest=destination, frequency=backupFreq)
|
||||
newSchedule.delete()
|
||||
|
||||
final_json = json.dumps({'delStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
elif backupDest == "Home" and backupFreq == "Weekly":
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
|
||||
data = open(path, "r").readlines()
|
||||
writeToFile = open(path, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find("* 3") > -1 and items.find("backupScheduleLocal.py") > -1:
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules.objects.get(dest=destination, frequency=backupFreq)
|
||||
newSchedule.delete()
|
||||
|
||||
final_json = json.dumps({'delStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
elif backupDest != "Home" and backupFreq == "Daily":
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
|
||||
data = open(path, "r").readlines()
|
||||
writeToFile = open(path, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find("0-6") > -1 and items.find("backupSchedule.py") > -1:
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules.objects.get(dest=destination, frequency=backupFreq)
|
||||
newSchedule.delete()
|
||||
|
||||
final_json = json.dumps({'delStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
elif backupDest != "Home" and backupFreq == "Weekly":
|
||||
|
||||
virtualHostUtilities.permissionControl(path)
|
||||
|
||||
data = open(path, "r").readlines()
|
||||
writeToFile = open(path, 'w')
|
||||
|
||||
for items in data:
|
||||
if items.find("* 3") > -1 and items.find("backupSchedule.py") > -1:
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
virtualHostUtilities.leaveControl(path)
|
||||
|
||||
execPath = "sudo systemctl restart crond"
|
||||
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
destination = dest.objects.get(destLoc=backupDest)
|
||||
newSchedule = backupSchedules.objects.get(dest=destination, frequency=backupFreq)
|
||||
newSchedule.delete()
|
||||
|
||||
final_json = json.dumps({'delStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
final_json = json.dumps({'delStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException, msg:
|
||||
final_json = json.dumps({'delStatus': 0, 'error_message': str(msg)})
|
||||
@@ -1125,8 +948,8 @@ class BackupManager:
|
||||
localBackupDir = os.path.join("/home", "backup")
|
||||
|
||||
if not os.path.exists(localBackupDir):
|
||||
execPath = "sudo mkdir " + localBackupDir
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo mkdir " + localBackupDir
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
## create local directory that will host backups
|
||||
|
||||
@@ -1134,8 +957,8 @@ class BackupManager:
|
||||
|
||||
## making local storage directory for backups
|
||||
|
||||
execPath = "sudo mkdir " + localStoragePath
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo mkdir " + localStoragePath
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
final_json = json.dumps(
|
||||
{'remoteTransferStatus': 1, 'error_message': "None", "dir": data['dir']})
|
||||
@@ -1249,18 +1072,18 @@ class BackupManager:
|
||||
time.sleep(3)
|
||||
|
||||
if os.path.isfile(backupLogPath):
|
||||
execPath = "sudo cat " + backupLogPath
|
||||
status = ProcessUtilities.outputExecutioner(execPath)
|
||||
command = "sudo cat " + backupLogPath
|
||||
status = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if status.find("completed[success]") > -1:
|
||||
command = "sudo rm -rf " + removalPath
|
||||
# ProcessUtilities.executioner(shlex.split(command))
|
||||
# subprocess.call(shlex.split(command))
|
||||
data_ret = {'remoteTransferStatus': 1, 'error_message': "None", "status": status, "complete": 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
elif status.find("[5010]") > -1:
|
||||
command = "sudo rm -rf " + removalPath
|
||||
# ProcessUtilities.executioner(shlex.split(command))
|
||||
# subprocess.call(shlex.split(command))
|
||||
data = {'remoteTransferStatus': 0, 'error_message': status,
|
||||
"status": "None", "complete": 0}
|
||||
json_data = json.dumps(data)
|
||||
@@ -1307,14 +1130,14 @@ class BackupManager:
|
||||
path = "/home/backup/transfer-" + str(dir)
|
||||
pathpid = path + "/pid"
|
||||
|
||||
execPath = "sudo cat " + pathpid
|
||||
pid = ProcessUtilities.outputExecutioner(execPath)
|
||||
command = "sudo cat " + pathpid
|
||||
pid = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
execPath = "sudo kill -KILL " + pid
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo kill -KILL " + pid
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
execPath = "sudo rm -rf " + path
|
||||
ProcessUtilities.executioner(execPath)
|
||||
command = "sudo rm -rf " + path
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
data = {'cancelStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data)
|
||||
|
||||
@@ -15,7 +15,6 @@ import shlex
|
||||
import os
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
# Create your views here.
|
||||
|
||||
|
||||
@@ -111,7 +110,7 @@ def upgrade(request):
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
vers = version.objects.get(pk=1)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import subprocess
|
||||
import time
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
class cliLogger:
|
||||
fileName = "/home/cyberpanel/error-logs.txt"
|
||||
|
||||
@@ -20,7 +20,7 @@ class cliLogger:
|
||||
def readLastNFiles(numberOfLines,fileName):
|
||||
try:
|
||||
|
||||
lastFewLines = ProcessUtilities.outputExecutioner(["tail", "-n",str(numberOfLines),fileName])
|
||||
lastFewLines = subprocess.check_output(["tail", "-n",str(numberOfLines),fileName])
|
||||
|
||||
return lastFewLines
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import json
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
from random import randint
|
||||
|
||||
from django.shortcuts import HttpResponse
|
||||
@@ -319,8 +317,8 @@ class CloudManager:
|
||||
lastLine = statusData[-1]
|
||||
|
||||
if lastLine.find('[200]') > -1:
|
||||
execPath = 'sudo rm -f ' + statusFile
|
||||
ProcessUtilities.outputExecutioner(execPath)
|
||||
command = 'sudo rm -f ' + statusFile
|
||||
ProcessUtilities.executioner(command)
|
||||
data_ret = {'status': 1, 'abort': 1, 'installationProgress': "100", 'currentStatus': lastLine}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
@@ -1053,11 +1051,9 @@ class CloudManager:
|
||||
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
execPath = 'sudo cat /etc/my.cnf'
|
||||
finalData['conf'] = ProcessUtilities.outputExecutioner(execPath)
|
||||
finalData['conf'] = ProcessUtilities.outputExecutioner('sudo cat /etc/my.cnf')
|
||||
else:
|
||||
execPath = 'sudo cat /etc/mysql/my.cnf'
|
||||
finalData['conf'] = ProcessUtilities.outputExecutioner(execPath)
|
||||
finalData['conf'] = ProcessUtilities.outputExecutioner('sudo cat /etc/mysql/my.cnf')
|
||||
|
||||
finalData['status'] = 1
|
||||
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
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()
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
import argparse
|
||||
import subprocess
|
||||
import shlex
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from xml.etree import ElementTree
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
|
||||
|
||||
class Container:
|
||||
packages = ['talksho']
|
||||
@@ -71,11 +65,38 @@ class Container:
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
|
||||
@staticmethod
|
||||
def submitContainerInstall():
|
||||
try:
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Starting Packages Installation..\n", 1)
|
||||
|
||||
command = 'sudo yum install -y libcgroup-tools'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo systemctl enable cgconfig'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo systemctl enable cgred'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Packages successfully installed.[200]\n", 1)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Container Manager')
|
||||
parser.add_argument('--userid', help='User ID')
|
||||
parser.add_argument('--package', help='Package')
|
||||
parser.add_argument('--function', help='Function')
|
||||
parser.add_argument('--list-all', help='List all users/packages.', action='store_true')
|
||||
parser.add_argument('--list-packages', help='List all packages.', action='store_true')
|
||||
|
||||
@@ -90,6 +111,11 @@ def main():
|
||||
Container.listAll()
|
||||
elif args['list_packages']:
|
||||
Container.listPackages()
|
||||
elif args['list_packages']:
|
||||
Container.listPackages()
|
||||
elif args["function"] == "submitContainerInstall":
|
||||
Container.submitContainerInstall()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ from django.shortcuts import render
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
import threading as multi
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
import os, stat
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
|
||||
|
||||
class ContainerManager(multi.Thread):
|
||||
@@ -125,24 +125,9 @@ class ContainerManager(multi.Thread):
|
||||
1)
|
||||
return 0
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Starting Packages Installation..\n", 1)
|
||||
|
||||
command = 'sudo yum install -y libcgroup-tools'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo systemctl enable cgconfig'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo systemctl enable cgred'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Packages successfully installed.[200]\n", 1)
|
||||
execPath = "sudo python /usr/local/CyberCP/containerization/container.py"
|
||||
execPath = execPath + " --function submitContainerInstall"
|
||||
ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
@@ -162,7 +162,7 @@ def saveWebsiteLimits(request):
|
||||
cgrules = '/etc/cgrules.conf'
|
||||
enforceString = '{} cpu,memory,blkio,net_cls {}/\n'.format(website.externalApp, website.externalApp)
|
||||
|
||||
cgrulesData = ProcessUtilities.outputExecutioner(shlex.split('sudo cat /etc/cgrules.conf')).splitlines()
|
||||
cgrulesData = ProcessUtilities.outputExecutioner('sudo cat /etc/cgrules.conf').splitlines()
|
||||
|
||||
writeToFile = open(cgrulesTemp, 'w')
|
||||
|
||||
@@ -219,7 +219,7 @@ def saveWebsiteLimits(request):
|
||||
cgrulesTemp = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
cgrules = '/etc/cgrules.conf'
|
||||
|
||||
cgrulesData = ProcessUtilities.outputExecutioner(shlex.split('sudo cat /etc/cgrules.conf')).splitlines()
|
||||
cgrulesData = ProcessUtilities.outputExecutioner('sudo cat /etc/cgrules.conf').splitlines()
|
||||
|
||||
writeToFile = open(cgrulesTemp, 'w')
|
||||
|
||||
@@ -293,7 +293,7 @@ def getUsageData(request):
|
||||
if type == 'memory':
|
||||
|
||||
command = 'sudo cat /sys/fs/cgroup/memory/' + website.externalApp + '/memory.usage_in_bytes'
|
||||
output = str(ProcessUtilities.outputExecutioner(command, shell=True))
|
||||
output = str(ProcessUtilities.outputExecutioner(command))
|
||||
finalData['memory'] = int(float(output)/float(1024 * 1024))
|
||||
|
||||
elif type == 'io':
|
||||
@@ -305,7 +305,7 @@ def getUsageData(request):
|
||||
os.mkdir(path)
|
||||
|
||||
command = 'sudo cat /sys/fs/cgroup/blkio/' + website.externalApp + '/blkio.throttle.io_service_bytes'
|
||||
output = ProcessUtilities.outputExecutioner(command, shell=True).splitlines()
|
||||
output = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
readCurrent = output[0].split(' ')[2]
|
||||
writeCurrent = output[1].split(' ')[2]
|
||||
@@ -332,8 +332,8 @@ def getUsageData(request):
|
||||
finalData['readRate'] = 0
|
||||
finalData['writeRate'] = 0
|
||||
except:
|
||||
command = "sudo top -b -n 1 -u " + website.externalApp + " | awk 'NR>7 { sum += $9; } END { print sum; }'"
|
||||
output = str(ProcessUtilities.outputExecutioner(command, shell=True))
|
||||
command = "top -b -n 1 -u " + website.externalApp + " | awk 'NR>7 { sum += $9; } END { print sum; }'"
|
||||
output = str(subprocess.check_output(command, shell=True))
|
||||
|
||||
finalData = {}
|
||||
if len(output) == 0:
|
||||
|
||||
@@ -9,12 +9,13 @@ from django.shortcuts import render, redirect
|
||||
from django.http import HttpResponse
|
||||
import json
|
||||
from plogical.acl import ACLManager
|
||||
import subprocess, shlex
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.mysqlUtilities import mysqlUtilities
|
||||
from websiteFunctions.models import Websites
|
||||
from databases.models import Databases
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
import argparse
|
||||
from loginSystem.models import Administrator
|
||||
import plogical.randomPassword as randomPassword
|
||||
|
||||
class DatabaseManager:
|
||||
|
||||
@@ -24,6 +25,12 @@ class DatabaseManager:
|
||||
except BaseException, msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def phpMyAdmin(self, request = None, userID = None):
|
||||
try:
|
||||
return render(request, 'databases/phpMyAdmin.html')
|
||||
except BaseException, msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def createDatabase(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -165,19 +172,10 @@ class DatabaseManager:
|
||||
userName = data['dbUserName']
|
||||
dbPassword = data['dbPassword']
|
||||
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
f = open(passFile)
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
res = mysqlUtilities.changePassword(userName, dbPassword)
|
||||
|
||||
passwordCMD = "use mysql;SET PASSWORD FOR '" + userName + "'@'localhost' = PASSWORD('" + dbPassword + "');FLUSH PRIVILEGES;"
|
||||
|
||||
command = 'sudo mysql -u root -p' + password + ' -e "' + passwordCMD + '"'
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
if res == 1:
|
||||
if res == 0:
|
||||
data_ret = {'status': 0, 'changePasswordStatus': 0,'error_message': "Please see CyberPanel main log file."}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
@@ -189,4 +187,49 @@ class DatabaseManager:
|
||||
except BaseException, msg:
|
||||
data_ret = {'status': 0, 'changePasswordStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@staticmethod
|
||||
def generatePHPMYAdminData(userID):
|
||||
try:
|
||||
|
||||
admin = Administrator.objects.get(id=userID)
|
||||
path = '/etc/cyberpanel/' + admin.userName
|
||||
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
websiteOBJs = ACLManager.findWebsiteObjects(currentACL, userID)
|
||||
finalUserPassword = randomPassword.generate_pass()
|
||||
|
||||
writeToFile = open(path, 'w')
|
||||
writeToFile.write(finalUserPassword)
|
||||
writeToFile.close()
|
||||
|
||||
mysqlUtilities.createDBUser(admin.userName, finalUserPassword)
|
||||
mysqlUtilities.changePassword(admin.userName, finalUserPassword)
|
||||
|
||||
for webs in websiteOBJs:
|
||||
for db in webs.databases_set.all():
|
||||
mysqlUtilities.allowGlobalUserAccess(admin.userName, db.dbName)
|
||||
|
||||
print "1," + finalUserPassword
|
||||
|
||||
except BaseException, msg:
|
||||
print "0," + str(msg)
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||
parser.add_argument('function', help='Specific a function to call!')
|
||||
|
||||
parser.add_argument('--userID', help='Logged in user ID')
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.function == "generatePHPMYAdminData":
|
||||
DatabaseManager.generatePHPMYAdminData(int(args.userID))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
/* Java script code to create database */
|
||||
app.controller('createDatabase', function($scope,$http) {
|
||||
app.controller('createDatabase', function ($scope, $http) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = true;
|
||||
@@ -14,103 +14,99 @@ app.controller('createDatabase', function($scope,$http) {
|
||||
$scope.generatedPasswordView = true;
|
||||
|
||||
|
||||
$scope.showDetailsBoxes = function(){
|
||||
$scope.showDetailsBoxes = function () {
|
||||
$scope.dbDetails = false;
|
||||
};
|
||||
|
||||
$scope.createDatabase = function(){
|
||||
$scope.createDatabase = function () {
|
||||
|
||||
$scope.createDatabaseLoading = false;
|
||||
$scope.createDatabaseLoading = false;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
var dbName = $scope.dbName;
|
||||
var dbUsername = $scope.dbUsername;
|
||||
var dbPassword = $scope.dbPassword;
|
||||
var webUserName = "";
|
||||
|
||||
// getting website username
|
||||
|
||||
webUserName = databaseWebsite.replace(/-/g, '');
|
||||
webUserName = webUserName.split(".")[0];
|
||||
|
||||
if (webUserName.length > 5) {
|
||||
webUserName = webUserName.substring(0, 4);
|
||||
}
|
||||
|
||||
var url = "/dataBases/submitDBCreation";
|
||||
|
||||
|
||||
var data = {
|
||||
webUserName: webUserName,
|
||||
databaseWebsite: databaseWebsite,
|
||||
dbName: dbName,
|
||||
dbUsername: dbUsername,
|
||||
dbPassword: dbPassword
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.createDBStatus == 1) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.databaseCreated = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
var dbName = $scope.dbName;
|
||||
var dbUsername = $scope.dbUsername;
|
||||
var dbPassword = $scope.dbPassword;
|
||||
var webUserName = "";
|
||||
}
|
||||
|
||||
// getting website username
|
||||
|
||||
webUserName = databaseWebsite.replace(/-/g, '');
|
||||
webUserName = webUserName.split(".")[0];
|
||||
|
||||
if(webUserName.length > 5){
|
||||
webUserName = webUserName.substring(0,4);
|
||||
}
|
||||
|
||||
var url = "/dataBases/submitDBCreation";
|
||||
else {
|
||||
|
||||
|
||||
var data = {
|
||||
webUserName:webUserName,
|
||||
databaseWebsite:databaseWebsite,
|
||||
dbName:dbName,
|
||||
dbUsername:dbUsername,
|
||||
dbPassword:dbPassword
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = false;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
}
|
||||
|
||||
|
||||
if(response.data.createDBStatus == 1){
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = false;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = true;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = true;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -122,7 +118,7 @@ app.controller('createDatabase', function($scope,$http) {
|
||||
|
||||
/* Java script code to delete database */
|
||||
|
||||
app.controller('deleteDatabase', function($scope,$http) {
|
||||
app.controller('deleteDatabase', function ($scope, $http) {
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
@@ -131,153 +127,147 @@ app.controller('deleteDatabase', function($scope,$http) {
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
$scope.fetchDatabases = function(){
|
||||
$scope.fetchDatabases = function () {
|
||||
|
||||
$scope.deleteDatabaseLoading = false;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.deleteDatabaseLoading = false;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
|
||||
var url = "/dataBases/fetchDatabases";
|
||||
|
||||
|
||||
var data = {
|
||||
databaseWebsite: databaseWebsite,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.fetchStatus == 1) {
|
||||
|
||||
|
||||
$scope.dbnames = JSON.parse(response.data.data);
|
||||
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = false;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
}
|
||||
|
||||
var url = "/dataBases/fetchDatabases";
|
||||
else {
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var data = {
|
||||
databaseWebsite:databaseWebsite,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
}
|
||||
|
||||
|
||||
if(response.data.fetchStatus == 1){
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
$scope.dbnames = JSON.parse(response.data.data);
|
||||
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = false;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.deleteDatabase = function(){
|
||||
$scope.deleteDatabase = function () {
|
||||
|
||||
$scope.deleteDatabaseLoading = false;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.deleteDatabaseLoading = false;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
|
||||
var url = "/dataBases/submitDatabaseDeletion";
|
||||
|
||||
|
||||
var data = {
|
||||
dbName: $scope.selectedDB,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.deleteStatus == 1) {
|
||||
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = false;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
|
||||
var url = "/dataBases/submitDatabaseDeletion";
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
var data = {
|
||||
dbName:$scope.selectedDB,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
}
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
if(response.data.deleteStatus == 1){
|
||||
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = false;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -289,7 +279,7 @@ app.controller('deleteDatabase', function($scope,$http) {
|
||||
/* Java script code to list databases */
|
||||
|
||||
|
||||
app.controller('listDBs', function($scope,$http) {
|
||||
app.controller('listDBs', function ($scope, $http) {
|
||||
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
@@ -303,161 +293,161 @@ app.controller('listDBs', function($scope,$http) {
|
||||
var globalDBUsername = "";
|
||||
|
||||
$scope.fetchDBs = function () {
|
||||
populateCurrentRecords();
|
||||
populateCurrentRecords();
|
||||
};
|
||||
|
||||
$scope.changePassword = function (dbUsername) {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = false;
|
||||
$scope.changePasswordBox = false;
|
||||
$scope.notificationsBox = true;
|
||||
$scope.dbUsername = dbUsername;
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = false;
|
||||
$scope.changePasswordBox = false;
|
||||
$scope.notificationsBox = true;
|
||||
$scope.dbUsername = dbUsername;
|
||||
|
||||
|
||||
globalDBUsername = dbUsername;
|
||||
globalDBUsername = dbUsername;
|
||||
|
||||
};
|
||||
|
||||
$scope.changePasswordBtn = function () {
|
||||
|
||||
$scope.dbLoading = false;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.dbLoading = false;
|
||||
$scope.passwordChanged = true;
|
||||
|
||||
|
||||
url = "/dataBases/changePassword";
|
||||
url = "/dataBases/changePassword";
|
||||
|
||||
var data = {
|
||||
dbUserName:globalDBUsername,
|
||||
dbPassword: $scope.dbPassword,
|
||||
};
|
||||
var data = {
|
||||
dbUserName: globalDBUsername,
|
||||
dbPassword: $scope.dbPassword,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.changePasswordStatus == 1){
|
||||
$scope.notificationsBox = false;
|
||||
$scope.passwordChanged = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
if (response.data.changePasswordStatus == 1) {
|
||||
$scope.notificationsBox = false;
|
||||
$scope.passwordChanged = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
|
||||
}
|
||||
else{
|
||||
$scope.notificationsBox = false;
|
||||
$scope.canNotChangePassword = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.canNotChangePassword = false;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$scope.notificationsBox = false;
|
||||
$scope.canNotChangePassword = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.canNotChangePassword = false;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.notificationsBox = false;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.dbLoading = true;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.notificationsBox = false;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.dbLoading = true;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
function populateCurrentRecords(){
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = false;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
};
|
||||
|
||||
var selectedDomain = $scope.selectedDomain;
|
||||
function populateCurrentRecords() {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = false;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
|
||||
url = "/dataBases/fetchDatabases";
|
||||
var selectedDomain = $scope.selectedDomain;
|
||||
|
||||
var data = {
|
||||
databaseWebsite:selectedDomain,
|
||||
};
|
||||
url = "/dataBases/fetchDatabases";
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
var data = {
|
||||
databaseWebsite: selectedDomain,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.fetchStatus == 1){
|
||||
if (response.data.fetchStatus == 1) {
|
||||
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
|
||||
|
||||
$scope.recordsFetched = false;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = false;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = false;
|
||||
$scope.recordsFetched = false;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = false;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = false;
|
||||
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
|
||||
}
|
||||
else{
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
}
|
||||
else {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
}
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
$scope.generatedPasswordView = true;
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -467,4 +457,40 @@ app.controller('listDBs', function($scope,$http) {
|
||||
});
|
||||
|
||||
|
||||
/* Java script code to list database ends here */
|
||||
/* Java script code to list database ends here */
|
||||
|
||||
|
||||
app.controller('phpMyAdmin', function ($scope, $http, $window) {
|
||||
|
||||
function setupPHPMYAdminSession() {
|
||||
|
||||
url = "/dataBases/setupPHPMYAdminSession";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.status === 1) {
|
||||
$window.location.href = '/phpmyadmin';
|
||||
}
|
||||
else {}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {}
|
||||
|
||||
}
|
||||
setupPHPMYAdminSession();
|
||||
|
||||
});
|
||||
73
databases/templates/databases/phpMyAdmin.html
Normal file
73
databases/templates/databases/phpMyAdmin.html
Normal file
@@ -0,0 +1,73 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "phpMyAdmin - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Create Database" %}</h2>
|
||||
<p>{% trans "Create a new database on this page." %}</p>
|
||||
</div>
|
||||
|
||||
<div ng-controller="phpMyAdmin" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Create Database" %} <img ng-hide="createDatabaseLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<form class="form-horizontal bordered-row panel-body">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Website" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="showDetailsBoxes()" ng-model="databaseWebsite" class="form-control">
|
||||
{% for items in websitesList %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<div ng-hide="databaseCreationFailed" class="alert alert-danger">
|
||||
<p>{% trans "Cannot create database. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="databaseCreated" class="alert alert-success">
|
||||
<p>{% trans "Database created successfully." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -14,4 +14,6 @@ urlpatterns = [
|
||||
url(r'^listDBs', views.listDBs, name='listDBs'),
|
||||
|
||||
url(r'^changePassword', views.changePassword, name='changePassword'),
|
||||
url(r'^phpMyAdmin$', views.phpMyAdmin, name='phpMyAdmin'),
|
||||
url(r'^setupPHPMYAdminSession$', views.setupPHPMYAdminSession, name='setupPHPMYAdminSession'),
|
||||
]
|
||||
@@ -1,11 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import redirect, HttpResponse
|
||||
from loginSystem.views import loadLoginPage
|
||||
from databaseManager import DatabaseManager
|
||||
from pluginManager import pluginManager
|
||||
import json
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from loginSystem.models import Administrator
|
||||
import CyberCP.settings as settings
|
||||
# Create your views here.
|
||||
|
||||
def loadDatabaseHome(request):
|
||||
@@ -116,3 +119,39 @@ def changePassword(request):
|
||||
return coreResult
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def phpMyAdmin(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
dm = DatabaseManager()
|
||||
return dm.phpMyAdmin(request, userID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def setupPHPMYAdminSession(request):
|
||||
try:
|
||||
|
||||
userID = request.session['userID']
|
||||
admin = Administrator.objects.get(id = userID)
|
||||
|
||||
execPath = "sudo python /usr/local/CyberCP/databases/databaseManager.py"
|
||||
execPath = execPath + " generatePHPMYAdminData --userID " + str(userID)
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,") > -1:
|
||||
request.session['PMA_single_signon_user'] = admin.userName
|
||||
request.session['PMA_single_signon_password'] = output.split(',')[1]
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'status': 0, 'createDBStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@@ -64,7 +64,7 @@ class ContainerManager(multi.Thread):
|
||||
@staticmethod
|
||||
def executioner(command, statusFile):
|
||||
try:
|
||||
res = ProcessUtilities.executioner(shlex.split(command), stdout=statusFile, stderr=statusFile)
|
||||
res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile)
|
||||
if res == 1:
|
||||
return 0
|
||||
else:
|
||||
@@ -80,49 +80,11 @@ class ContainerManager(multi.Thread):
|
||||
if ACLManager.currentContextPermission(currentACL, 'createContainer') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
writeToFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
|
||||
writeToFile.close()
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Starting Docker Installation..\n", 1)
|
||||
|
||||
command = "sudo adduser docker"
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo groupadd docker'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo usermod -aG docker docker'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo usermod -aG docker cyberpanel'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
command = 'sudo yum install -y docker'
|
||||
else:
|
||||
command = 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io'
|
||||
|
||||
if not ServerStatusUtil.executioner(command, statusFile):
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Failed to install Docker. [404]\n", 1)
|
||||
return 0
|
||||
|
||||
command = 'sudo systemctl enable docker'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo systemctl start docker'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Docker successfully installed.[200]\n", 1)
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
cm = ContainerManager(self.name, 'restartGunicorn')
|
||||
cm.start()
|
||||
execPath = "sudo python /usr/local/CyberCP/dockerManager/dockerInstall.py"
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
63
dockerManager/dockerInstall.py
Normal file
63
dockerManager/dockerInstall.py
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
import sys
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
import time
|
||||
|
||||
|
||||
class DockerInstall:
|
||||
|
||||
@staticmethod
|
||||
def submitInstallDocker():
|
||||
try:
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Starting Docker Installation..\n", 1)
|
||||
|
||||
command = "sudo adduser docker"
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo groupadd docker'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo usermod -aG docker docker'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo usermod -aG docker cyberpanel'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
command = 'sudo yum install -y docker'
|
||||
else:
|
||||
command = 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io'
|
||||
|
||||
if not ServerStatusUtil.executioner(command, statusFile):
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Failed to install Docker. [404]\n", 1)
|
||||
return 0
|
||||
|
||||
command = 'sudo systemctl enable docker'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
command = 'sudo systemctl start docker'
|
||||
ServerStatusUtil.executioner(command, statusFile)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
||||
"Docker successfully installed.[200]\n", 1)
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
command = 'sudo systemctl restart gunicorn.socket'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
DockerInstall.submitInstallDocker()
|
||||
@@ -14,7 +14,6 @@ from random import randint
|
||||
import subprocess, shlex
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
|
||||
class emailMarketing(multi.Thread):
|
||||
def __init__(self, function, extraArgs):
|
||||
multi.Thread.__init__(self)
|
||||
@@ -213,7 +212,7 @@ class emailMarketing(multi.Thread):
|
||||
messageFile.close()
|
||||
|
||||
command = "sudo sed -i 's/{{ unsubscribeCheck }}/" + removalLink + "/g' " + tempPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
messageFile = open(tempPath, 'r')
|
||||
finalMessage = messageFile.read()
|
||||
|
||||
@@ -20,7 +20,7 @@ import shlex
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from random import randint
|
||||
from plogical.acl import ACLManager
|
||||
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
# Create your views here.
|
||||
|
||||
@@ -54,7 +54,7 @@ def fetchPolicyServerStatus(request):
|
||||
if request.method == 'POST':
|
||||
|
||||
command = 'sudo cat /etc/postfix/main.cf'
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command)).split('\n')
|
||||
output = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
installCheck = 0
|
||||
|
||||
@@ -104,10 +104,8 @@ def savePolicyServerStatus(request):
|
||||
## save configuration data
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
|
||||
|
||||
execPath = execPath + " savePolicyServerStatus --install " + install
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'status': 1, 'error_message': "None"}
|
||||
@@ -148,7 +146,7 @@ def listDomains(request):
|
||||
## Check if Policy Server is installed.
|
||||
|
||||
command = 'sudo cat /etc/postfix/main.cf'
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command)).split('\n')
|
||||
output = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
installCheck = 0
|
||||
|
||||
@@ -806,15 +804,13 @@ def installStatusSpamAssassin(request):
|
||||
if request.method == 'POST':
|
||||
|
||||
command = "sudo cat " + mailUtilities.spamassassinInstallLogPath
|
||||
installStatus = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
installStatus = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if installStatus.find("[200]")>-1:
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
|
||||
|
||||
execPath = execPath + " configureSpamAssassin"
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
pass
|
||||
@@ -884,7 +880,7 @@ def fetchSpamAssassinSettings(request):
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
|
||||
data = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
data = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
for items in data:
|
||||
if items.find('report_safe ') > -1:
|
||||
@@ -984,10 +980,8 @@ def saveSpamAssassinConfigurations(request):
|
||||
## save configuration data
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
|
||||
|
||||
execPath = execPath + " saveSpamAssassinConfigs --tempConfigPath " + tempConfigPath
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'saveStatus': 1, 'error_message': "None"}
|
||||
|
||||
@@ -40,7 +40,7 @@ class FileManager:
|
||||
return self.ajaxPre(0, 'Not allowed to browse this path, going back home!')
|
||||
|
||||
command = "sudo ls -la --group-directories-first " + self.returnPathEnclosed(self.data['completeStartingPath'])
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
output = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
counter = 0
|
||||
for items in output:
|
||||
@@ -72,7 +72,7 @@ class FileManager:
|
||||
finalData['status'] = 1
|
||||
|
||||
command = "sudo ls -la --group-directories-first " + self.returnPathEnclosed(self.data['completeStartingPath'])
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
output = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
counter = 0
|
||||
for items in output:
|
||||
@@ -225,7 +225,7 @@ class FileManager:
|
||||
|
||||
command = 'sudo cat ' + self.returnPathEnclosed(self.data['fileName'])
|
||||
ProcessUtilities.executioner(command)
|
||||
finalData['fileContents'] = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
finalData['fileContents'] = subprocess.check_output(shlex.split(command))
|
||||
|
||||
json_data = json.dumps(finalData)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@@ -54,10 +54,10 @@ def changePermissions(request):
|
||||
externalApp = website.externalApp
|
||||
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp +" /home/"+domainName
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "sudo chown -R lscpd:lscpd /home/" + domainName+"/logs"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
data_ret = {'permissionsChanged': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from django.contrib import admin
|
||||
|
||||
import models
|
||||
# Register your models here.
|
||||
admin.site.register(models.FirewallRules)
|
||||
@@ -162,10 +162,9 @@ class FirewallManager:
|
||||
return ACLManager.loadErrorJson('reload_status', 0)
|
||||
|
||||
command = 'sudo firewall-cmd --reload'
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = ProcessUtilities.executioner(command)
|
||||
|
||||
if res == 0:
|
||||
if res == 1:
|
||||
final_dic = {'reload_status': 1, 'error_message': "None"}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
@@ -191,12 +190,9 @@ class FirewallManager:
|
||||
return ACLManager.loadErrorJson('start_status', 0)
|
||||
|
||||
command = 'sudo systemctl start firewalld'
|
||||
res = ProcessUtilities.executioner(command)
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
if res == 0:
|
||||
if res == 1:
|
||||
final_dic = {'start_status': 1, 'error_message': "None"}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
@@ -222,10 +218,9 @@ class FirewallManager:
|
||||
return ACLManager.loadErrorJson('stop_status', 0)
|
||||
|
||||
command = 'sudo systemctl stop firewalld'
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = ProcessUtilities.executioner(command)
|
||||
|
||||
if res == 0:
|
||||
if res == 1:
|
||||
final_dic = {'stop_status': 1, 'error_message': "None"}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
@@ -251,8 +246,7 @@ class FirewallManager:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
command = 'sudo systemctl status firewalld'
|
||||
|
||||
status = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
status = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if status.find("active") > -1:
|
||||
final_dic = {'status': 1, 'error_message': "none", 'firewallStatus': 1}
|
||||
@@ -297,15 +291,10 @@ class FirewallManager:
|
||||
|
||||
## temporarily changing permission for sshd files
|
||||
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel /etc/ssh/sshd_config'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
pathToSSH = "/etc/ssh/sshd_config"
|
||||
|
||||
data = open(pathToSSH, 'r').readlines()
|
||||
cat = "sudo cat " + pathToSSH
|
||||
data = ProcessUtilities.outputExecutioner(cat).split('\n')
|
||||
|
||||
permitRootLogin = 0
|
||||
sshPort = "22"
|
||||
@@ -318,34 +307,19 @@ class FirewallManager:
|
||||
if items.find("Port") > -1 and not items.find("GatewayPorts") > -1:
|
||||
sshPort = items.split(" ")[1].strip("\n")
|
||||
|
||||
## changing permission back
|
||||
|
||||
command = 'sudo chown -R root:root /etc/ssh/sshd_config'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
final_dic = {'status': 1, 'permitRootLogin': permitRootLogin, 'sshPort': sshPort}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
|
||||
## temporarily changing permission for sshd files
|
||||
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel /root'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
pathToKeyFile = "/root/.ssh/authorized_keys"
|
||||
|
||||
cat = "sudo cat " + pathToKeyFile
|
||||
data = ProcessUtilities.outputExecutioner(cat).split('\n')
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
||||
data = open(pathToKeyFile, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find("ssh-rsa") > -1:
|
||||
keydata = items.split(" ")
|
||||
@@ -374,12 +348,6 @@ class FirewallManager:
|
||||
|
||||
json_data = json_data + ']'
|
||||
|
||||
## changing permission back
|
||||
|
||||
command = 'sudo chown -R root:root /root'
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
@@ -398,17 +366,20 @@ class FirewallManager:
|
||||
return ACLManager.loadErrorJson('saveStatus', 0)
|
||||
|
||||
type = data['type']
|
||||
sshPort = data['sshPort']
|
||||
rootLogin = data['rootLogin']
|
||||
|
||||
if type == "1":
|
||||
if rootLogin == True:
|
||||
rootLogin = "1"
|
||||
else:
|
||||
rootLogin = "0"
|
||||
|
||||
sshPort = data['sshPort']
|
||||
rootLogin = data['rootLogin']
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/firewallUtilities.py"
|
||||
execPath = execPath + " saveSSHConfigs --type " + str(type) + " --sshPort " + sshPort + " --rootLogin " + rootLogin
|
||||
|
||||
command = 'sudo semanage port -a -t ssh_port_t -p tcp ' + sshPort
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
FirewallUtilities.addRule('tcp', sshPort, "0.0.0.0/0")
|
||||
if output.find("1,None") > -1:
|
||||
|
||||
try:
|
||||
updateFW = FirewallRules.objects.get(name="SSHCustom")
|
||||
@@ -422,60 +393,13 @@ class FirewallManager:
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
|
||||
## temporarily changing permission for sshd files
|
||||
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel /etc/ssh/sshd_config'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
##
|
||||
|
||||
|
||||
if rootLogin == True:
|
||||
rootLogin = "PermitRootLogin yes\n"
|
||||
else:
|
||||
rootLogin = "PermitRootLogin no\n"
|
||||
|
||||
sshPort = "Port " + sshPort + "\n"
|
||||
|
||||
pathToSSH = "/etc/ssh/sshd_config"
|
||||
|
||||
data = open(pathToSSH, 'r').readlines()
|
||||
|
||||
writeToFile = open(pathToSSH, "w")
|
||||
|
||||
for items in data:
|
||||
if items.find("PermitRootLogin") > -1:
|
||||
if items.find("Yes") > -1 or items.find("yes"):
|
||||
writeToFile.writelines(rootLogin)
|
||||
continue
|
||||
elif items.find("Port") > -1:
|
||||
writeToFile.writelines(sshPort)
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
writeToFile.close()
|
||||
|
||||
command = 'sudo systemctl restart sshd'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
## changin back permissions
|
||||
|
||||
command = 'sudo chown -R root:root /etc/ssh/sshd_config'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
##
|
||||
|
||||
final_dic = {'status': 1, 'saveStatus': 1}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
final_dic = {'status': 0, 'saveStatus': 0, "error_message": output}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException, msg:
|
||||
final_dic = {'status': 0 ,'saveStatus': 0, 'error_message': str(msg)}
|
||||
@@ -493,44 +417,19 @@ class FirewallManager:
|
||||
|
||||
key = data['key']
|
||||
|
||||
# temp change of permissions
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/firewallUtilities.py"
|
||||
execPath = execPath + " deleteSSHKey --key '" + key + "'"
|
||||
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel /root'
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
##
|
||||
|
||||
keyPart = key.split(" ")[1]
|
||||
|
||||
pathToSSH = "/root/.ssh/authorized_keys"
|
||||
|
||||
data = open(pathToSSH, 'r').readlines()
|
||||
|
||||
writeToFile = open(pathToSSH, "w")
|
||||
|
||||
for items in data:
|
||||
if items.find("ssh-rsa") > -1 and items.find(keyPart) > -1:
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
writeToFile.close()
|
||||
|
||||
# change back permissions
|
||||
|
||||
command = 'sudo chown -R root:root /root'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
##
|
||||
|
||||
final_dic = {'status': 1, 'delete_status': 1}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
if output.find("1,None") > -1:
|
||||
final_dic = {'status': 1, 'delete_status': 1}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
final_dic = {'status': 1, 'delete_status': 1, "error_mssage": output}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException, msg:
|
||||
final_dic = {'status': 0, 'delete_status': 0, 'error_mssage': str(msg)}
|
||||
@@ -548,62 +447,25 @@ class FirewallManager:
|
||||
|
||||
key = data['key']
|
||||
|
||||
# temp change of permissions
|
||||
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel /root'
|
||||
writeToFile = open(tempPath, "w")
|
||||
writeToFile.write(key)
|
||||
writeToFile.close()
|
||||
|
||||
cmd = shlex.split(command)
|
||||
execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/firewallUtilities.py"
|
||||
execPath = execPath + " addSSHKey --tempPath " + tempPath
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
##
|
||||
|
||||
sshDir = "/root/.ssh"
|
||||
|
||||
pathToSSH = "/root/.ssh/authorized_keys"
|
||||
|
||||
if os.path.exists(sshDir):
|
||||
pass
|
||||
if output.find("1,None") > -1:
|
||||
final_dic = {'status': 1, 'add_status': 1}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
os.mkdir(sshDir)
|
||||
|
||||
if os.path.exists(pathToSSH):
|
||||
pass
|
||||
else:
|
||||
sshFile = open(pathToSSH, 'w')
|
||||
sshFile.writelines("#Created by CyberPanel\n")
|
||||
sshFile.close()
|
||||
|
||||
presenseCheck = 0
|
||||
try:
|
||||
data = open(pathToSSH, "r").readlines()
|
||||
for items in data:
|
||||
if items.find(key) > -1:
|
||||
presenseCheck = 1
|
||||
except:
|
||||
pass
|
||||
|
||||
if presenseCheck == 0:
|
||||
writeToFile = open(pathToSSH, 'a')
|
||||
writeToFile.writelines("#Added by CyberPanel\n")
|
||||
writeToFile.writelines("\n")
|
||||
writeToFile.writelines(key)
|
||||
writeToFile.writelines("\n")
|
||||
writeToFile.close()
|
||||
|
||||
# change back permissions
|
||||
|
||||
command = 'sudo chown -R root:root /root'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
|
||||
##
|
||||
|
||||
final_dic = {'status': 1, 'add_status': 1}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
final_dic = {'status': 0, 'add_status': 0, "error_mssage": output}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException, msg:
|
||||
final_dic = {'status': 0, 'add_status': 0, 'error_mssage': str(msg)}
|
||||
@@ -624,7 +486,7 @@ class FirewallManager:
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
modSecInstalled = 0
|
||||
|
||||
@@ -649,7 +511,14 @@ class FirewallManager:
|
||||
else:
|
||||
return ACLManager.loadErrorJson('installModSec', 0)
|
||||
|
||||
thread.start_new_thread(modSec.installModSec, ('Install', 'modSec'))
|
||||
writeToFile = open(modSec.installLogPath, "w")
|
||||
writeToFile.close()
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
|
||||
execPath = execPath + " installModSec"
|
||||
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
|
||||
final_json = json.dumps({'installModSec': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
@@ -661,7 +530,8 @@ class FirewallManager:
|
||||
def installStatusModSec(self, userID = None, data = None):
|
||||
try:
|
||||
|
||||
installStatus = unicode(open(modSec.installLogPath, "r").read())
|
||||
command = "sudo cat " + modSec.installLogPath
|
||||
installStatus = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if installStatus.find("[200]") > -1:
|
||||
|
||||
@@ -669,7 +539,7 @@ class FirewallManager:
|
||||
|
||||
execPath = execPath + " installModSecConfigs"
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
pass
|
||||
@@ -738,7 +608,7 @@ class FirewallManager:
|
||||
|
||||
if os.path.exists(modSecPath):
|
||||
command = "sudo cat " + confPath
|
||||
data = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
data = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
for items in data:
|
||||
|
||||
@@ -803,7 +673,7 @@ class FirewallManager:
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
|
||||
data = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
data = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
for items in data:
|
||||
if items.find('SecAuditEngine ') > -1:
|
||||
@@ -917,7 +787,7 @@ class FirewallManager:
|
||||
|
||||
execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
installUtilities.reStartLiteSpeed()
|
||||
@@ -973,7 +843,7 @@ class FirewallManager:
|
||||
|
||||
execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
installUtilities.reStartLiteSpeed()
|
||||
@@ -1004,7 +874,7 @@ class FirewallManager:
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
modSecInstalled = 0
|
||||
|
||||
@@ -1034,7 +904,7 @@ class FirewallManager:
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
modSecInstalled = 0
|
||||
|
||||
@@ -1047,7 +917,7 @@ class FirewallManager:
|
||||
|
||||
if modSecInstalled:
|
||||
command = "sudo cat " + rulesPath
|
||||
currentModSecRules = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
currentModSecRules = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
final_dic = {'modSecInstalled': 1,
|
||||
'currentModSecRules': currentModSecRules}
|
||||
@@ -1063,7 +933,7 @@ class FirewallManager:
|
||||
rulesPath = os.path.join(virtualHostUtilities.Server_root + "/conf/rules.conf")
|
||||
|
||||
command = "sudo cat " + rulesPath
|
||||
currentModSecRules = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
currentModSecRules = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
final_dic = {'modSecInstalled': 1,
|
||||
'currentModSecRules': currentModSecRules}
|
||||
@@ -1098,7 +968,7 @@ class FirewallManager:
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
|
||||
execPath = execPath + " saveModSecRules"
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath).split('\n')
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
installUtilities.reStartLiteSpeed()
|
||||
@@ -1130,7 +1000,7 @@ class FirewallManager:
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
modSecInstalled = 0
|
||||
|
||||
@@ -1160,7 +1030,7 @@ class FirewallManager:
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
modSecInstalled = 0
|
||||
|
||||
@@ -1174,7 +1044,7 @@ class FirewallManager:
|
||||
|
||||
if modSecInstalled:
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
for items in httpdConfig:
|
||||
|
||||
@@ -1205,9 +1075,9 @@ class FirewallManager:
|
||||
|
||||
try:
|
||||
command = 'sudo cat /usr/local/lsws/conf/comodo_litespeed/rules.conf.main'
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
res = ProcessUtilities.executioner(command)
|
||||
|
||||
if res == 0:
|
||||
if res == 1:
|
||||
comodoInstalled = 1
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
@@ -1242,7 +1112,7 @@ class FirewallManager:
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
|
||||
execPath = execPath + " " + packName
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
installUtilities.reStartLiteSpeed()
|
||||
@@ -1260,7 +1130,7 @@ class FirewallManager:
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
|
||||
execPath = execPath + " " + packName
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
installUtilities.reStartLiteSpeed()
|
||||
@@ -1292,7 +1162,7 @@ class FirewallManager:
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/httpd_config.conf')
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
@@ -1334,7 +1204,7 @@ class FirewallManager:
|
||||
|
||||
comodoPath = '/usr/local/lsws/conf/comodo_litespeed'
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel /usr/local/lsws/conf'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
json_data = "["
|
||||
|
||||
@@ -1370,7 +1240,7 @@ class FirewallManager:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
json_data = json_data + ']'
|
||||
final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data})
|
||||
@@ -1403,7 +1273,7 @@ class FirewallManager:
|
||||
|
||||
execPath = execPath + " " + functionName + ' --packName ' + packName + ' --fileName ' + fileName
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
installUtilities.reStartLiteSpeed()
|
||||
@@ -1433,8 +1303,8 @@ class FirewallManager:
|
||||
csfInstalled = 1
|
||||
try:
|
||||
command = 'sudo csf -h'
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
if res == 1:
|
||||
res = ProcessUtilities.executioner(command)
|
||||
if res == 0:
|
||||
csfInstalled = 0
|
||||
except subprocess.CalledProcessError:
|
||||
csfInstalled = 0
|
||||
@@ -1454,7 +1324,7 @@ class FirewallManager:
|
||||
|
||||
execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
|
||||
execPath = execPath + " installCSF"
|
||||
ProcessUtilities.popenExecutioner(shlex.split(execPath))
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
@@ -1477,7 +1347,7 @@ class FirewallManager:
|
||||
if installStatus.find("[200]")>-1:
|
||||
|
||||
command = 'sudo rm -f ' + CSF.installLogPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
final_json = json.dumps({
|
||||
'error_message': "None",
|
||||
@@ -1488,7 +1358,7 @@ class FirewallManager:
|
||||
return HttpResponse(final_json)
|
||||
elif installStatus.find("[404]") > -1:
|
||||
command = 'sudo rm -f ' + CSF.installLogPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
final_json = json.dumps({
|
||||
'abort':1,
|
||||
'installed':0,
|
||||
@@ -1522,7 +1392,7 @@ class FirewallManager:
|
||||
|
||||
execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
|
||||
execPath = execPath + " removeCSF"
|
||||
ProcessUtilities.popenExecutioner(shlex.split(execPath))
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
@@ -1581,7 +1451,7 @@ class FirewallManager:
|
||||
|
||||
execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
|
||||
execPath = execPath + " changeStatus --controller " + controller + " --status " + status
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {"status": 1}
|
||||
@@ -1615,7 +1485,7 @@ class FirewallManager:
|
||||
|
||||
execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
|
||||
execPath = execPath + " modifyPorts --protocol " + protocol + " --ports " + ports
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {"status": 1}
|
||||
|
||||
@@ -2,7 +2,6 @@ from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
|
||||
class FirewallRules(models.Model):
|
||||
name = models.CharField(unique=True, max_length=32) # Field name made lowercase.
|
||||
proto = models.CharField(max_length=10)
|
||||
|
||||
@@ -13,12 +13,11 @@ from loginSystem.models import Administrator
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from loginSystem.views import loadLoginPage
|
||||
from websiteFunctions.models import Websites
|
||||
import subprocess
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import shlex
|
||||
from plogical.ftpUtilities import FTPUtilities
|
||||
import os
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
class FTPManager:
|
||||
def __init__(self, request):
|
||||
@@ -85,7 +84,9 @@ class FTPManager:
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/ftpUtilities.py"
|
||||
execPath = execPath + " submitFTPCreation --domainName " + domainName + " --userName " + userName \
|
||||
+ " --password " + password + " --path " + path + " --owner " + admin.userName + ' --api ' + api
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'status': 1, 'creatFTPStatus': 1, 'error_message': 'None'}
|
||||
json_data = json.dumps(data_ret)
|
||||
|
||||
@@ -55,7 +55,7 @@ class HAManager(multi.Thread):
|
||||
|
||||
for command in commands:
|
||||
try:
|
||||
result = ProcessUtilities.executioner(command, shell=True)
|
||||
result = subprocess.call(command, shell=True)
|
||||
if result != 0:
|
||||
logging.writeToFile(command + ' Failed.')
|
||||
except BaseException:
|
||||
@@ -99,14 +99,14 @@ class HAManager(multi.Thread):
|
||||
workerToken = ''
|
||||
|
||||
command = "sudo docker swarm join-token manager"
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
output = subprocess.check_output(shlex.split(command)).splitlines()
|
||||
|
||||
for items in output:
|
||||
if items.find('--token') > -1:
|
||||
managerToken = items.split(' ')[-2]
|
||||
|
||||
command = "sudo docker swarm join-token worker"
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
output = subprocess.check_output(shlex.split(command)).splitlines()
|
||||
|
||||
for items in output:
|
||||
if items.find('--token') > -1:
|
||||
@@ -160,7 +160,7 @@ class HAManager(multi.Thread):
|
||||
|
||||
for command in commands:
|
||||
try:
|
||||
result = ProcessUtilities.executioner(command, shell=True)
|
||||
result = subprocess.call(command, shell=True)
|
||||
if result != 0:
|
||||
logging.writeToFile(command + ' Failed.')
|
||||
except BaseException, msg:
|
||||
|
||||
@@ -8,7 +8,7 @@ class FirewallUtilities:
|
||||
import install as inst
|
||||
try:
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
if inst.preFlightsChecks.resFailed(inst.get_distro(), res):
|
||||
inst.preFlightsChecks.stdOut("Failed to apply rule: " + command + " Error #" + str(res), 1)
|
||||
return 0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,12 +18,13 @@ class InstallCyberPanel:
|
||||
mysql_Root_password = ""
|
||||
mysqlPassword = ""
|
||||
|
||||
def __init__(self, rootPath, cwd, distro, ent, serial = None):
|
||||
def __init__(self, rootPath, cwd, distro, ent, serial = None, port = None):
|
||||
self.server_root_path = rootPath
|
||||
self.cwd = cwd
|
||||
self.distro = distro
|
||||
self.ent = ent
|
||||
self.serial = serial
|
||||
self.port = port
|
||||
|
||||
@staticmethod
|
||||
def stdOut(message, log=0, exit=0, code=os.EX_OK):
|
||||
@@ -337,7 +338,7 @@ class InstallCyberPanel:
|
||||
|
||||
while (1):
|
||||
command = "systemctl start mysqld@1"
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
if install.preFlightsChecks.resFailed(self.distro, res):
|
||||
count = count + 1
|
||||
@@ -357,7 +358,7 @@ class InstallCyberPanel:
|
||||
|
||||
while (1):
|
||||
command = "systemctl enable mysqld@1"
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
if install.preFlightsChecks.resFailed(self.distro, res):
|
||||
count = count + 1
|
||||
@@ -546,7 +547,7 @@ class InstallCyberPanel:
|
||||
shutil.copy(ftpdPath + "/pureftpd-mysql.conf", '/etc/pure-ftpd/db/mysql.conf')
|
||||
|
||||
command = 'echo 1 > /etc/pure-ftpd/conf/TLS'
|
||||
ProcessUtilities.executioner(command, shell=True)
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'systemctl restart pure-ftpd-mysql.service'
|
||||
install.preFlightsChecks.call(command, self.distro, '[installPureFTPDConfigurations]',
|
||||
@@ -565,12 +566,12 @@ class InstallCyberPanel:
|
||||
|
||||
if self.distro == ubuntu:
|
||||
command = 'systemctl stop systemd-resolved'
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
res = subprocess.call(shlex.split(command))
|
||||
if res != 0:
|
||||
InstallCyberPanel.stdOut('Unable to stop systemd.resolved, prohits install of PowerDNS, error #' +
|
||||
str(res), 1, 1, os.EX_OSERR)
|
||||
command = 'systemctl disable systemd-resolved.service'
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
res = subprocess.call(shlex.split(command))
|
||||
if res != 0:
|
||||
InstallCyberPanel.stdOut(
|
||||
'Unable to disable systemd.resolved, prohits install of PowerDNS, error #' +
|
||||
@@ -684,83 +685,6 @@ class InstallCyberPanel:
|
||||
except BaseException, msg:
|
||||
logging.InstallLog.writeToFile(str(msg) + " [startPowerDNS]")
|
||||
|
||||
def installLSCPD(self):
|
||||
try:
|
||||
|
||||
InstallCyberPanel.stdOut("Starting LSCPD installation..", 1)
|
||||
|
||||
os.chdir(self.cwd)
|
||||
|
||||
if self.distro == ubuntu:
|
||||
command = "apt-get -y install gcc g++ make autoconf rcs"
|
||||
else:
|
||||
command = 'yum -y install gcc gcc-c++ make autoconf glibc rcs'
|
||||
|
||||
install.preFlightsChecks.call(command, self.distro, '[installLSCPD]',
|
||||
'Install LSCPD',
|
||||
1, 1, os.EX_OSERR)
|
||||
|
||||
if self.distro == ubuntu:
|
||||
command = "apt-get -y install libpcre3 libpcre3-dev openssl libexpat1 libexpat1-dev libgeoip-dev" \
|
||||
" zlib1g zlib1g-dev libudns-dev whichman curl"
|
||||
else:
|
||||
command = 'yum -y install pcre-devel openssl-devel expat-devel geoip-devel zlib-devel udns-devel' \
|
||||
' which curl'
|
||||
install.preFlightsChecks.call(command, self.distro, '[installLSCPD]',
|
||||
'Install LSCPD',
|
||||
1, 1, os.EX_OSERR)
|
||||
|
||||
|
||||
command = 'tar zxf lscp.tar.gz -C /usr/local/'
|
||||
install.preFlightsChecks.call(command, self.distro, '[installLSCPD]',
|
||||
'Install LSCPD',
|
||||
1, 1, os.EX_OSERR)
|
||||
|
||||
|
||||
command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /usr/local/lscp/key.pem -out /usr/local/lscp/cert.pem'
|
||||
install.preFlightsChecks.call(command, self.distro, '[installLSCPD]',
|
||||
'Install LSCPD',
|
||||
1, 1, os.EX_OSERR)
|
||||
|
||||
try:
|
||||
os.remove("/usr/local/lscp/fcgi-bin/lsphp")
|
||||
shutil.copy("/usr/local/lsws/lsphp70/bin/lsphp","/usr/local/lscp/fcgi-bin/lsphp")
|
||||
except:
|
||||
pass
|
||||
|
||||
if self.distro == centos:
|
||||
command = 'adduser lscpd -M -d /usr/local/lscp'
|
||||
else:
|
||||
command = 'useradd lscpd -M -d /usr/local/lscp'
|
||||
|
||||
install.preFlightsChecks.call(command, self.distro, '[installLSCPD]',
|
||||
'Install LSCPD',
|
||||
1, 0, os.EX_OSERR)
|
||||
|
||||
if self.distro == centos:
|
||||
command = 'groupadd lscpd'
|
||||
install.preFlightsChecks.call(command, self.distro, '[installLSCPD]',
|
||||
'Install LSCPD',
|
||||
1, 0, os.EX_OSERR)
|
||||
# Added group in useradd for Ubuntu
|
||||
|
||||
command = 'usermod -a -G lscpd lscpd'
|
||||
install.preFlightsChecks.call(command, self.distro, '[installLSCPD]',
|
||||
'Install LSCPD',
|
||||
1, 0, os.EX_OSERR)
|
||||
|
||||
command = 'usermod -a -G lsadm lscpd'
|
||||
install.preFlightsChecks.call(command, self.distro, '[installLSCPD]',
|
||||
'Install LSCPD',
|
||||
1, 0, os.EX_OSERR)
|
||||
|
||||
os.mkdir('/usr/local/lscp/cyberpanel')
|
||||
|
||||
InstallCyberPanel.stdOut("LSCPD successfully installed!", 1)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.InstallLog.writeToFile(str(msg) + " [startPowerDNS]")
|
||||
|
||||
|
||||
def Main(cwd, mysql, distro, ent, serial = None):
|
||||
|
||||
@@ -809,6 +733,4 @@ def Main(cwd, mysql, distro, ent, serial = None):
|
||||
|
||||
installer.installPowerDNS()
|
||||
installer.installPowerDNSConfigurations(InstallCyberPanel.mysqlPassword, mysql)
|
||||
installer.startPowerDNS()
|
||||
|
||||
installer.installLSCPD()
|
||||
installer.startPowerDNS()
|
||||
Binary file not shown.
@@ -19,7 +19,7 @@ class mysqlUtilities:
|
||||
|
||||
command = 'mysql -u root -p' + password + ' -e "' + createDB + '"'
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
return 0
|
||||
@@ -29,7 +29,7 @@ class mysqlUtilities:
|
||||
command = 'mysql -u root -p' + password + ' -e "' + createUser + '"'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
return 0
|
||||
@@ -37,7 +37,7 @@ class mysqlUtilities:
|
||||
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'"
|
||||
command = 'mysql -u root -p' + password + ' -e "' + dropDB + '"'
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
return 0
|
||||
|
||||
@@ -9,7 +9,7 @@ def installCertBot():
|
||||
cmd.append("install")
|
||||
cmd.append("certbot")
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
|
||||
installCertBot()
|
||||
@@ -44,7 +44,7 @@ class unInstallCyberPanel:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
shutil.rmtree("/etc/postfix")
|
||||
shutil.rmtree("etc/dovecot")
|
||||
@@ -66,7 +66,7 @@ class unInstallCyberPanel:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
shutil.rmtree("/var/lib/mysql")
|
||||
os.remove("/etc/my.cnf")
|
||||
@@ -88,7 +88,7 @@ class unInstallCyberPanel:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
shutil.rmtree("/usr/local/lsws")
|
||||
|
||||
@@ -122,7 +122,7 @@ class unInstallCyberPanel:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
shutil.rmtree("/etc/pure-ftpd")
|
||||
|
||||
@@ -141,7 +141,7 @@ class unInstallCyberPanel:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
shutil.rmtree("/etc/pdns")
|
||||
|
||||
@@ -160,7 +160,7 @@ class unInstallCyberPanel:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
shutil.rmtree("/etc/pdns")
|
||||
|
||||
|
||||
@@ -181,6 +181,30 @@ def loadLoginPage(request):
|
||||
newFWRule = FirewallRules(name="ftp", proto="tcp", port="21")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="smtp", proto="tcp", port="25")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="smtps", proto="tcp", port="587")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="ssmtp", proto="tcp", port="465")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="pop3", proto="tcp", port="110")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="imap", proto="tcp", port="143")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="simap", proto="tcp", port="993")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="dns", proto="udp", port="53")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="dnstcp", proto="tcp", port="53")
|
||||
newFWRule.save()
|
||||
|
||||
newFWRule = FirewallRules(name="ftptls", proto="tcp", port="40110-40210")
|
||||
newFWRule.save()
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ from plogical.acl import ACLManager
|
||||
import os
|
||||
from plogical.dnsUtilities import DNS
|
||||
from loginSystem.models import Administrator
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
class MailServerManager:
|
||||
|
||||
@@ -76,7 +77,7 @@ class MailServerManager:
|
||||
execPath = execPath + " createEmailAccount --domain " + domainName + " --userName " \
|
||||
+ userName + " --password " + password
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'status': 1, 'createEmailStatus': 1, 'error_message': "None"}
|
||||
@@ -391,13 +392,13 @@ class MailServerManager:
|
||||
try:
|
||||
path = "/etc/opendkim/keys/" + domainName + "/default.txt"
|
||||
command = "sudo cat " + path
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
leftIndex = output.index('(') + 2
|
||||
rightIndex = output.rindex(')') - 1
|
||||
|
||||
path = "/etc/opendkim/keys/" + domainName + "/default.private"
|
||||
command = "sudo cat " + path
|
||||
privateKey = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
privateKey = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
data_ret = {'status': 1, 'fetchStatus': 1, 'keysAvailable': 1, 'publicKey': output[leftIndex:rightIndex],
|
||||
'privateKey': privateKey, 'dkimSuccessMessage': 'Keys successfully fetched!',
|
||||
@@ -428,7 +429,7 @@ class MailServerManager:
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
|
||||
execPath = execPath + " generateKeys --domain " + domainName
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
DNS.dnsTemplate(domainName, admin)
|
||||
@@ -444,7 +445,7 @@ class MailServerManager:
|
||||
|
||||
path = "/etc/opendkim/keys/" + domainName + "/default.txt"
|
||||
command = "sudo cat " + path
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
leftIndex = output.index('(') + 2
|
||||
rightIndex = output.rindex(')') - 1
|
||||
|
||||
@@ -492,15 +493,14 @@ class MailServerManager:
|
||||
def installStatusOpenDKIM(self):
|
||||
try:
|
||||
command = "sudo cat " + mailUtilities.installLogPath
|
||||
installStatus = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
installStatus = subprocess.check_output(shlex.split(command))
|
||||
|
||||
if installStatus.find("[200]") > -1:
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
|
||||
|
||||
execPath = execPath + " configureOpenDKIM"
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
pass
|
||||
|
||||
@@ -1273,10 +1273,13 @@ def submitExtensionRequest(request):
|
||||
type = data['type']
|
||||
|
||||
if type == "install":
|
||||
phpUtilities.initiateInstall(extensionName)
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
|
||||
execPath = execPath + " installPHPExtension --extension " + extensionName
|
||||
else:
|
||||
phpUtilities.initiateRemoval(extensionName)
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
|
||||
execPath = execPath + " unInstallPHPExtension --extension " + extensionName
|
||||
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
|
||||
final_json = json.dumps({'extensionRequestStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
@@ -1448,7 +1451,8 @@ def getCurrentPHPConfig(request):
|
||||
upload_max_filesize = ""
|
||||
max_input_time = ""
|
||||
|
||||
data = open(path, 'r').readlines()
|
||||
command = "sudo cat " + path
|
||||
data = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
for items in data:
|
||||
if items.find("allow_url_fopen") > -1 and items.find("=") > -1:
|
||||
@@ -1549,10 +1553,9 @@ def savePHPConfigBasic(request):
|
||||
##
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
|
||||
|
||||
execPath = execPath + " savePHPConfigBasic --phpVers " + phpVers + " --allow_url_fopen '" + allow_url_fopen + "' --display_errors '" + display_errors + "' --file_uploads '" + file_uploads + "' --allow_url_include '" + allow_url_include + "' --memory_limit " + memory_limit + " --max_execution_time " + max_execution_time + " --upload_max_filesize " + upload_max_filesize + " --max_input_time " + max_input_time + " --post_max_size " + post_max_size
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'saveStatus': 1}
|
||||
@@ -1598,7 +1601,8 @@ def getCurrentAdvancedPHPConfig(request):
|
||||
completeName = str(initial) + '.' + str(final)
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php/" + completeName + "/litespeed/php.ini"
|
||||
|
||||
configData = open(path, "r").read()
|
||||
command = "sudo cat " + path
|
||||
configData = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
status = {"fetchStatus": 1, "configData": configData}
|
||||
final_json = json.dumps(status)
|
||||
@@ -1641,16 +1645,13 @@ def savePHPConfigAdvance(request):
|
||||
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
vhost = open(tempPath, "w")
|
||||
|
||||
vhost.write(data['configData'])
|
||||
|
||||
vhost.close()
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
|
||||
|
||||
execPath = execPath + " savePHPConfigAdvance --phpVers " + path + " --tempPath " + tempPath
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
status = {"saveStatus": 1, "configData": data['configData']}
|
||||
|
||||
@@ -12,6 +12,7 @@ import shlex
|
||||
import subprocess
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
# Create your views here.
|
||||
|
||||
|
||||
@@ -76,7 +77,7 @@ def issueSSL(request):
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
execPath = execPath + " issueSSL --virtualHostName " + virtualHost + " --administratorEmail " + adminEmail + " --path " + path
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
pass
|
||||
@@ -148,10 +149,8 @@ def obtainHostNameSSL(request):
|
||||
## ssl issue
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " issueSSLForHostName --virtualHostName " + virtualHost + " --path " + path
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {"status": 1, "SSL": 1,
|
||||
@@ -218,10 +217,8 @@ def obtainMailServerSSL(request):
|
||||
## ssl issue
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " issueSSLForMailServer --virtualHostName " + virtualHost + " --path " + path
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {"status": 1, "SSL": 1,
|
||||
|
||||
@@ -12,7 +12,7 @@ class ServiceManager:
|
||||
type = self.extraArgs['type']
|
||||
path = '/etc/pdns/pdns.conf'
|
||||
|
||||
data = ProcessUtilities.outputExecutioner(shlex.split('sudo cat ' + path)).splitlines()
|
||||
data = subprocess.check_output(shlex.split('sudo cat ' + path)).splitlines()
|
||||
|
||||
if type == 'MASTER':
|
||||
counter = 0
|
||||
|
||||
@@ -12,6 +12,7 @@ import subprocess, shlex
|
||||
from plogical.acl import ACLManager
|
||||
from models import PDNSStatus
|
||||
from .serviceManager import ServiceManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
# Create your views here.
|
||||
|
||||
|
||||
@@ -174,10 +175,10 @@ def saveStatus(request):
|
||||
sm.managePDNS()
|
||||
|
||||
command = 'sudo systemctl enable pdns'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
else:
|
||||
|
||||
@@ -186,10 +187,10 @@ def saveStatus(request):
|
||||
pdns.save()
|
||||
|
||||
command = 'sudo systemctl stop pdns'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo systemctl disable pdns'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
elif service == 'postfix':
|
||||
@@ -199,13 +200,13 @@ def saveStatus(request):
|
||||
writeToFile = open(servicePath, 'w+')
|
||||
writeToFile.close()
|
||||
command = 'sudo systemctl start postfix'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
command = 'sudo systemctl stop postfix'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo systemctl disable postfix'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
try:
|
||||
os.remove(servicePath)
|
||||
@@ -223,13 +224,13 @@ def saveStatus(request):
|
||||
writeToFile = open(servicePath, 'w+')
|
||||
writeToFile.close()
|
||||
command = 'sudo systemctl start ' + serviceName
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
command = 'sudo systemctl stop ' + serviceName
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo systemctl disable ' + serviceName
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
try:
|
||||
os.remove(servicePath)
|
||||
|
||||
@@ -31,7 +31,7 @@ class CyberCPLogFileWriter:
|
||||
def readLastNFiles(numberOfLines,fileName):
|
||||
try:
|
||||
|
||||
lastFewLines = ProcessUtilities.outputExecutioner(["tail", "-n",str(numberOfLines),fileName])
|
||||
lastFewLines = subprocess.check_output(["tail", "-n",str(numberOfLines),fileName])
|
||||
|
||||
return lastFewLines
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ from databases.models import Databases
|
||||
from installUtilities import installUtilities
|
||||
import shutil
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
class ApplicationInstaller(multi.Thread):
|
||||
|
||||
@@ -48,13 +48,13 @@ class ApplicationInstaller(multi.Thread):
|
||||
def installWPCLI(self):
|
||||
try:
|
||||
command = 'sudo wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo chmod +x wp-cli.phar'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo mv wp-cli.phar /usr/bin/wp'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.writeToFile( str(msg) + ' [ApplicationInstaller.installWPCLI]')
|
||||
@@ -94,13 +94,13 @@ class ApplicationInstaller(multi.Thread):
|
||||
try:
|
||||
if os.path.exists("/etc/lsb-release"):
|
||||
command = 'apt -y install git'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
command = 'sudo yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo yum install git -y'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.writeToFile( str(msg) + ' [ApplicationInstaller.installGit]')
|
||||
@@ -158,9 +158,9 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
try:
|
||||
command = 'sudo wp --info'
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
res = ProcessUtilities.executioner(command)
|
||||
|
||||
if res == 1:
|
||||
if res == 0:
|
||||
self.installWPCLI()
|
||||
except subprocess.CalledProcessError:
|
||||
self.installWPCLI()
|
||||
@@ -235,7 +235,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
if not os.path.exists(finalPath):
|
||||
command = 'sudo mkdir -p ' + finalPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## checking for directories/files
|
||||
|
||||
@@ -249,7 +249,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
statusFile.close()
|
||||
|
||||
command = "sudo wp core download --allow-root --path=" + finalPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
@@ -258,7 +258,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
statusFile.close()
|
||||
|
||||
command = "sudo wp core config --dbname=" + dbName + " --dbuser=" + dbUser + " --dbpass=" + dbPassword + " --dbhost=localhost --dbprefix=wp_ --allow-root --path=" + finalPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
if home == '0':
|
||||
path = self.extraArgs['path']
|
||||
@@ -267,7 +267,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
finalURL = domainName
|
||||
|
||||
command = 'sudo wp core install --url="http://' + finalURL + '" --title="' + blogTitle + '" --admin_user="' + adminUser + '" --admin_password="' + adminPassword + '" --admin_email="' + adminEmail + '" --allow-root --path=' + finalPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
@@ -276,21 +276,20 @@ class ApplicationInstaller(multi.Thread):
|
||||
statusFile.close()
|
||||
|
||||
command = "sudo wp plugin install litespeed-cache --allow-root --path=" + finalPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Activating LSCache Plugin,90')
|
||||
statusFile.close()
|
||||
|
||||
command = "sudo wp plugin activate litespeed-cache --allow-root --path=" + finalPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Successfully Installed. [200]")
|
||||
@@ -307,8 +306,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
if not os.path.exists(homeDir):
|
||||
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
try:
|
||||
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
||||
@@ -406,7 +404,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
if not os.path.exists(finalPath):
|
||||
command = 'sudo mkdir -p ' + finalPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## checking for directories/files
|
||||
|
||||
@@ -420,13 +418,13 @@ class ApplicationInstaller(multi.Thread):
|
||||
statusFile.close()
|
||||
|
||||
command = "sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "sudo unzip -o prestashop_1.7.4.2.zip -d " + finalPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "sudo unzip -o " + finalPath + "prestashop.zip -d " + finalPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
@@ -449,22 +447,20 @@ class ApplicationInstaller(multi.Thread):
|
||||
" --db_server=localhost --db_name=" + dbName + " --db_user=" + dbUser + " --db_password=" + dbPassword \
|
||||
+ " --name='" + shopName + "' --firstname=" + firstName + " --lastname=" + lastName + \
|
||||
" --email=" + email + " --password=" + password
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = "sudo rm -rf " + finalPath + "install"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "sudo rm -f prestashop_1.7.4.2.zip"
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Successfully Installed. [200]")
|
||||
@@ -479,8 +475,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
if not os.path.exists(homeDir):
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
try:
|
||||
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
||||
@@ -512,9 +507,9 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
try:
|
||||
command = 'sudo git --help'
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
res = ProcessUtilities.executioner(command)
|
||||
|
||||
if res == 1:
|
||||
if res == 0:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Installing GIT..,0')
|
||||
statusFile.close()
|
||||
@@ -561,7 +556,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
if not os.path.exists(finalPath):
|
||||
command = 'sudo mkdir -p ' + finalPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## checking for directories/files
|
||||
|
||||
@@ -578,8 +573,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
try:
|
||||
command = 'sudo GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" git clone --depth 1 --no-single-branch git@' + defaultProvider +'.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath
|
||||
logging.writeToFile(command)
|
||||
ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
except subprocess.CalledProcessError, msg:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Failed to clone repository, make sure you deployed your key to repository. [404]')
|
||||
@@ -589,8 +583,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
##
|
||||
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
vhost.addRewriteRules(domainName)
|
||||
installUtilities.reStartLiteSpeed()
|
||||
@@ -633,7 +626,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
return 0
|
||||
|
||||
command = 'sudo git --git-dir=' + finalPath + '.git --work-tree=' + finalPath +' pull'
|
||||
ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
@@ -641,8 +634,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
externalApp = website.externalApp
|
||||
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
return 0
|
||||
|
||||
@@ -674,16 +666,15 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
|
||||
command = 'sudo rm -rf ' + finalPath
|
||||
ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo mkdir ' + finalPath
|
||||
ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
gitPath = '/home/cyberpanel/' + domain + '.git'
|
||||
|
||||
@@ -730,8 +721,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
if not os.path.exists("staging.zip"):
|
||||
command = 'wget --no-check-certificate https://github.com/joomla/joomla-cms/archive/staging.zip -P ' + finalPath
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
else:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("File already exists." + " [404]")
|
||||
@@ -739,14 +729,12 @@ class ApplicationInstaller(multi.Thread):
|
||||
return 0
|
||||
|
||||
command = 'unzip ' + finalPath + 'staging.zip -d ' + finalPath
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
os.remove(finalPath + 'staging.zip')
|
||||
|
||||
command = 'cp -r ' + finalPath + 'joomla-cms-staging/. ' + finalPath
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
shutil.rmtree(finalPath + "joomla-cms-staging")
|
||||
os.rename(finalPath + "installation/configuration.php-dist", finalPath + "configuration.php")
|
||||
@@ -816,7 +804,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
f2.close()
|
||||
|
||||
# Restore SQL
|
||||
proc = ProcessUtilities.popenExecutioner(["mysql", "--user=%s" % dbUser, "--password=%s" % dbPassword, dbName],
|
||||
proc = subprocess.Popen(["mysql", "--user=%s" % dbUser, "--password=%s" % dbPassword, dbName],
|
||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
|
||||
usercreation = """INSERT INTO `%susers`
|
||||
@@ -832,8 +820,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
shutil.rmtree(finalPath + "installation")
|
||||
|
||||
command = "sudo chown -R " + virtualHostUser + ":" + virtualHostUser + " " + finalPath
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
vhost.addRewriteRules(domainName)
|
||||
|
||||
@@ -851,8 +838,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
if not os.path.exists(homeDir):
|
||||
command = "sudo chown -R " + virtualHostUser + ":" + virtualHostUser + " " + homeDir
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
try:
|
||||
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
||||
@@ -881,11 +867,11 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
try:
|
||||
command = 'sudo git --git-dir=' + finalPath + '/.git checkout -b ' + githubBranch
|
||||
ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
except:
|
||||
try:
|
||||
command = 'sudo git --git-dir=' + finalPath + '/.git checkout ' + githubBranch
|
||||
ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
except subprocess.CalledProcessError, msg:
|
||||
logging.writeToFile('Failed to change branch: ' + str(msg))
|
||||
return 0
|
||||
|
||||
@@ -111,7 +111,7 @@ class backupSchedule:
|
||||
|
||||
writeToFile = open(backupLogPath, "a")
|
||||
command = "sudo scp -o StrictHostKeyChecking=no -P "+port+" -i /root/.ssh/cyberpanel " + backupPath + " root@"+IPAddress+":/home/backup/" + ipAddressLocal + "/" + time.strftime("%a-%b") + "/"
|
||||
ProcessUtilities.executioner(shlex.split(command), stdout=writeToFile)
|
||||
subprocess.call(shlex.split(command), stdout=writeToFile)
|
||||
|
||||
## Remove backups already sent to remote destinations
|
||||
|
||||
@@ -162,7 +162,7 @@ class backupSchedule:
|
||||
|
||||
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + ipAddress + " mkdir -p /home/backup/" + ipAddressLocal + "/" + time.strftime(
|
||||
"%a-%b")
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
pass
|
||||
|
||||
for virtualHost in os.listdir("/home"):
|
||||
|
||||
@@ -638,7 +638,7 @@ class backupUtilities:
|
||||
## Change permissions
|
||||
|
||||
command = "chmod -r vmail:vmail " + emailHome
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
except:
|
||||
pass
|
||||
@@ -656,7 +656,7 @@ class backupUtilities:
|
||||
|
||||
command = "chown -R " + externalApp + ":" + externalApp + " " + websiteHome
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd)
|
||||
subprocess.call(cmd)
|
||||
|
||||
except BaseException, msg:
|
||||
status = os.path.join(completPath, 'status')
|
||||
@@ -778,7 +778,7 @@ class backupUtilities:
|
||||
@staticmethod
|
||||
def checkIfHostIsUp(IPAddress):
|
||||
try:
|
||||
if ProcessUtilities.outputExecutioner(['ping', IPAddress, '-c 1']).find("0% packet loss") > -1:
|
||||
if subprocess.check_output(['ping', IPAddress, '-c 1']).find("0% packet loss") > -1:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
@@ -807,22 +807,22 @@ class backupUtilities:
|
||||
index = checkConn.expect(expectation)
|
||||
|
||||
if index == 0:
|
||||
ProcessUtilities.executioner(['kill', str(checkConn.pid)])
|
||||
subprocess.call(['kill', str(checkConn.pid)])
|
||||
logging.CyberCPLogFileWriter.writeToFile("Remote Server is not able to authenticate for transfer to initiate, IP Address:" + IPAddress)
|
||||
return [0,"Remote Server is not able to authenticate for transfer to initiate."]
|
||||
elif index == 1:
|
||||
ProcessUtilities.executioner(['kill', str(checkConn.pid)])
|
||||
subprocess.call(['kill', str(checkConn.pid)])
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
"Remote Server is not able to authenticate for transfer to initiate, IP Address:" + IPAddress)
|
||||
return [0, "Remote Server is not able to authenticate for transfer to initiate."]
|
||||
elif index == 2:
|
||||
ProcessUtilities.executioner(['kill', str(checkConn.pid)])
|
||||
subprocess.call(['kill', str(checkConn.pid)])
|
||||
return [1, "None"]
|
||||
elif index == 4:
|
||||
ProcessUtilities.executioner(['kill', str(checkConn.pid)])
|
||||
subprocess.call(['kill', str(checkConn.pid)])
|
||||
return [1, "None"]
|
||||
else:
|
||||
ProcessUtilities.executioner(['kill', str(checkConn.pid)])
|
||||
subprocess.call(['kill', str(checkConn.pid)])
|
||||
return [1, "None"]
|
||||
|
||||
except pexpect.TIMEOUT, msg:
|
||||
@@ -907,13 +907,13 @@ class backupUtilities:
|
||||
|
||||
try:
|
||||
command = "sudo ssh -o StrictHostKeyChecking=no -p "+ port +" -i /root/.ssh/cyberpanel root@"+IPAddress+" mkdir /home/backup"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + IPAddress + ' "cat /root/.ssh/authorized_keys /root/.ssh/temp > /root/.ssh/authorized_temp"'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + IPAddress + ' "cat /root/.ssh/authorized_temp > /root/.ssh/authorized_keys"'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createBackupDir]")
|
||||
@@ -923,7 +923,7 @@ class backupUtilities:
|
||||
def host_key_verification(IPAddress):
|
||||
try:
|
||||
command = 'sudo ssh-keygen -R ' + IPAddress
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
return 1
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [host_key_verification]")
|
||||
|
||||
190
plogical/cronUtil.py
Normal file
190
plogical/cronUtil.py
Normal file
@@ -0,0 +1,190 @@
|
||||
import CyberCPLogFileWriter as logging
|
||||
import subprocess
|
||||
import shlex
|
||||
import thread
|
||||
import installUtilities
|
||||
import argparse
|
||||
import os
|
||||
from mailUtilities import mailUtilities
|
||||
from processUtilities import ProcessUtilities
|
||||
from random import randint
|
||||
|
||||
class CronUtil:
|
||||
|
||||
@staticmethod
|
||||
def getWebsiteCron(externalApp):
|
||||
try:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
cronPath = "/var/spool/cron/" + externalApp
|
||||
else:
|
||||
cronPath = "/var/spool/cron/crontabs/" + externalApp
|
||||
|
||||
cmd = 'sudo test -e ' + cronPath + ' && echo Exists'
|
||||
output = os.popen(cmd).read()
|
||||
|
||||
if "Exists" not in output:
|
||||
print "0,Not Exists"
|
||||
return 1
|
||||
|
||||
try:
|
||||
f = subprocess.check_output(["sudo", "crontab", "-u", externalApp, "-l"])
|
||||
print f
|
||||
except BaseException, msg:
|
||||
print "0," + str(msg)
|
||||
return 1
|
||||
|
||||
except BaseException, msg:
|
||||
print "0," + str(msg)
|
||||
|
||||
@staticmethod
|
||||
def saveCronChanges(externalApp, finalCron, line):
|
||||
try:
|
||||
|
||||
tempPath = "/home/cyberpanel/" + externalApp + str(randint(10000, 99999)) + ".cron.tmp"
|
||||
|
||||
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", externalApp, "-l"])
|
||||
|
||||
if "no crontab for" in output:
|
||||
print "0,crontab file does not exists for user"
|
||||
return 1
|
||||
|
||||
with open(tempPath, "w+") as file:
|
||||
file.write(output)
|
||||
|
||||
# Confirming that directory is read/writable
|
||||
o = subprocess.call(['sudo', 'chown', 'cyberpanel:cyberpanel', tempPath])
|
||||
if o is not 0:
|
||||
print "0,Error Changing Permissions"
|
||||
return 1
|
||||
|
||||
with open(tempPath, 'r') as file:
|
||||
data = file.readlines()
|
||||
|
||||
data[line] = finalCron + '\n'
|
||||
|
||||
with open(tempPath, 'w') as file:
|
||||
file.writelines(data)
|
||||
|
||||
output = subprocess.call(["sudo", "/usr/bin/crontab", "-u", externalApp, tempPath])
|
||||
|
||||
os.remove(tempPath)
|
||||
if output != 0:
|
||||
print "0,Incorrect Syntax cannot be accepted."
|
||||
return 1
|
||||
|
||||
print "1,None"
|
||||
except BaseException, msg:
|
||||
print "0," + str(msg)
|
||||
|
||||
@staticmethod
|
||||
def remCronbyLine(externalApp, line):
|
||||
try:
|
||||
line -= 1
|
||||
|
||||
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", externalApp, "-l"])
|
||||
|
||||
if "no crontab for" in output:
|
||||
print "0,No Cron exists for this user"
|
||||
return 1
|
||||
|
||||
tempPath = "/home/cyberpanel/" + externalApp + str(randint(10000, 99999)) + ".cron.tmp"
|
||||
|
||||
with open(tempPath, "w+") as file:
|
||||
file.write(output)
|
||||
|
||||
# Confirming that directory is read/writable
|
||||
o = subprocess.call(['sudo', 'chown', 'cyberpanel:cyberpanel', tempPath])
|
||||
if o is not 0:
|
||||
print "0,Error Changing Permissions"
|
||||
return 1
|
||||
|
||||
with open(tempPath, 'r') as file:
|
||||
data = file.readlines()
|
||||
|
||||
removedLine = data.pop(line)
|
||||
|
||||
with open(tempPath, 'w') as file:
|
||||
file.writelines(data)
|
||||
|
||||
output = subprocess.call(["sudo", "/usr/bin/crontab", "-u", externalApp, tempPath])
|
||||
|
||||
os.remove(tempPath)
|
||||
if output != 0:
|
||||
print "0,Incorrect Syntax cannot be accepted"
|
||||
return 1
|
||||
|
||||
print "1," + removedLine
|
||||
except BaseException, msg:
|
||||
print "0," + str(msg)
|
||||
|
||||
@staticmethod
|
||||
def addNewCron(externalApp, finalCron):
|
||||
try:
|
||||
|
||||
try:
|
||||
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", externalApp, "-l"])
|
||||
except:
|
||||
try:
|
||||
subprocess.call(('sudo', 'crontab', '-u', externalApp, '-'))
|
||||
except:
|
||||
print "0,Unable to initialise crontab file for user"
|
||||
return 1
|
||||
|
||||
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", externalApp, "-l"])
|
||||
|
||||
if "no crontab for" in output:
|
||||
echo = subprocess.Popen((['cat', '/dev/null']), stdout=subprocess.PIPE)
|
||||
subprocess.call(('sudo', 'crontab', '-u', externalApp, '-'), stdin=echo.stdout)
|
||||
echo.wait()
|
||||
echo.stdout.close()
|
||||
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", externalApp, "-l"])
|
||||
if "no crontab for" in output:
|
||||
print "0,Unable to initialise crontab file for user"
|
||||
return 1
|
||||
|
||||
tempPath = "/home/cyberpanel/" + externalApp + str(randint(10000, 99999)) + ".cron.tmp"
|
||||
|
||||
with open(tempPath, "a") as file:
|
||||
file.write(output + finalCron + "\n")
|
||||
|
||||
output = subprocess.call(["sudo", "/usr/bin/crontab", "-u", externalApp, tempPath])
|
||||
|
||||
os.remove(tempPath)
|
||||
if output != 0:
|
||||
print "0,Incorrect Syntax cannot be accepted"
|
||||
return 1
|
||||
|
||||
print "1,None"
|
||||
except BaseException, msg:
|
||||
print "0," + str(msg)
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||
parser.add_argument('function', help='Specific a function to call!')
|
||||
|
||||
parser.add_argument("--externalApp", help="externalApp")
|
||||
parser.add_argument("--line", help="")
|
||||
parser.add_argument("--finalCron", help="")
|
||||
parser.add_argument("--tempPath", help="Temporary path to file where PHP is storing data!")
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.function == "getWebsiteCron":
|
||||
CronUtil.getWebsiteCron(args.externalApp)
|
||||
elif args.function == "saveCronChanges":
|
||||
CronUtil.saveCronChanges(args.externalApp, args.finalCron, int(args.line))
|
||||
elif args.function == "remCronbyLine":
|
||||
CronUtil.remCronbyLine(args.externalApp, int(args.line))
|
||||
elif args.function == "addNewCron":
|
||||
CronUtil.addNewCron(args.externalApp, args.finalCron)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -141,7 +141,7 @@ class CSF(multi.Thread):
|
||||
currentSettings = {}
|
||||
|
||||
command = 'sudo cat /etc/csf/csf.conf'
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
output = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
for items in output:
|
||||
if items.find('TESTING') > -1 and items.find('=') > -1 and (items[0]!= '#') and items.find('TESTING_INTERVAL') == -1:
|
||||
@@ -167,7 +167,7 @@ class CSF(multi.Thread):
|
||||
currentSettings['firewallStatus'] = 0
|
||||
|
||||
command = 'sudo iptables -nv -L'
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if output.find('0.0.0.0/0') > -1:
|
||||
currentSettings['firewallStatus'] = 1
|
||||
@@ -259,10 +259,10 @@ class CSF(multi.Thread):
|
||||
def allowIP(ipAddress):
|
||||
try:
|
||||
command = 'sudo csf -dr ' + ipAddress
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo csf -a ' + ipAddress
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[allowIP]")
|
||||
@@ -272,10 +272,10 @@ class CSF(multi.Thread):
|
||||
try:
|
||||
|
||||
command = 'sudo csf -tr ' + ipAddress
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo csf -d ' + ipAddress
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[blockIP]")
|
||||
|
||||
@@ -326,7 +326,7 @@ class DNS:
|
||||
|
||||
path = "/etc/opendkim/keys/" + topLevelDomain + "/default.txt"
|
||||
command = "sudo cat " + path
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
leftIndex = output.index('(') + 2
|
||||
rightIndex = output.rindex(')') - 1
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ class findBWUsage:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
logging.CyberCPLogFileWriter.writeToFile("1440 [setup_cron]")
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import subprocess
|
||||
import CyberCPLogFileWriter as logging
|
||||
import shlex
|
||||
from processUtilities import ProcessUtilities
|
||||
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
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()
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
import argparse
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
|
||||
class FirewallUtilities:
|
||||
@@ -18,9 +24,8 @@ class FirewallUtilities:
|
||||
@staticmethod
|
||||
def doCommand(command):
|
||||
try:
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
if FirewallUtilities.resFailed(res):
|
||||
res = ProcessUtilities.executioner(command)
|
||||
if res == 0:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error #" + str(res))
|
||||
return 0
|
||||
|
||||
@@ -33,7 +38,6 @@ class FirewallUtilities:
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
def addRule(proto,port,ipAddress):
|
||||
ruleFamily = 'rule family="ipv4"'
|
||||
@@ -70,7 +74,7 @@ class FirewallUtilities:
|
||||
|
||||
command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||
|
||||
if not FirewallUtilities.doCommand(command):
|
||||
if ProcessUtilities.executioner(command) == 0:
|
||||
return 0
|
||||
|
||||
ruleFamily = 'rule family="ipv6"'
|
||||
@@ -78,12 +82,155 @@ class FirewallUtilities:
|
||||
|
||||
command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||
|
||||
if not FirewallUtilities.doCommand(command):
|
||||
if ProcessUtilities.executioner(command) == 0:
|
||||
return 0
|
||||
|
||||
command = 'sudo firewall-cmd --reload'
|
||||
|
||||
if not FirewallUtilities.doCommand(command):
|
||||
if ProcessUtilities.executioner(command) == 0:
|
||||
return 0
|
||||
|
||||
return 1
|
||||
return 1
|
||||
|
||||
@staticmethod
|
||||
def saveSSHConfigs(type, sshPort, rootLogin):
|
||||
try:
|
||||
if type == "1":
|
||||
|
||||
command = 'sudo semanage port -a -t ssh_port_t -p tcp ' + sshPort
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
FirewallUtilities.addRule('tcp', sshPort, "0.0.0.0/0")
|
||||
|
||||
|
||||
if rootLogin == "1":
|
||||
rootLogin = "PermitRootLogin yes\n"
|
||||
else:
|
||||
rootLogin = "PermitRootLogin no\n"
|
||||
|
||||
sshPort = "Port " + sshPort + "\n"
|
||||
|
||||
pathToSSH = "/etc/ssh/sshd_config"
|
||||
|
||||
data = open(pathToSSH, 'r').readlines()
|
||||
|
||||
writeToFile = open(pathToSSH, "w")
|
||||
|
||||
for items in data:
|
||||
if items.find("PermitRootLogin") > -1:
|
||||
if items.find("Yes") > -1 or items.find("yes"):
|
||||
writeToFile.writelines(rootLogin)
|
||||
continue
|
||||
elif items.find("Port") > -1:
|
||||
writeToFile.writelines(sshPort)
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
writeToFile.close()
|
||||
|
||||
command = 'sudo systemctl restart sshd'
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
print "1,None"
|
||||
|
||||
except BaseException, msg:
|
||||
print "0," + str(msg)
|
||||
|
||||
@staticmethod
|
||||
def addSSHKey(tempPath):
|
||||
try:
|
||||
key = open(tempPath, 'r').read()
|
||||
|
||||
sshDir = "/root/.ssh"
|
||||
|
||||
pathToSSH = "/root/.ssh/authorized_keys"
|
||||
|
||||
if os.path.exists(sshDir):
|
||||
pass
|
||||
else:
|
||||
os.mkdir(sshDir)
|
||||
|
||||
if os.path.exists(pathToSSH):
|
||||
pass
|
||||
else:
|
||||
sshFile = open(pathToSSH, 'w')
|
||||
sshFile.writelines("#Created by CyberPanel\n")
|
||||
sshFile.close()
|
||||
|
||||
presenseCheck = 0
|
||||
try:
|
||||
data = open(pathToSSH, "r").readlines()
|
||||
for items in data:
|
||||
if items.find(key) > -1:
|
||||
presenseCheck = 1
|
||||
except:
|
||||
pass
|
||||
|
||||
if presenseCheck == 0:
|
||||
writeToFile = open(pathToSSH, 'a')
|
||||
writeToFile.writelines("#Added by CyberPanel\n")
|
||||
writeToFile.writelines("\n")
|
||||
writeToFile.writelines(key)
|
||||
writeToFile.writelines("\n")
|
||||
writeToFile.close()
|
||||
|
||||
if os.path.split(tempPath):
|
||||
os.remove(tempPath)
|
||||
|
||||
print "1,None"
|
||||
|
||||
except BaseException, msg:
|
||||
print "0," + str(msg)
|
||||
|
||||
@staticmethod
|
||||
def deleteSSHKey(key):
|
||||
try:
|
||||
keyPart = key.split(" ")[1]
|
||||
pathToSSH = "/root/.ssh/authorized_keys"
|
||||
|
||||
data = open(pathToSSH, 'r').readlines()
|
||||
|
||||
writeToFile = open(pathToSSH, "w")
|
||||
|
||||
for items in data:
|
||||
if items.find("ssh-rsa") > -1 and items.find(keyPart) > -1:
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
|
||||
print "1,None"
|
||||
|
||||
except BaseException, msg:
|
||||
print "0," + str(msg)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||
parser.add_argument('function', help='Specific a function to call!')
|
||||
|
||||
## Litespeed Tuning Arguments
|
||||
|
||||
parser.add_argument("--tempPath", help="Temporary path to file where PHP is storing data!")
|
||||
|
||||
parser.add_argument("--type", help="Type")
|
||||
parser.add_argument("--sshPort", help="SSH Port")
|
||||
parser.add_argument("--rootLogin", help="Root Login")
|
||||
parser.add_argument("--key", help="Key")
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.function == "saveSSHConfigs":
|
||||
FirewallUtilities.saveSSHConfigs(args.type, args.sshPort, args.rootLogin)
|
||||
elif args.function == "addSSHKey":
|
||||
FirewallUtilities.addSSHKey(args.tempPath)
|
||||
elif args.function == "deleteSSHKey":
|
||||
FirewallUtilities.deleteSSHKey(args.key)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -21,7 +21,6 @@ from datetime import datetime
|
||||
|
||||
class FTPUtilities:
|
||||
|
||||
|
||||
@staticmethod
|
||||
def createNewFTPAccount(udb,upass,username,password,path):
|
||||
try:
|
||||
@@ -32,7 +31,7 @@ class FTPUtilities:
|
||||
cmd.append("ftpuser:2001")
|
||||
cmd.append(path)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
if res == 1:
|
||||
print "Permissions not changed."
|
||||
else:
|
||||
@@ -58,7 +57,7 @@ class FTPUtilities:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
print "Permissions not changed."
|
||||
@@ -72,7 +71,7 @@ class FTPUtilities:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
return 0
|
||||
@@ -96,7 +95,7 @@ class FTPUtilities:
|
||||
|
||||
command = "chown " + externalApp + ":" + externalApp + " " + path
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
return 1,'None'
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class installUtilities:
|
||||
cmd.append("-y")
|
||||
cmd.append("install")
|
||||
cmd.append("epel-release")
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
@@ -47,7 +47,7 @@ class installUtilities:
|
||||
cmd.append("rpm")
|
||||
cmd.append("-ivh")
|
||||
cmd.append("http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm")
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
print(" Could not add Litespeed repo " )
|
||||
@@ -78,7 +78,7 @@ class installUtilities:
|
||||
cmd.append("install")
|
||||
cmd.append("openlitespeed-1.4.26")
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
|
||||
if res == 1:
|
||||
@@ -111,7 +111,7 @@ class installUtilities:
|
||||
cmd.append("/usr/local/lsws/bin/lswsctrl")
|
||||
cmd.append("start")
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
@@ -136,15 +136,13 @@ class installUtilities:
|
||||
@staticmethod
|
||||
def reStartLiteSpeed():
|
||||
try:
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
command = "sudo systemctl restart lsws"
|
||||
else:
|
||||
command = "sudo /usr/local/lsws/bin/lswsctrl restart"
|
||||
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
except OSError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
|
||||
@@ -165,7 +163,7 @@ class installUtilities:
|
||||
command = "sudo /usr/local/lsws/bin/lswsctrl restart"
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
@@ -216,7 +214,7 @@ class installUtilities:
|
||||
cmd.append("groupinstall")
|
||||
cmd.append("lsphp-all")
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
@@ -310,7 +308,7 @@ class installUtilities:
|
||||
cmd.append("remove")
|
||||
cmd.append("openlitespeed-1.4.26")
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
@@ -338,7 +336,7 @@ class installUtilities:
|
||||
cmd.append("remove")
|
||||
cmd.append("lsphp*")
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
@@ -380,7 +378,7 @@ class installUtilities:
|
||||
cmd.append("start")
|
||||
cmd.append("mariadb")
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
@@ -416,7 +414,7 @@ class installUtilities:
|
||||
cmd.append("install")
|
||||
cmd.append("mariadb-server")
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
@@ -456,7 +454,7 @@ class installUtilities:
|
||||
cmd.append("enable")
|
||||
cmd.append("mariadb")
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 1:
|
||||
print("###############################################")
|
||||
|
||||
@@ -80,13 +80,13 @@ class mailUtilities:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data/_data_'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
## After effects ends
|
||||
|
||||
@@ -159,18 +159,18 @@ class mailUtilities:
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
command = "opendkim-genkey -D /etc/opendkim/keys/" + virtualHostName + " -d " + virtualHostName + " -s default"
|
||||
ProcessUtilities.executioner(shlex.split(command),stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(shlex.split(command),stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
## Fix permissions
|
||||
|
||||
command = "chown -R root:opendkim /etc/opendkim/keys/" + virtualHostName
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "chmod 640 /etc/opendkim/keys/" + virtualHostName + "/default.private"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "chmod 644 /etc/opendkim/keys/" + virtualHostName + "/default.txt"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
## Edit key file
|
||||
|
||||
@@ -202,10 +202,10 @@ class mailUtilities:
|
||||
## Restart postfix and OpenDKIM
|
||||
|
||||
command = "systemctl restart opendkim"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "systemctl restart postfix"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
return 1, "None"
|
||||
|
||||
@@ -221,7 +221,7 @@ class mailUtilities:
|
||||
path = "/etc/opendkim.conf"
|
||||
|
||||
command = "sudo cat " + path
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
if res == 1:
|
||||
return 0
|
||||
@@ -285,15 +285,15 @@ milter_default_action = accept
|
||||
#### Restarting Postfix and OpenDKIM
|
||||
|
||||
command = "systemctl start opendkim"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "systemctl enable opendkim"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
##
|
||||
|
||||
command = "systemctl start postfix"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
print "1,None"
|
||||
return
|
||||
@@ -316,14 +316,14 @@ milter_default_action = accept
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
command = "sudo mkdir " + mailUtilities.cyberPanelHome
|
||||
ProcessUtilities.executioner(shlex.split(command), stdout=FNULL)
|
||||
subprocess.call(shlex.split(command), stdout=FNULL)
|
||||
|
||||
command = "sudo chown -R cyberpanel:cyberpanel " + mailUtilities.cyberPanelHome
|
||||
ProcessUtilities.executioner(shlex.split(command), stdout=FNULL)
|
||||
subprocess.call(shlex.split(command), stdout=FNULL)
|
||||
except:
|
||||
FNULL = open(os.devnull, 'w')
|
||||
command = "sudo chown -R cyberpanel:cyberpanel " + mailUtilities.cyberPanelHome
|
||||
ProcessUtilities.executioner(shlex.split(command), stdout=FNULL)
|
||||
subprocess.call(shlex.split(command), stdout=FNULL)
|
||||
|
||||
except BaseException,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [checkHome]")
|
||||
@@ -339,7 +339,7 @@ milter_default_action = accept
|
||||
cmd = shlex.split(command)
|
||||
|
||||
with open(mailUtilities.installLogPath, 'w') as f:
|
||||
res = ProcessUtilities.executioner(cmd, stdout=f)
|
||||
res = subprocess.call(cmd, stdout=f)
|
||||
|
||||
if res == 1:
|
||||
writeToFile = open(mailUtilities.installLogPath, 'a')
|
||||
@@ -363,10 +363,10 @@ milter_default_action = accept
|
||||
def restartServices():
|
||||
try:
|
||||
command = 'systemctl restart postfix'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = 'systemctl restart dovecot'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
except BaseException,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [restartServices]")
|
||||
|
||||
@@ -384,7 +384,7 @@ milter_default_action = accept
|
||||
cmd = shlex.split(command)
|
||||
|
||||
with open(mailUtilities.spamassassinInstallLogPath, 'w') as f:
|
||||
res = ProcessUtilities.executioner(cmd, stdout=f)
|
||||
res = subprocess.call(cmd, stdout=f)
|
||||
|
||||
if res == 1:
|
||||
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
|
||||
@@ -411,7 +411,7 @@ milter_default_action = accept
|
||||
path = "/etc/mail/spamassassin/local.cf"
|
||||
|
||||
command = "sudo cat " + path
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
res = subprocess.call(shlex.split(command))
|
||||
|
||||
if res == 1:
|
||||
return 0
|
||||
@@ -443,21 +443,21 @@ milter_default_action = accept
|
||||
|
||||
|
||||
command = "groupadd spamd"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
##
|
||||
|
||||
command = "chown spamd:spamd /var/log/spamassassin"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "systemctl enable spamassassin"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "systemctl start spamassassin"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
## Configuration to postfix
|
||||
|
||||
@@ -478,7 +478,7 @@ milter_default_action = accept
|
||||
writeToFile.close()
|
||||
|
||||
command = 'systemctl restart postfix'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
|
||||
print "1,None"
|
||||
@@ -531,7 +531,7 @@ milter_default_action = accept
|
||||
conf.close()
|
||||
|
||||
command = 'systemctl restart spamassassin'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
print "1,None"
|
||||
return
|
||||
@@ -552,10 +552,10 @@ milter_default_action = accept
|
||||
shutil.copy("/usr/local/CyberCP/postfixSenderPolicy/cpecs.service", "/etc/systemd/system/cpecs.service")
|
||||
|
||||
command = 'systemctl enable cpecs'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = 'systemctl start cpecs'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
writeToFile = open(postfixPath, 'a')
|
||||
writeToFile.writelines('smtpd_data_restrictions = check_policy_service unix:/var/log/policyServerSocket\n')
|
||||
@@ -563,7 +563,7 @@ milter_default_action = accept
|
||||
writeToFile.close()
|
||||
|
||||
command = 'systemctl restart postfix'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
else:
|
||||
|
||||
data = open(postfixPath, 'r').readlines()
|
||||
@@ -580,10 +580,10 @@ milter_default_action = accept
|
||||
writeToFile.close()
|
||||
|
||||
command = 'systemctl stop cpecs'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = 'systemctl restart postfix'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
print "1,None"
|
||||
return
|
||||
|
||||
@@ -10,13 +10,13 @@ from mailUtilities import mailUtilities
|
||||
from processUtilities import ProcessUtilities
|
||||
|
||||
class modSec:
|
||||
|
||||
installLogPath = "/home/cyberpanel/modSecInstallLog"
|
||||
tempRulesFile = "/home/cyberpanel/tempModSecRules"
|
||||
mirrorPath = "cyberpanel.net"
|
||||
|
||||
|
||||
@staticmethod
|
||||
def installModSec(install, modSecInstall):
|
||||
def installModSec():
|
||||
try:
|
||||
|
||||
mailUtilities.checkHome()
|
||||
@@ -29,7 +29,7 @@ class modSec:
|
||||
cmd = shlex.split(command)
|
||||
|
||||
with open(modSec.installLogPath, 'w') as f:
|
||||
res = ProcessUtilities.executioner(cmd, stdout=f)
|
||||
res = subprocess.call(cmd, stdout=f)
|
||||
|
||||
if res == 1:
|
||||
writeToFile = open(modSec.installLogPath, 'a')
|
||||
@@ -215,7 +215,6 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
|
||||
str(msg) + " [saveModSecRules]")
|
||||
print "0," + str(msg)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def setupComodoRules():
|
||||
try:
|
||||
@@ -230,7 +229,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
|
||||
os.remove('comodo.tar.gz')
|
||||
|
||||
command = "wget https://" + modSec.mirrorPath + "/modsec/comodo.tar.gz"
|
||||
result = ProcessUtilities.executioner(shlex.split(command))
|
||||
result = subprocess.call(shlex.split(command))
|
||||
|
||||
if result == 1:
|
||||
return 0
|
||||
@@ -250,13 +249,13 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
|
||||
os.remove('cpanel_litespeed_vendor')
|
||||
|
||||
command = "wget https://waf.comodo.com/api/cpanel_litespeed_vendor"
|
||||
result = ProcessUtilities.executioner(shlex.split(command))
|
||||
result = subprocess.call(shlex.split(command))
|
||||
|
||||
if result == 1:
|
||||
return 0
|
||||
|
||||
command = "unzip cpanel_litespeed_vendor -d " + extractLocation
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
return 1
|
||||
|
||||
@@ -334,16 +333,16 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
|
||||
os.remove('cpanel_litespeed_vendor')
|
||||
|
||||
command = "wget https://waf.comodo.com/api/cpanel_litespeed_vendor"
|
||||
result = ProcessUtilities.executioner(shlex.split(command))
|
||||
result = subprocess.call(shlex.split(command))
|
||||
|
||||
if result == 1:
|
||||
return 0
|
||||
|
||||
command = "unzip cpanel_litespeed_vendor -d " + extractLocation
|
||||
result = ProcessUtilities.executioner(shlex.split(command))
|
||||
result = subprocess.call(shlex.split(command))
|
||||
|
||||
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
print "1,None"
|
||||
return
|
||||
@@ -398,7 +397,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
|
||||
os.remove('owasp.tar.gz')
|
||||
|
||||
command = "wget https://" + modSec.mirrorPath + "/modsec/owasp.tar.gz"
|
||||
result = ProcessUtilities.executioner(shlex.split(command))
|
||||
result = subprocess.call(shlex.split(command))
|
||||
|
||||
if result == 1:
|
||||
return 0
|
||||
@@ -573,6 +572,8 @@ def main():
|
||||
|
||||
if args.function == "installModSecConfigs":
|
||||
modSec.installModSecConfigs()
|
||||
elif args.function == "installModSec":
|
||||
modSec.installModSec()
|
||||
elif args.function == "saveModSecConfigs":
|
||||
modSec.saveModSecConfigs(args.tempConfigPath)
|
||||
elif args.function == "saveModSecRules":
|
||||
|
||||
@@ -72,8 +72,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 + "'@'localhost' IDENTIFIED BY '"+dbpassword+"'")
|
||||
cursor.execute("GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'")
|
||||
connection.close()
|
||||
|
||||
return 1
|
||||
@@ -83,6 +83,42 @@ class mysqlUtilities:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDatabase]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def createDBUser(dbuser, dbpassword):
|
||||
try:
|
||||
|
||||
connection, cursor = mysqlUtilities.setupConnection()
|
||||
|
||||
if connection == 0:
|
||||
return 0
|
||||
|
||||
cursor.execute("CREATE DATABASE " + dbuser)
|
||||
cursor.execute("CREATE USER '" + dbuser + "'@'localhost' IDENTIFIED BY '" + dbpassword + "'")
|
||||
|
||||
return 1
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDBUser]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def allowGlobalUserAccess(globalUser, dbName):
|
||||
try:
|
||||
|
||||
connection, cursor = mysqlUtilities.setupConnection()
|
||||
|
||||
if connection == 0:
|
||||
return 0
|
||||
|
||||
cursor.execute("GRANT ALL PRIVILEGES ON " + dbName + ".* TO '" + globalUser + "'@'localhost'")
|
||||
connection.close()
|
||||
|
||||
return 1
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[createDatabase]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def deleteDatabase(dbname, dbuser):
|
||||
try:
|
||||
@@ -116,7 +152,7 @@ class mysqlUtilities:
|
||||
cmd = shlex.split(command)
|
||||
|
||||
with open(tempStoragePath+"/"+databaseName+'.sql', 'w') as f:
|
||||
res = ProcessUtilities.executioner(cmd,stdout=f)
|
||||
res = subprocess.call(cmd,stdout=f)
|
||||
|
||||
if res == 1:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Database: "+databaseName + "could not be backed! [createDatabaseBackup]")
|
||||
@@ -143,7 +179,7 @@ class mysqlUtilities:
|
||||
|
||||
|
||||
with open(tempStoragePath + "/" + databaseName + '.sql', 'r') as f:
|
||||
res = ProcessUtilities.executioner(cmd, stdin=f)
|
||||
res = subprocess.call(cmd, stdin=f)
|
||||
|
||||
if res == 1:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Could not restore MYSQL database: " +databaseName +"! [restoreDatabaseBackup]")
|
||||
@@ -347,7 +383,7 @@ class mysqlUtilities:
|
||||
command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf'
|
||||
else:
|
||||
command = 'sudo mv /etc/mysql/my.cnf.bak /etc/mysql//my.cnf'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return 0, str(msg)
|
||||
|
||||
@@ -383,7 +419,7 @@ class mysqlUtilities:
|
||||
|
||||
except BaseException, msg:
|
||||
command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return 0, str(msg)
|
||||
|
||||
@@ -608,4 +644,23 @@ class mysqlUtilities:
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[showStatus]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def changePassword(userName, dbPassword):
|
||||
try:
|
||||
|
||||
connection, cursor = mysqlUtilities.setupConnection()
|
||||
|
||||
if connection == 0:
|
||||
return 0
|
||||
|
||||
cursor.execute("use mysql")
|
||||
cursor.execute("SET PASSWORD FOR '" + userName + "'@'localhost' = PASSWORD('" + dbPassword + "')")
|
||||
connection.close()
|
||||
|
||||
return 1
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[mysqlUtilities.changePassword]")
|
||||
return 0
|
||||
@@ -27,7 +27,7 @@ class phpUtilities:
|
||||
|
||||
try:
|
||||
with open(phpUtilities.installLogPath, 'w') as f:
|
||||
ProcessUtilities.executioner(cmd, stdout=f)
|
||||
subprocess.call(cmd, stdout=f)
|
||||
|
||||
writeToFile = open(phpUtilities.installLogPath, 'a')
|
||||
writeToFile.writelines("PHP Extension Installed.\n")
|
||||
@@ -59,7 +59,7 @@ class phpUtilities:
|
||||
try:
|
||||
|
||||
with open(phpUtilities.installLogPath, 'w') as f:
|
||||
ProcessUtilities.executioner(cmd, stdout=f)
|
||||
subprocess.call(cmd, stdout=f)
|
||||
|
||||
writeToFile = open(phpUtilities.installLogPath, 'a')
|
||||
writeToFile.writelines("PHP Extension Removed.\n")
|
||||
@@ -178,6 +178,7 @@ def main():
|
||||
parser.add_argument("--upload_max_filesize", help="Process Soft Limit for PHP!")
|
||||
parser.add_argument("--max_input_time", help="Process Hard Limit for PHP!")
|
||||
parser.add_argument("--post_max_size", help="Process Hard Limit for PHP!")
|
||||
parser.add_argument("--extension", help="Process Hard Limit for PHP!")
|
||||
|
||||
## Litespeed Tuning Arguments
|
||||
|
||||
@@ -192,6 +193,12 @@ def main():
|
||||
elif args.function == "savePHPConfigAdvance":
|
||||
phpUtilities.savePHPConfigAdvance(args.phpVers, args.tempPath)
|
||||
|
||||
elif args.function == "installPHPExtension":
|
||||
phpUtilities.installPHPExtension(args.extension, args.extension)
|
||||
|
||||
elif args.function == "unInstallPHPExtension":
|
||||
phpUtilities.unInstallPHPExtension(args.extension, args.extension)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class ProcessUtilities:
|
||||
command = "sudo /usr/local/lsws/bin/lswsctrl restart"
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 0:
|
||||
return 1
|
||||
@@ -58,7 +58,7 @@ class ProcessUtilities:
|
||||
command = "sudo /usr/local/lsws/bin/lswsctrl stop"
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
if res == 0:
|
||||
return 1
|
||||
@@ -68,6 +68,17 @@ class ProcessUtilities:
|
||||
except subprocess.CalledProcessError, msg:
|
||||
logging.writeToFile(str(msg) + "[stopLitespeed]")
|
||||
|
||||
@staticmethod
|
||||
def normalExecutioner(command):
|
||||
try:
|
||||
res = subprocess.call(shlex.split(command))
|
||||
if res == 0:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
except BaseException, msg:
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def killLiteSpeed():
|
||||
try:
|
||||
@@ -107,7 +118,7 @@ class ProcessUtilities:
|
||||
def containerCheck():
|
||||
try:
|
||||
command = 'sudo cat /etc/cgrules.conf'
|
||||
result = ProcessUtilities.executioner(shlex.split(command))
|
||||
result = subprocess.call(shlex.split(command))
|
||||
if result == 1:
|
||||
return 0
|
||||
else:
|
||||
@@ -118,6 +129,7 @@ class ProcessUtilities:
|
||||
@staticmethod
|
||||
def executioner(command):
|
||||
try:
|
||||
logging.writeToFile(command)
|
||||
res = subprocess.call(shlex.split(command))
|
||||
if res == 0:
|
||||
return 1
|
||||
@@ -128,11 +140,23 @@ class ProcessUtilities:
|
||||
|
||||
@staticmethod
|
||||
def outputExecutioner(command):
|
||||
return subprocess.check_output(shlex.split(command))
|
||||
if type(command) == str or type(command) == unicode:
|
||||
logging.writeToFile(command)
|
||||
return subprocess.check_output(shlex.split(command))
|
||||
else:
|
||||
command = " ".join(command)
|
||||
logging.writeToFile(command + " join")
|
||||
return subprocess.check_output(shlex.split(command))
|
||||
|
||||
@staticmethod
|
||||
def popenExecutioner(command):
|
||||
return subprocess.Popen(shlex.split(command))
|
||||
if type(command) == str or type(command) == unicode:
|
||||
logging.writeToFile(command)
|
||||
return subprocess.Popen(shlex.split(command))
|
||||
else:
|
||||
command = " ".join(command)
|
||||
logging.writeToFile(command)
|
||||
return subprocess.Popen(shlex.split(command))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ class remoteBackup:
|
||||
## complete path is a path to the file need to send
|
||||
|
||||
command = 'sudo rsync -avz -e "ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" ' + completedPathToSend + ' root@' + IPAddress + ':/home/backup/transfer-'+folderNumber
|
||||
ProcessUtilities.executioner(shlex.split(command), stdout=writeToFile)
|
||||
subprocess.call(shlex.split(command), stdout=writeToFile)
|
||||
os.remove(completedPathToSend)
|
||||
|
||||
except BaseException, msg:
|
||||
|
||||
@@ -213,7 +213,7 @@ class remoteTransferUtilities:
|
||||
## complete path is a path to the file need to send
|
||||
|
||||
command = "sudo scp -o StrictHostKeyChecking=no -i /root/.ssh/cyberpanel " + completedPathToSend + " root@" + IPAddress + ":/home/backup/transfer-" + folderNumber + "/"
|
||||
ProcessUtilities.executioner(shlex.split(command), stdout=writeToFile)
|
||||
subprocess.call(shlex.split(command), stdout=writeToFile)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||
|
||||
@@ -236,14 +236,14 @@ class sslUtilities:
|
||||
|
||||
if not os.path.exists(acmePath):
|
||||
command = 'wget -O - https://get.acme.sh | sh'
|
||||
ProcessUtilities.executioner(command, shell=True)
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
if aliasDomain == None:
|
||||
|
||||
existingCertPath = '/etc/letsencrypt/live/' + virtualHostName
|
||||
if not os.path.exists(existingCertPath):
|
||||
command = 'mkdir -p ' + existingCertPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
try:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Trying to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName)
|
||||
@@ -252,7 +252,7 @@ class sslUtilities:
|
||||
+ ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
|
||||
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName + " and: www." + virtualHostName)
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ class sslUtilities:
|
||||
command = acmePath + " --issue -d " + virtualHostName + ' --cert-file ' + existingCertPath \
|
||||
+ '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
|
||||
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName)
|
||||
except subprocess.CalledProcessError:
|
||||
logging.CyberCPLogFileWriter.writeToFile('Failed to obtain SSL, issuing self-signed SSL for: ' + virtualHostName)
|
||||
@@ -275,7 +275,7 @@ class sslUtilities:
|
||||
existingCertPath = '/etc/letsencrypt/live/' + virtualHostName
|
||||
if not os.path.exists(existingCertPath):
|
||||
command = 'mkdir -p ' + existingCertPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
try:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
@@ -286,7 +286,7 @@ class sslUtilities:
|
||||
+ ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
|
||||
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
output = subprocess.check_output(shlex.split(command))
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
"Successfully obtained SSL for: " + virtualHostName + ", www." + virtualHostName + ", " + aliasDomain + "and www." + aliasDomain + ",")
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class tuning:
|
||||
try:
|
||||
dataToReturn = {}
|
||||
command = "sudo cat /usr/local/lsws/conf/httpd_config.conf"
|
||||
datas = ProcessUtilities.outputExecutioner(shlex.split(command)).split("\n")
|
||||
datas = ProcessUtilities.outputExecutioner(command).split("\n")
|
||||
|
||||
for items in datas:
|
||||
if items.find("maxConnections")>-1:
|
||||
@@ -58,7 +58,7 @@ class tuning:
|
||||
dataToReturn = {}
|
||||
|
||||
command = "sudo cat /usr/local/lsws/conf/httpd_config.xml"
|
||||
datas = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
datas = ProcessUtilities.outputExecutioner(command)
|
||||
comTree = ElementTree.fromstring(datas)
|
||||
tuningData = comTree.find('tuning')
|
||||
|
||||
@@ -187,7 +187,7 @@ class tuning:
|
||||
path = installUtilities.Server_root_path + "/conf/vhosts/"+virtualHost+"/vhost.conf"
|
||||
|
||||
command = "sudo cat "+path
|
||||
datas = ProcessUtilities.outputExecutioner(shlex.split(command)).split("\n")
|
||||
datas = ProcessUtilities.outputExecutioner(command).split("\n")
|
||||
|
||||
dataToReturn = {}
|
||||
|
||||
@@ -230,7 +230,7 @@ class tuning:
|
||||
else:
|
||||
try:
|
||||
command = "sudo cat /usr/local/lsws/conf/httpd_config.xml"
|
||||
datas = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
datas = ProcessUtilities.outputExecutioner(command)
|
||||
comTree = ElementTree.fromstring(datas)
|
||||
extProcessorList = comTree.findall('extProcessorList/extProcessor')
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class Upgrade:
|
||||
try:
|
||||
count = 0
|
||||
while True:
|
||||
res = ProcessUtilities.executioner(shlex.split(command))
|
||||
res = subprocess.call(shlex.split(command))
|
||||
if res != 0:
|
||||
count = count + 1
|
||||
Upgrade.stdOut(component + ' failed, trying again, try number: ' + str(count), 0)
|
||||
@@ -89,7 +89,7 @@ class Upgrade:
|
||||
##
|
||||
|
||||
env_path = '/usr/local/CyberCP'
|
||||
ProcessUtilities.executioner(['virtualenv', env_path])
|
||||
subprocess.call(['virtualenv', env_path])
|
||||
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
|
||||
execfile(activate_this, dict(__file__=activate_this))
|
||||
|
||||
@@ -990,11 +990,17 @@ WantedBy=multi-user.target"""
|
||||
|
||||
Upgrade.stdOut("Fixing permissions..")
|
||||
|
||||
command = 'chown -R cyberpanel:cyberpanel /usr/local/CyberCP'
|
||||
command = "find /usr/local/CyberCP -type d -exec chmod 0755 {} \;"
|
||||
Upgrade.executioner(command, 'chown core code', 0)
|
||||
|
||||
command = 'chown -R cyberpanel:cyberpanel /usr/local/lscp'
|
||||
Upgrade.executioner(command, 'chown lscp', 0)
|
||||
command = "find /usr/local/CyberCP -type f -exec chmod 0644 {} \;"
|
||||
Upgrade.executioner(command, 'chown core code', 0)
|
||||
|
||||
command = "chmod -R 755 /usr/local/CyberCP/bin"
|
||||
Upgrade.executioner(command, 'chown core code', 0)
|
||||
|
||||
command = "chown -R root:root /usr/local/CyberCP"
|
||||
Upgrade.executioner(command, 'chown core code', 0)
|
||||
|
||||
command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel'
|
||||
Upgrade.executioner(command, 'chown static content', 0)
|
||||
|
||||
@@ -11,7 +11,7 @@ class UpgradeCritical:
|
||||
try:
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
res = ProcessUtilities.executioner(shlex.split(command), stdout=FNULL)
|
||||
res = subprocess.call(shlex.split(command), stdout=FNULL)
|
||||
if res == 0:
|
||||
return 1
|
||||
else:
|
||||
@@ -26,7 +26,6 @@ class UpgradeCritical:
|
||||
command = "DEBIAN_FRONTEND=noninteractive apt-get install --only-upgrade pdns-server pdns-backend-mysql install dovecot-imapd dovecot-pop3d postfix-mysql pure-ftpd postfix dovecot-mysql -y"
|
||||
UpgradeCritical.executioner(command)
|
||||
else:
|
||||
|
||||
command = "yum update"
|
||||
UpgradeCritical.executioner(command)
|
||||
|
||||
|
||||
@@ -39,15 +39,15 @@ class vhost:
|
||||
command = "adduser " + virtualHostUser + " -M -d " + path
|
||||
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
command = "groupadd " + virtualHostUser
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
command = "usermod -a -G " + virtualHostUser + " " + virtualHostUser
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [addingUsers]")
|
||||
@@ -60,7 +60,7 @@ class vhost:
|
||||
try:
|
||||
command = 'chmod 711 /home'
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -69,11 +69,11 @@ class vhost:
|
||||
|
||||
command = "chown " + virtualHostUser + ":" + virtualHostUser + " " + path
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
command = "chmod 711 " + path
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except OSError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
@@ -85,7 +85,7 @@ class vhost:
|
||||
|
||||
command = "chown " + virtualHostUser + ":" + virtualHostUser + " " + pathHTML
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except OSError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
@@ -97,7 +97,7 @@ class vhost:
|
||||
|
||||
command = "chown " + "lscpd" + ":" + "lscpd" + " " + pathLogs
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
@@ -106,7 +106,7 @@ class vhost:
|
||||
command = "chmod -R 755 " + pathLogs
|
||||
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except OSError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
@@ -127,7 +127,7 @@ class vhost:
|
||||
|
||||
command = "chown " + "lsadm" + ":" + "lsadm" + " " + completePathToConfigFile
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except IOError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createDirectories]]")
|
||||
@@ -149,13 +149,13 @@ class vhost:
|
||||
|
||||
command = "chown " + virtualHostUser + ":" + virtualHostUser + " " + "/home/" + virtualHostName + "/public_html/index.html"
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
vhostPath = vhost.Server_root + "/conf/vhosts"
|
||||
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [finalizeVhostCreation]")
|
||||
@@ -332,7 +332,7 @@ class vhost:
|
||||
## Delete mail accounts
|
||||
|
||||
command = "sudo rm -rf /home/vmail/" + virtualHostName
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
|
||||
return 0
|
||||
@@ -368,7 +368,7 @@ class vhost:
|
||||
## Delete mail accounts
|
||||
|
||||
command = "sudo rm -rf /home/vmail/" + virtualHostName
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
|
||||
@@ -596,7 +596,7 @@ class vhost:
|
||||
try:
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel ' + path
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
|
||||
@@ -607,7 +607,7 @@ class vhost:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
@@ -673,12 +673,12 @@ class vhost:
|
||||
|
||||
command = "chown " + virtualHostUser + ":" + virtualHostUser + " " + path + "/index.html"
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
vhostPath = vhost.Server_root + "/conf/vhosts"
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [finalizeDomainCreation]")
|
||||
@@ -696,7 +696,7 @@ class vhost:
|
||||
os.makedirs(path)
|
||||
command = "chown " + virtualHostUser + ":" + virtualHostUser + " " + path
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
except OSError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + "329 [Not able to create directories for virtual host [createDirectoryForDomain]]")
|
||||
|
||||
@@ -166,10 +166,10 @@ class virtualHostUtilities:
|
||||
def getAccessLogs(fileName, page):
|
||||
try:
|
||||
|
||||
numberOfTotalLines = int(ProcessUtilities.outputExecutioner(["wc", "-l", fileName]).split(" ")[0])
|
||||
numberOfTotalLines = int(subprocess.check_output(["wc", "-l", fileName]).split(" ")[0])
|
||||
|
||||
if numberOfTotalLines < 25:
|
||||
data = ProcessUtilities.outputExecutioner(["cat", fileName])
|
||||
data = subprocess.check_output(["cat", fileName])
|
||||
else:
|
||||
if page == 1:
|
||||
end = numberOfTotalLines
|
||||
@@ -199,10 +199,10 @@ class virtualHostUtilities:
|
||||
def getErrorLogs(fileName, page):
|
||||
try:
|
||||
|
||||
numberOfTotalLines = int(ProcessUtilities.outputExecutioner(["wc", "-l", fileName]).split(" ")[0])
|
||||
numberOfTotalLines = int(subprocess.check_output(["wc", "-l", fileName]).split(" ")[0])
|
||||
|
||||
if numberOfTotalLines < 25:
|
||||
data = ProcessUtilities.outputExecutioner(["cat", fileName])
|
||||
data = subprocess.check_output(["cat", fileName])
|
||||
else:
|
||||
if page == 1:
|
||||
end = numberOfTotalLines
|
||||
@@ -303,13 +303,13 @@ class virtualHostUtilities:
|
||||
if not os.path.exists("latest.tar.gz"):
|
||||
command = 'wget --no-check-certificate http://wordpress.org/latest.tar.gz -O latest.tar.gz'
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
command = 'tar -xzvf latest.tar.gz -C ' + finalPath
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
## Get plugin
|
||||
|
||||
@@ -318,13 +318,13 @@ class virtualHostUtilities:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
command = 'unzip litespeed-cache.1.1.5.1.zip -d ' + finalPath
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
root = finalPath
|
||||
|
||||
@@ -368,7 +368,7 @@ class virtualHostUtilities:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
vhost.addRewriteRules(domainName)
|
||||
|
||||
@@ -392,7 +392,7 @@ class virtualHostUtilities:
|
||||
os.mkdir(homeDir)
|
||||
command = "chown -R " + virtualHostUser + ":" + virtualHostUser + " " + homeDir
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
print "0," + str(msg)
|
||||
return
|
||||
@@ -454,7 +454,7 @@ class virtualHostUtilities:
|
||||
|
||||
command = 'systemctl restart lscpd'
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd)
|
||||
subprocess.call(cmd)
|
||||
|
||||
print "1,None"
|
||||
return 1,'None'
|
||||
@@ -838,7 +838,7 @@ class virtualHostUtilities:
|
||||
pathToStoreSSL = '/etc/letsencrypt/live/' + virtualHost
|
||||
|
||||
command = 'mkdir -p ' + pathToStoreSSL
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
pathToStoreSSLPrivKey = pathToStoreSSL + "/privkey.pem"
|
||||
pathToStoreSSLFullChain = pathToStoreSSL + "/fullchain.pem"
|
||||
@@ -863,7 +863,7 @@ class virtualHostUtilities:
|
||||
|
||||
command = "chown " + "lsadm" + ":" + "lsadm" + " " + pathToStoreSSL
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
print "1,None"
|
||||
|
||||
@@ -1002,7 +1002,7 @@ class virtualHostUtilities:
|
||||
def getDiskUsage(path, totalAllowed):
|
||||
try:
|
||||
|
||||
totalUsageInMB = ProcessUtilities.outputExecutioner(["sudo", "du", "-hs", path, "--block-size=1M"]).split()[0]
|
||||
totalUsageInMB = subprocess.check_output(["sudo", "du", "-hs", path, "--block-size=1M"]).split()[0]
|
||||
|
||||
percentage = float(100) / float(totalAllowed)
|
||||
|
||||
@@ -1021,7 +1021,7 @@ class virtualHostUtilities:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
@@ -1033,7 +1033,7 @@ class virtualHostUtilities:
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
|
||||
@@ -167,7 +167,7 @@ class WebsiteManager:
|
||||
+ str(data['dkimCheck']) + " --openBasedir " + str(data['openBasedir']) + \
|
||||
' --websiteOwner ' + websiteOwner + ' --package ' + packageName + ' --tempStatusPath ' + tempStatusPath
|
||||
|
||||
subprocess.Popen(shlex.split(execPath))
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1, 'createWebSiteStatus': 1, 'error_message': "None", 'tempStatusPath': tempStatusPath}
|
||||
@@ -215,7 +215,7 @@ class WebsiteManager:
|
||||
+ " --openBasedir " + str(data['openBasedir']) + ' --path ' + path + ' --websiteOwner ' \
|
||||
+ admin.userName + ' --tempStatusPath ' + tempStatusPath
|
||||
|
||||
subprocess.Popen(shlex.split(execPath))
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1, 'createWebSiteStatus': 1, 'error_message': "None", 'tempStatusPath': tempStatusPath}
|
||||
@@ -296,7 +296,7 @@ class WebsiteManager:
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
execPath = execPath + " deleteVirtualHostConfigurations --virtualHostName " + websiteName
|
||||
ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
|
||||
data_ret = {'status': 1, 'websiteDeleteStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
@@ -321,7 +321,7 @@ class WebsiteManager:
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
execPath = execPath + " deleteDomain --virtualHostName " + websiteName
|
||||
ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
data_ret = {'status': 1, 'websiteDeleteStatus': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
@@ -346,18 +346,17 @@ class WebsiteManager:
|
||||
if state == "Suspend":
|
||||
confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + websiteName
|
||||
command = "sudo mv " + confPath + " " + confPath + "-suspended"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.popenExecutioner(command)
|
||||
installUtilities.reStartLiteSpeed()
|
||||
website.state = 0
|
||||
else:
|
||||
confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + websiteName
|
||||
|
||||
command = "sudo mv " + confPath + "-suspended" + " " + confPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + confPath
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd)
|
||||
ProcessUtilities.popenExecutioner(command)
|
||||
|
||||
installUtilities.reStartLiteSpeed()
|
||||
website.state = 1
|
||||
@@ -503,19 +502,10 @@ class WebsiteManager:
|
||||
completePathToConfigFile = confPath + "/vhost.conf"
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " changePHP --phpVersion '" + phpVersion + "' --path " + completePathToConfigFile
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
pass
|
||||
else:
|
||||
data_ret = {'status': 0, 'saveStatus': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
## php changes ends
|
||||
####
|
||||
|
||||
newOwner = Administrator.objects.get(userName=newUser)
|
||||
|
||||
@@ -574,7 +564,7 @@ class WebsiteManager:
|
||||
execPath = execPath + " findDomainBW --virtualHostName " + self.domain + " --bandwidth " + str(
|
||||
website.package.bandwidth)
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
bwData = output.split(",")
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
@@ -639,7 +629,7 @@ class WebsiteManager:
|
||||
execPath = execPath + " findDomainBW --virtualHostName " + self.domain + " --bandwidth " + str(
|
||||
website.package.bandwidth)
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
bwData = output.split(",")
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
@@ -695,7 +685,7 @@ class WebsiteManager:
|
||||
|
||||
execPath = execPath + " getAccessLogs --path " + fileName + " --page " + str(page)
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
final_json = json.dumps(
|
||||
@@ -754,10 +744,9 @@ class WebsiteManager:
|
||||
## get Logs
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " getErrorLogs --path " + fileName + " --page " + str(page)
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
final_json = json.dumps(
|
||||
@@ -783,7 +772,7 @@ class WebsiteManager:
|
||||
filePath = installUtilities.Server_root_path + "/conf/vhosts/" + self.domain + "/vhost.conf"
|
||||
|
||||
command = 'sudo cat ' + filePath
|
||||
configData = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
configData = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if len(configData) == 0:
|
||||
status = {'status': 0, "configstatus": 0, "error_message": "Configuration file is currently empty!"}
|
||||
@@ -822,10 +811,9 @@ class WebsiteManager:
|
||||
## save configuration data
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " saveVHostConfigs --path " + filePath + " --tempPath " + tempPath
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
status = {"configstatus": 1}
|
||||
@@ -905,10 +893,9 @@ class WebsiteManager:
|
||||
## save configuration data
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " saveRewriteRules --virtualHostName " + self.domain + " --path " + filePath + " --tempPath " + tempPath
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
status = {"rewriteStatus": 1, 'error_message': output}
|
||||
@@ -950,10 +937,8 @@ class WebsiteManager:
|
||||
## writing data temporary to file
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " saveSSL --virtualHostName " + self.domain + " --tempKeyPath " + tempKeyPath + " --tempCertPath " + tempCertPath
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'sslStatus': 1, 'error_message': "None"}
|
||||
@@ -983,17 +968,9 @@ class WebsiteManager:
|
||||
completePathToConfigFile = confPath + "/vhost.conf"
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " changePHP --phpVersion '" + phpVersion + "' --path " + completePathToConfigFile
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
pass
|
||||
else:
|
||||
data_ret = {'status': 1, 'changePHP': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
output = ProcessUtilities.popenExecutioner(execPath)
|
||||
|
||||
data_ret = {'status': 1, 'changePHP': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
@@ -1020,28 +997,19 @@ class WebsiteManager:
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
cronPath = "/var/spool/cron/" + website.externalApp
|
||||
else:
|
||||
cronPath = "/var/spool/cron/crontabs/" + website.externalApp
|
||||
|
||||
cmd = 'sudo test -e ' + cronPath + ' && echo Exists'
|
||||
output = os.popen(cmd).read()
|
||||
|
||||
if "Exists" not in output:
|
||||
data_ret = {'getWebsiteCron': 1, "user": website.externalApp, "crons": {}}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
crons = []
|
||||
|
||||
try:
|
||||
# f = ProcessUtilities.outputExecutioner(["sudo", "cat", cronPath])
|
||||
f = ProcessUtilities.outputExecutioner(["sudo", "crontab", "-u", website.externalApp, "-l"])
|
||||
except subprocess.CalledProcessError as error:
|
||||
dic = {'getWebsiteCron': 0, 'error_message': 'Unable to access Cron file'}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py"
|
||||
execPath = execPath + " getWebsiteCron --externalApp " + website.externalApp
|
||||
|
||||
f = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if f.find("0,") > -1:
|
||||
data_ret = {'getWebsiteCron': 0, "user": website.externalApp, "crons": {}}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
counter = 0
|
||||
for line in f.split("\n"):
|
||||
if line:
|
||||
@@ -1089,11 +1057,8 @@ class WebsiteManager:
|
||||
line -= 1
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
|
||||
cronPath = "/var/spool/cron/" + website.externalApp
|
||||
crons = []
|
||||
|
||||
try:
|
||||
# f = ProcessUtilities.outputExecutioner(["sudo", "cat", cronPath])
|
||||
# f = subprocess.check_output(["sudo", "cat", cronPath])
|
||||
f = ProcessUtilities.outputExecutioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
|
||||
print f
|
||||
except subprocess.CalledProcessError as error:
|
||||
@@ -1157,51 +1122,26 @@ class WebsiteManager:
|
||||
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
|
||||
tempPath = "/home/cyberpanel/" + website.externalApp + str(randint(10000, 99999)) + ".cron.tmp"
|
||||
|
||||
finalCron = "%s %s %s %s %s %s" % (minute, hour, monthday, month, weekday, command)
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
|
||||
|
||||
if "no crontab for" in output:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'crontab file does not exists for user'}
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py"
|
||||
execPath = execPath + " saveCronChanges --externalApp " + website.externalApp + " --line " + str(line) + " --finalCron '" + finalCron + "'"
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,") > -1:
|
||||
data_ret = {"getWebsiteCron": 1,
|
||||
"user": website.externalApp,
|
||||
"cron": finalCron,
|
||||
"line": line}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
dic = {'getWebsiteCron': 0, 'error_message': output}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
with open(tempPath, "w+") as file:
|
||||
file.write(output)
|
||||
|
||||
# Confirming that directory is read/writable
|
||||
o = ProcessUtilities.executioner(['sudo', 'chown', 'cyberpanel:cyberpanel', tempPath])
|
||||
if o is not 0:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'Error Changing Permissions'}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
with open(tempPath, 'r') as file:
|
||||
data = file.readlines()
|
||||
|
||||
data[line] = finalCron + '\n'
|
||||
|
||||
with open(tempPath, 'w') as file:
|
||||
file.writelines(data)
|
||||
|
||||
output = ProcessUtilities.executioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, tempPath])
|
||||
|
||||
os.remove(tempPath)
|
||||
if output != 0:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'Incorrect Syntax cannot be accepted.'}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
data_ret = {"getWebsiteCron": 1,
|
||||
"user": website.externalApp,
|
||||
"cron": finalCron,
|
||||
"line": line}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
except BaseException, msg:
|
||||
print msg
|
||||
dic = {'getWebsiteCron': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
@@ -1219,52 +1159,27 @@ class WebsiteManager:
|
||||
else:
|
||||
return ACLManager.loadErrorJson('addNewCron', 0)
|
||||
|
||||
line -= 1
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py"
|
||||
execPath = execPath + " remCronbyLine --externalApp " + website.externalApp + " --line " + str(
|
||||
line)
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if "no crontab for" in output:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'No Cron exists for this user'}
|
||||
if output.find("1,") > -1:
|
||||
data_ret = {"remCronbyLine": 1,
|
||||
"user": website.externalApp,
|
||||
"removeLine": output.split(',')[1],
|
||||
"line": line}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
dic = {'remCronbyLine': 0, 'error_message': output}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
tempPath = "/home/cyberpanel/" + website.externalApp + str(randint(10000, 99999)) + ".cron.tmp"
|
||||
|
||||
with open(tempPath, "w+") as file:
|
||||
file.write(output)
|
||||
|
||||
# Confirming that directory is read/writable
|
||||
o = ProcessUtilities.executioner(['sudo', 'chown', 'cyberpanel:cyberpanel', tempPath])
|
||||
if o is not 0:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'Error Changing Permissions'}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
with open(tempPath, 'r') as file:
|
||||
data = file.readlines()
|
||||
|
||||
removedLine = data.pop(line)
|
||||
|
||||
with open(tempPath, 'w') as file:
|
||||
file.writelines(data)
|
||||
|
||||
output = ProcessUtilities.executioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, tempPath])
|
||||
|
||||
os.remove(tempPath)
|
||||
if output != 0:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'Incorrect Syntax cannot be accepted'}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
data_ret = {"remCronbyLine": 1,
|
||||
"user": website.externalApp,
|
||||
"removeLine": removedLine,
|
||||
"line": line}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
except BaseException, msg:
|
||||
print msg
|
||||
dic = {'remCronbyLine': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
@@ -1290,51 +1205,25 @@ class WebsiteManager:
|
||||
|
||||
website = Websites.objects.get(domain=self.domain)
|
||||
|
||||
try:
|
||||
output = ProcessUtilities.outputExecutioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
|
||||
except:
|
||||
try:
|
||||
ProcessUtilities.executioner(('sudo', 'crontab', '-u', website.externalApp, '-'))
|
||||
except:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'Unable to initialise crontab file for user'}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
|
||||
|
||||
if "no crontab for" in output:
|
||||
echo = subprocess.Popen((['cat', '/dev/null']), stdout=subprocess.PIPE)
|
||||
ProcessUtilities.executioner(('sudo', 'crontab', '-u', website.externalApp, '-'), stdin=echo.stdout)
|
||||
echo.wait()
|
||||
echo.stdout.close()
|
||||
output = ProcessUtilities.outputExecutioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
|
||||
if "no crontab for" in output:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'Unable to initialise crontab file for user'}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
tempPath = "/home/cyberpanel/" + website.externalApp + str(randint(10000, 99999)) + ".cron.tmp"
|
||||
|
||||
finalCron = "%s %s %s %s %s %s" % (minute, hour, monthday, month, weekday, command)
|
||||
|
||||
with open(tempPath, "a") as file:
|
||||
file.write(output + finalCron + "\n")
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/cronUtil.py"
|
||||
execPath = execPath + " addNewCron --externalApp " + website.externalApp + " --finalCron '" + finalCron + "'"
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
output = ProcessUtilities.executioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, tempPath])
|
||||
|
||||
os.remove(tempPath)
|
||||
if output != 0:
|
||||
data_ret = {'addNewCron': 0, 'error_message': 'Incorrect Syntax cannot be accepted'}
|
||||
if output.find("1,") > -1:
|
||||
data_ret = {"addNewCron": 1,
|
||||
"user": website.externalApp,
|
||||
"cron": finalCron}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
dic = {'addNewCron': 0, 'error_message': output}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
data_ret = {"addNewCron": 1,
|
||||
"user": website.externalApp,
|
||||
"cron": finalCron}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
except BaseException, msg:
|
||||
print msg
|
||||
dic = {'addNewCron': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(dic)
|
||||
return HttpResponse(json_data)
|
||||
@@ -1363,7 +1252,7 @@ class WebsiteManager:
|
||||
execPath = execPath + " createAlias --masterDomain " + self.domain + " --aliasDomain " + aliasDomain + " --ssl " + str(
|
||||
ssl) + " --sslPath " + sslpath + " --administratorEmail " + admin.email + ' --websiteOwner ' + admin.userName
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
pass
|
||||
@@ -1405,10 +1294,9 @@ class WebsiteManager:
|
||||
## Create Configurations
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " issueAliasSSL --masterDomain " + self.domain + " --aliasDomain " + aliasDomain + " --sslPath " + sslpath + " --administratorEmail " + admin.email
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'sslStatus': 1, 'error_message': "None", "existsStatus": 0}
|
||||
@@ -1441,10 +1329,8 @@ class WebsiteManager:
|
||||
## Create Configurations
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " deleteAlias --masterDomain " + self.domain + " --aliasDomain " + aliasDomain
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'deleteAlias': 1, 'error_message': "None", "existsStatus": 0}
|
||||
@@ -1475,17 +1361,8 @@ class WebsiteManager:
|
||||
return ACLManager.loadErrorJson('changeOpenBasedir', 0)
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
|
||||
execPath = execPath + " changeOpenBasedir --virtualHostName '" + self.domain + "' --openBasedirValue " + openBasedirValue
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
pass
|
||||
else:
|
||||
data_ret = {'status': 0, 'changeOpenBasedir': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
output = ProcessUtilities.popenExecutioner(execPath)
|
||||
|
||||
data_ret = {'status': 1, 'changeOpenBasedir': 1, 'error_message': "None"}
|
||||
json_data = json.dumps(data_ret)
|
||||
@@ -1566,7 +1443,7 @@ class WebsiteManager:
|
||||
|
||||
if lastLine.find('[200]') > -1:
|
||||
command = 'sudo rm -f ' + statusFile
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
data_ret = {'abort': 1, 'installStatus': 1, 'installationProgress': "100",
|
||||
'currentStatus': 'Successfully Installed.'}
|
||||
json_data = json.dumps(data_ret)
|
||||
@@ -1802,7 +1679,7 @@ Host gitlab.com
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo cat /root/.ssh/git.pub'
|
||||
deploymentKey = ProcessUtilities.outputExecutioner(shlex.split(command)).strip('\n')
|
||||
deploymentKey = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
return render(request, 'websiteFunctions/setupGit.html',
|
||||
{'domainName': self.domain, 'deploymentKey': deploymentKey, 'installed': 0})
|
||||
|
||||
@@ -26,7 +26,7 @@ class pluginInstaller:
|
||||
def extractPlugin(pluginName):
|
||||
pathToPlugin = pluginName + '.zip'
|
||||
command = 'unzip ' + pathToPlugin + ' -d /usr/local/CyberCP'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
@staticmethod
|
||||
def upgradingSettingsFile(pluginName):
|
||||
@@ -65,7 +65,7 @@ class pluginInstaller:
|
||||
|
||||
pluginFile = pluginPath + '/' + pluginName
|
||||
command = 'touch ' + pluginFile
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
@staticmethod
|
||||
def addInterfaceLink(pluginName):
|
||||
@@ -87,15 +87,15 @@ class pluginInstaller:
|
||||
currentDir = os.getcwd()
|
||||
|
||||
command = "rm -rf /usr/local/lscp/cyberpanel/static"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
os.chdir('/usr/local/CyberCP')
|
||||
|
||||
command = "python manage.py collectstatic --noinput"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "mv /usr/local/CyberCP/static /usr/local/lscp/cyberpanel"
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
|
||||
os.chdir(currentDir)
|
||||
@@ -106,10 +106,10 @@ class pluginInstaller:
|
||||
|
||||
if os.path.exists(pluginHome + '/pre_install'):
|
||||
command = 'chmod +x ' + pluginHome + '/pre_install'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = pluginHome + '/pre_install'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
@staticmethod
|
||||
def postScript(pluginName):
|
||||
@@ -117,10 +117,10 @@ class pluginInstaller:
|
||||
|
||||
if os.path.exists(pluginHome + '/post_install'):
|
||||
command = 'chmod +x ' + pluginHome + '/post_install'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = pluginHome + '/post_install'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
|
||||
@staticmethod
|
||||
@@ -286,7 +286,7 @@ class pluginInstaller:
|
||||
@staticmethod
|
||||
def restartGunicorn():
|
||||
command = 'systemctl restart gunicorn.socket'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import subprocess
|
||||
import shlex
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
# Create your views here.
|
||||
|
||||
|
||||
@@ -139,7 +140,7 @@ def getLogsFromFile(request):
|
||||
|
||||
try:
|
||||
command = "sudo tail -50 " + fileName
|
||||
fewLinesOfLogFile = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
fewLinesOfLogFile = ProcessUtilities.outputExecutioner(command)
|
||||
status = {"status": 1, "logstatus": 1, "logsdata": fewLinesOfLogFile}
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
@@ -172,10 +173,9 @@ def clearLogFile(request):
|
||||
fileName = data['fileName']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/serverLogs.py"
|
||||
|
||||
execPath = execPath + " cleanLogFile --fileName " + fileName
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'cleanStatus': 1, 'error_message': "None"}
|
||||
|
||||
@@ -24,7 +24,7 @@ class ServerStatusUtil:
|
||||
@staticmethod
|
||||
def executioner(command, statusFile):
|
||||
try:
|
||||
res = ProcessUtilities.executioner(shlex.split(command), stdout=statusFile, stderr=statusFile)
|
||||
res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile)
|
||||
if res == 1:
|
||||
return 0
|
||||
else:
|
||||
@@ -94,7 +94,7 @@ class ServerStatusUtil:
|
||||
|
||||
try:
|
||||
command = 'chown -R lsadm:lsadm ' + confPath
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
subprocess.call(shlex.split(command))
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -172,7 +172,7 @@ class ServerStatusUtil:
|
||||
FNULL = open(os.devnull, 'w')
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
@@ -209,7 +209,7 @@ class ServerStatusUtil:
|
||||
FNULL = open(os.devnull, 'w')
|
||||
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
|
||||
cmd = shlex.split(command)
|
||||
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
|
||||
@@ -60,7 +60,7 @@ def litespeedStatus(request):
|
||||
else:
|
||||
loadedModules.append(items)
|
||||
|
||||
except subprocess.CalledProcessError, msg:
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||
return render(request, "serverStatus/litespeedStatus.html", {"processList": processList,
|
||||
"liteSpeedVersionStatus": "For some reaons not able to load version details, see CyberCP main log file.",
|
||||
@@ -143,6 +143,7 @@ def getFurtherDataFromLogFile(request):
|
||||
return ACLManager.loadErrorJson('logstatus', 0)
|
||||
|
||||
fewLinesOfLogFile = logging.CyberCPLogFileWriter.readLastNFiles(50, logging.CyberCPLogFileWriter.fileName)
|
||||
|
||||
fewLinesOfLogFile = str(fewLinesOfLogFile)
|
||||
status = {"logstatus": 1, "logsdata": fewLinesOfLogFile}
|
||||
final_json = json.dumps(status)
|
||||
@@ -193,7 +194,7 @@ def servicesStatus(request):
|
||||
mailStatus = []
|
||||
dockerStatus = []
|
||||
|
||||
processlist = ProcessUtilities.outputExecutioner(['ps', '-A'])
|
||||
processlist = subprocess.check_output(['ps', '-A'])
|
||||
|
||||
def getServiceStats(service):
|
||||
if service in processlist:
|
||||
@@ -308,20 +309,8 @@ def servicesAction(request):
|
||||
service = 'pure-ftpd'
|
||||
|
||||
command = 'sudo systemctl %s %s' % (action, service)
|
||||
cmd = shlex.split(command)
|
||||
res = ProcessUtilities.executioner(cmd)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
result = p.communicate()[0]
|
||||
|
||||
if res != 0:
|
||||
final_dic = {'serviceAction': 0, "error_message": "Error while performing action"}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
final_dic = {'serviceAction': 1, "error_message": 0}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException, msg:
|
||||
final_dic = {'serviceAction': 0, 'error_message': str(msg)}
|
||||
@@ -349,7 +338,7 @@ def switchTOLSWS(request):
|
||||
execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/serverStatus/serverStatusUtil.py"
|
||||
execPath = execPath + " switchTOLSWS --licenseKey " + data['licenseKey']
|
||||
|
||||
subprocess.Popen(shlex.split(execPath))
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1, 'error_message': "None", }
|
||||
@@ -366,7 +355,7 @@ def switchTOLSWSStatus(request):
|
||||
try:
|
||||
|
||||
command = 'sudo cat ' + serverStatusUtil.ServerStatusUtil.lswsInstallStatusPath
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if output.find('[404]') > -1:
|
||||
data_ret = {'abort': 1, 'requestStatus': output, 'installed': 0}
|
||||
@@ -400,10 +389,10 @@ def licenseStatus(request):
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
command = 'sudo cat /usr/local/lsws/conf/serial.no'
|
||||
serial = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
serial = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
command = 'sudo /usr/local/lsws/bin/lshttpd -V'
|
||||
expiration = ProcessUtilities.outputExecutioner(shlex.split(command))
|
||||
expiration = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
final_dic = {'status': 1, "erroMessage": 0, 'lsSerial': serial, 'lsexpiration': expiration}
|
||||
final_json = json.dumps(final_dic)
|
||||
@@ -435,7 +424,7 @@ def changeLicense(request):
|
||||
newKey = data['newKey']
|
||||
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel /usr/local/lsws/conf'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
serialPath = '/usr/local/lsws/conf/serial.no'
|
||||
serialFile = open(serialPath, 'w')
|
||||
@@ -443,13 +432,13 @@ def changeLicense(request):
|
||||
serialFile.close()
|
||||
|
||||
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo /usr/local/lsws/bin/lshttpd -r'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'sudo /usr/local/lsws/bin/lswsctrl restart'
|
||||
ProcessUtilities.executioner(shlex.split(command))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
final_dic = {'status': 1, "erroMessage": 'None'}
|
||||
final_json = json.dumps(final_dic)
|
||||
@@ -488,7 +477,7 @@ def topProcessesStatus(request):
|
||||
try:
|
||||
|
||||
with open("/home/cyberpanel/top", "w") as outfile:
|
||||
ProcessUtilities.executioner("sudo top -n1 -b", shell=True, stdout=outfile)
|
||||
subprocess.call("top -n1 -b", shell=True, stdout=outfile)
|
||||
|
||||
data = open('/home/cyberpanel/top', 'r').readlines()
|
||||
|
||||
@@ -574,7 +563,7 @@ def topProcessesStatus(request):
|
||||
## CPU Details
|
||||
|
||||
command = 'sudo cat /proc/cpuinfo'
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
|
||||
output = subprocess.check_output(shlex.split(command)).splitlines()
|
||||
|
||||
import psutil
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
/* Java script code to create database */
|
||||
app.controller('createDatabase', function($scope,$http) {
|
||||
app.controller('createDatabase', function ($scope, $http) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = true;
|
||||
@@ -14,103 +14,99 @@ app.controller('createDatabase', function($scope,$http) {
|
||||
$scope.generatedPasswordView = true;
|
||||
|
||||
|
||||
$scope.showDetailsBoxes = function(){
|
||||
$scope.showDetailsBoxes = function () {
|
||||
$scope.dbDetails = false;
|
||||
};
|
||||
|
||||
$scope.createDatabase = function(){
|
||||
$scope.createDatabase = function () {
|
||||
|
||||
$scope.createDatabaseLoading = false;
|
||||
$scope.createDatabaseLoading = false;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
var dbName = $scope.dbName;
|
||||
var dbUsername = $scope.dbUsername;
|
||||
var dbPassword = $scope.dbPassword;
|
||||
var webUserName = "";
|
||||
|
||||
// getting website username
|
||||
|
||||
webUserName = databaseWebsite.replace(/-/g, '');
|
||||
webUserName = webUserName.split(".")[0];
|
||||
|
||||
if (webUserName.length > 5) {
|
||||
webUserName = webUserName.substring(0, 4);
|
||||
}
|
||||
|
||||
var url = "/dataBases/submitDBCreation";
|
||||
|
||||
|
||||
var data = {
|
||||
webUserName: webUserName,
|
||||
databaseWebsite: databaseWebsite,
|
||||
dbName: dbName,
|
||||
dbUsername: dbUsername,
|
||||
dbPassword: dbPassword
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.createDBStatus == 1) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.databaseCreated = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
var dbName = $scope.dbName;
|
||||
var dbUsername = $scope.dbUsername;
|
||||
var dbPassword = $scope.dbPassword;
|
||||
var webUserName = "";
|
||||
}
|
||||
|
||||
// getting website username
|
||||
|
||||
webUserName = databaseWebsite.replace(/-/g, '');
|
||||
webUserName = webUserName.split(".")[0];
|
||||
|
||||
if(webUserName.length > 5){
|
||||
webUserName = webUserName.substring(0,4);
|
||||
}
|
||||
|
||||
var url = "/dataBases/submitDBCreation";
|
||||
else {
|
||||
|
||||
|
||||
var data = {
|
||||
webUserName:webUserName,
|
||||
databaseWebsite:databaseWebsite,
|
||||
dbName:dbName,
|
||||
dbUsername:dbUsername,
|
||||
dbPassword:dbPassword
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = false;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
}
|
||||
|
||||
|
||||
if(response.data.createDBStatus == 1){
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = false;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = true;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = true;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -122,7 +118,7 @@ app.controller('createDatabase', function($scope,$http) {
|
||||
|
||||
/* Java script code to delete database */
|
||||
|
||||
app.controller('deleteDatabase', function($scope,$http) {
|
||||
app.controller('deleteDatabase', function ($scope, $http) {
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
@@ -131,153 +127,147 @@ app.controller('deleteDatabase', function($scope,$http) {
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
$scope.fetchDatabases = function(){
|
||||
$scope.fetchDatabases = function () {
|
||||
|
||||
$scope.deleteDatabaseLoading = false;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.deleteDatabaseLoading = false;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
|
||||
var url = "/dataBases/fetchDatabases";
|
||||
|
||||
|
||||
var data = {
|
||||
databaseWebsite: databaseWebsite,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.fetchStatus == 1) {
|
||||
|
||||
|
||||
$scope.dbnames = JSON.parse(response.data.data);
|
||||
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = false;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
}
|
||||
|
||||
var url = "/dataBases/fetchDatabases";
|
||||
else {
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var data = {
|
||||
databaseWebsite:databaseWebsite,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
}
|
||||
|
||||
|
||||
if(response.data.fetchStatus == 1){
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
$scope.dbnames = JSON.parse(response.data.data);
|
||||
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = false;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.deleteDatabase = function(){
|
||||
$scope.deleteDatabase = function () {
|
||||
|
||||
$scope.deleteDatabaseLoading = false;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.deleteDatabaseLoading = false;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
|
||||
var url = "/dataBases/submitDatabaseDeletion";
|
||||
|
||||
|
||||
var data = {
|
||||
dbName: $scope.selectedDB,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.deleteStatus == 1) {
|
||||
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = false;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
|
||||
var url = "/dataBases/submitDatabaseDeletion";
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
var data = {
|
||||
dbName:$scope.selectedDB,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
}
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
if(response.data.deleteStatus == 1){
|
||||
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = false;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = true;
|
||||
$scope.databaseDeleted = true;
|
||||
$scope.couldNotConnect = false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -289,7 +279,7 @@ app.controller('deleteDatabase', function($scope,$http) {
|
||||
/* Java script code to list databases */
|
||||
|
||||
|
||||
app.controller('listDBs', function($scope,$http) {
|
||||
app.controller('listDBs', function ($scope, $http) {
|
||||
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
@@ -303,161 +293,161 @@ app.controller('listDBs', function($scope,$http) {
|
||||
var globalDBUsername = "";
|
||||
|
||||
$scope.fetchDBs = function () {
|
||||
populateCurrentRecords();
|
||||
populateCurrentRecords();
|
||||
};
|
||||
|
||||
$scope.changePassword = function (dbUsername) {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = false;
|
||||
$scope.changePasswordBox = false;
|
||||
$scope.notificationsBox = true;
|
||||
$scope.dbUsername = dbUsername;
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = false;
|
||||
$scope.changePasswordBox = false;
|
||||
$scope.notificationsBox = true;
|
||||
$scope.dbUsername = dbUsername;
|
||||
|
||||
|
||||
globalDBUsername = dbUsername;
|
||||
globalDBUsername = dbUsername;
|
||||
|
||||
};
|
||||
|
||||
$scope.changePasswordBtn = function () {
|
||||
|
||||
$scope.dbLoading = false;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.dbLoading = false;
|
||||
$scope.passwordChanged = true;
|
||||
|
||||
|
||||
url = "/dataBases/changePassword";
|
||||
url = "/dataBases/changePassword";
|
||||
|
||||
var data = {
|
||||
dbUserName:globalDBUsername,
|
||||
dbPassword: $scope.dbPassword,
|
||||
};
|
||||
var data = {
|
||||
dbUserName: globalDBUsername,
|
||||
dbPassword: $scope.dbPassword,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.changePasswordStatus == 1){
|
||||
$scope.notificationsBox = false;
|
||||
$scope.passwordChanged = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
if (response.data.changePasswordStatus == 1) {
|
||||
$scope.notificationsBox = false;
|
||||
$scope.passwordChanged = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
|
||||
}
|
||||
else{
|
||||
$scope.notificationsBox = false;
|
||||
$scope.canNotChangePassword = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.canNotChangePassword = false;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$scope.notificationsBox = false;
|
||||
$scope.canNotChangePassword = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.canNotChangePassword = false;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.notificationsBox = false;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.dbLoading = true;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.notificationsBox = false;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.dbLoading = true;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
function populateCurrentRecords(){
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = false;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
};
|
||||
|
||||
var selectedDomain = $scope.selectedDomain;
|
||||
function populateCurrentRecords() {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = false;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
|
||||
url = "/dataBases/fetchDatabases";
|
||||
var selectedDomain = $scope.selectedDomain;
|
||||
|
||||
var data = {
|
||||
databaseWebsite:selectedDomain,
|
||||
};
|
||||
url = "/dataBases/fetchDatabases";
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
var data = {
|
||||
databaseWebsite: selectedDomain,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.fetchStatus == 1){
|
||||
if (response.data.fetchStatus == 1) {
|
||||
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
|
||||
|
||||
$scope.recordsFetched = false;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = false;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = false;
|
||||
$scope.recordsFetched = false;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = false;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = false;
|
||||
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
|
||||
}
|
||||
else{
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
}
|
||||
else {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
}
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.dbLoading = true;
|
||||
$scope.dbAccounts = true;
|
||||
$scope.changePasswordBox = true;
|
||||
$scope.notificationsBox = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
$scope.generatedPasswordView = true;
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
$scope.generatedPasswordView = false;
|
||||
$scope.dbPassword = randomPassword(12);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
@@ -467,4 +457,40 @@ app.controller('listDBs', function($scope,$http) {
|
||||
});
|
||||
|
||||
|
||||
/* Java script code to list database ends here */
|
||||
/* Java script code to list database ends here */
|
||||
|
||||
|
||||
app.controller('phpMyAdmin', function ($scope, $http, $window) {
|
||||
|
||||
function setupPHPMYAdminSession() {
|
||||
|
||||
url = "/dataBases/setupPHPMYAdminSession";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.status === 1) {
|
||||
$window.location.href = '/phpmyadmin';
|
||||
}
|
||||
else {}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {}
|
||||
|
||||
}
|
||||
setupPHPMYAdminSession();
|
||||
|
||||
});
|
||||
@@ -118,10 +118,8 @@ class tuningManager:
|
||||
gzipCompression = data['gzipCompression']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py"
|
||||
|
||||
execPath = execPath + " saveTuningDetails --maxConn " + maxConn + " --maxSSLConn " + maxSSLConn + " --connTime " + connTime + " --keepAlive " + keepAlive + " --inMemCache '" + inMemCache + "' --gzipCompression " + gzipCompression
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'fetch_status': 1, 'error_message': "None", 'tuneStatus': 1}
|
||||
@@ -163,10 +161,9 @@ class tuningManager:
|
||||
persistConn = data['persistConn']
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/tuning.py"
|
||||
|
||||
execPath = execPath + " tunePHP --virtualHost " + domainSelection + " --initTimeout " + initTimeout + " --maxConns " + maxConns + " --memSoftLimit " + memSoftLimit + " --memHardLimit '" + memHardLimit + "' --procSoftLimit " + procSoftLimit + " --procHardLimit " + procHardLimit + " --persistConn " + persistConn
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'tuneStatus': 1, 'fetch_status': 0, 'error_message': "None"}
|
||||
|
||||
Reference in New Issue
Block a user