centralized execution ph1

This commit is contained in:
usmannasir
2019-03-21 23:26:42 +05:00
parent b37907af85
commit 520bd2b797
57 changed files with 813 additions and 679 deletions

View File

@@ -21,6 +21,7 @@ from plogical.acl import ACLManager
from firewall.models import FirewallRules
from s3Backups.s3Backups import S3Backups
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
from plogical.processUtilities import ProcessUtilities
# Create your views here.
@@ -120,8 +121,6 @@ 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)
@@ -260,7 +259,7 @@ def fetchSSHkey(request):
pubKey = os.path.join("/root",".ssh",'cyberpanel.pub')
execPath = "sudo cat " + pubKey
data = subprocess.check_output(shlex.split(execPath))
data = ProcessUtilities.outputExecutioner(execPath)
data_ret = {
'status': 1,
@@ -313,7 +312,7 @@ def remoteTransfer(request):
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py"
execPath = execPath + " remoteTransfer --ipAddress " + ipAddress + " --dir " + dir + " --accountsToTransfer " + path
subprocess.Popen(shlex.split(execPath))
ProcessUtilities.popenExecutioner(execPath)
return HttpResponse(json.dumps({"transferStatus": 1, "dir": dir}))
@@ -381,8 +380,8 @@ def FetchRemoteTransferStatus(request):
dir = "/home/backup/transfer-"+str(data['dir'])+"/backup_log"
try:
command = "sudo cat "+ dir
status = subprocess.check_output(shlex.split(command))
execPath = "sudo cat "+ dir
status = ProcessUtilities.outputExecutioner(execPath)
admin = Administrator.objects.get(userName=username)
if hashPassword.check_password(admin.password, password):
@@ -418,14 +417,14 @@ def cancelRemoteTransfer(request):
path = dir + "/pid"
command = "sudo cat " + path
pid = subprocess.check_output(shlex.split(command))
execPath = "sudo cat " + path
pid = ProcessUtilities.outputExecutioner(execPath)
command = "sudo kill -KILL " + pid
subprocess.call(shlex.split(command))
execPath = "sudo kill -KILL " + pid
ProcessUtilities.executioner(execPath)
command = "sudo rm -rf " + dir
subprocess.call(shlex.split(command))
execPath = "sudo rm -rf " + dir
ProcessUtilities.executioner(execPath)
data = {'cancelStatus': 1, 'error_message': "None"}
json_data = json.dumps(data)
@@ -525,9 +524,8 @@ def putSSHkey(request):
##
command = "sudo chmod g-w /home/cyberpanel"
cmd = shlex.split(command)
res = subprocess.call(cmd)
execPath = "sudo chmod g-w /home/cyberpanel"
ProcessUtilities.executioner(execPath)
os.chmod(keyPath,0700)
os.chmod(authorized_keys, 0600)
@@ -590,30 +588,6 @@ 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()

View File

@@ -20,6 +20,7 @@ from random import randint
import time
import plogical.backupUtilities as backupUtil
import requests
from plogical.processUtilities import ProcessUtilities
class BackupManager:
def __init__(self, domain = None, childDomain = None):
@@ -61,7 +62,7 @@ class BackupManager:
ext = ".tar.gz"
command = 'sudo chown -R cyberpanel:cyberpanel ' + path
ACLManager.executeCall(command)
ProcessUtilities.executioner(command)
files = os.listdir(path)
for filename in files:
@@ -144,7 +145,7 @@ class BackupManager:
execPath = execPath + " submitBackupCreation --tempStoragePath " + tempStoragePath + " --backupName " \
+ backupName + " --backupPath " + backupPath + ' --backupDomain ' + backupDomain
subprocess.Popen(shlex.split(execPath))
ProcessUtilities.popenExecutioner(execPath)
time.sleep(2)
@@ -168,16 +169,16 @@ class BackupManager:
## read file name
try:
command = "sudo cat " + backupFileNamePath
fileName = subprocess.check_output(shlex.split(command))
execPath = "sudo cat " + backupFileNamePath
fileName = ProcessUtilities.outputExecutioner(execPath)
except:
fileName = "Fetching.."
## file name read ends
if os.path.exists(status):
command = "sudo cat " + status
status = subprocess.check_output(shlex.split(command))
execPath = "sudo cat " + status
status = ProcessUtilities.outputExecutioner(execPath)
if status.find("Completed") > -1:
@@ -201,14 +202,14 @@ class BackupManager:
### Removing Files
command = 'sudo rm -f ' + status
subprocess.call(shlex.split(command))
execPath = 'sudo rm -f ' + status
ProcessUtilities.executioner(execPath)
command = 'sudo rm -f ' + backupFileNamePath
subprocess.call(shlex.split(command))
execPath = 'sudo rm -f ' + backupFileNamePath
ProcessUtilities.executioner(execPath)
command = 'sudo rm -f ' + pid
subprocess.call(shlex.split(command))
execPath = 'sudo rm -f ' + pid
ProcessUtilities.executioner(execPath)
final_json = json.dumps(
{'backupStatus': 1, 'error_message': "None", "status": status, "abort": 1,
@@ -218,14 +219,14 @@ class BackupManager:
elif status.find("[5009]") > -1:
## removing status file, so that backup can re-run
try:
command = 'sudo rm -f ' + status
subprocess.call(shlex.split(command))
execPath = 'sudo rm -f ' + status
ProcessUtilities.executioner(execPath)
command = 'sudo rm -f ' + backupFileNamePath
subprocess.call(shlex.split(command))
execPath = 'sudo rm -f ' + backupFileNamePath
ProcessUtilities.executioner(execPath)
command = 'sudo rm -f ' + pid
subprocess.call(shlex.split(command))
execPath = 'sudo rm -f ' + pid
ProcessUtilities.executioner(execPath)
backupObs = Backups.objects.filter(fileName=fileName)
for items in backupObs:
@@ -260,10 +261,9 @@ class BackupManager:
fileName = data['fileName']
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " cancelBackupCreation --backupCancellationDomain " + backupCancellationDomain + " --fileName " + fileName
subprocess.call(shlex.split(execPath))
ProcessUtilities.executioner(execPath)
try:
backupOb = Backups.objects.get(fileName=fileName)
@@ -287,8 +287,8 @@ class BackupManager:
domainName = backup.website.domain
path = "/home/" + domainName + "/backup/" + backup.fileName + ".tar.gz"
command = 'sudo rm -f ' + path
ACLManager.executeCall(command)
execPath = 'sudo rm -f ' + path
ProcessUtilities.executioner(execPath)
backup.delete()
@@ -312,7 +312,7 @@ class BackupManager:
execPath = "sudo nice -n 10 python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " submitRestore --backupFile " + backupFile + " --dir " + dir
subprocess.Popen(shlex.split(execPath))
ProcessUtilities.popenExecutioner(execPath)
time.sleep(4)
final_dic = {'restoreStatus': 1, 'error_message': "None"}
@@ -340,12 +340,12 @@ class BackupManager:
if os.path.exists(path):
try:
execPath = "sudo cat " + path + "/status"
status = subprocess.check_output(shlex.split(execPath))
status = ProcessUtilities.outputExecutioner(execPath)
if status.find("Done") > -1:
command = "sudo rm -rf " + path
subprocess.call(shlex.split(command))
execPath = "sudo rm -rf " + path
ProcessUtilities.executioner(execPath)
final_json = json.dumps(
{'restoreStatus': 1, 'error_message': "None", "status": status, 'abort': 1,
@@ -353,8 +353,8 @@ class BackupManager:
return HttpResponse(final_json)
elif status.find("[5009]") > -1:
## removing temporarily generated files while restoring
command = "sudo rm -rf " + path
subprocess.call(shlex.split(command))
execPath = "sudo rm -rf " + path
ProcessUtilities.executioner(execPath)
final_json = json.dumps({'restoreStatus': 1, 'error_message': "None",
"status": status, 'abort': 1, 'alreadyRunning': 0,
'running': 'Error'})
@@ -428,7 +428,7 @@ class BackupManager:
execPath = execPath + " submitDestinationCreation --ipAddress " + ipAddress + " --password " \
+ password + " --port " + port
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(execPath)
if output.find('1,') > -1:
try:
@@ -506,7 +506,7 @@ class BackupManager:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/backupUtilities.py"
execPath = execPath + " getConnectionStatus --ipAddress " + ipAddress
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(execPath)
if output.find('1,') > -1:
final_dic = {'connStatus': 1, 'error_message': "None"}
@@ -664,9 +664,8 @@ class BackupManager:
virtualHostUtilities.leaveControl(path)
command = "sudo systemctl restart crond"
subprocess.call(shlex.split(command))
execPath = "sudo systemctl restart crond"
ProcessUtilities.executioner(execPath)
destination = dest.objects.get(destLoc=backupDest)
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
@@ -686,9 +685,9 @@ class BackupManager:
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(dest=destination, frequency=backupFreq)
@@ -708,9 +707,9 @@ class BackupManager:
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(dest=destination, frequency=backupFreq)
@@ -730,9 +729,8 @@ class BackupManager:
virtualHostUtilities.leaveControl(path)
command = "sudo systemctl restart crond"
subprocess.call(shlex.split(command))
execPath = "sudo systemctl restart crond"
ProcessUtilities.executioner(execPath)
destination = dest.objects.get(destLoc=backupDest)
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
@@ -752,9 +750,8 @@ class BackupManager:
virtualHostUtilities.leaveControl(path)
command = "sudo systemctl restart crond"
subprocess.call(shlex.split(command))
execPath = "sudo systemctl restart crond"
ProcessUtilities.executioner(execPath)
destination = dest.objects.get(destLoc=backupDest)
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
@@ -774,9 +771,8 @@ class BackupManager:
virtualHostUtilities.leaveControl(path)
command = "sudo systemctl restart crond"
subprocess.call(shlex.split(command))
execPath = "sudo systemctl restart crond"
ProcessUtilities.executioner(execPath)
destination = dest.objects.get(destLoc=backupDest)
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
@@ -796,9 +792,9 @@ class BackupManager:
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(dest=destination, frequency=backupFreq)
@@ -818,9 +814,9 @@ class BackupManager:
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(dest=destination, frequency=backupFreq)
@@ -862,9 +858,9 @@ class BackupManager:
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)
@@ -890,9 +886,9 @@ class BackupManager:
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)
@@ -918,9 +914,9 @@ class BackupManager:
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)
@@ -946,9 +942,9 @@ class BackupManager:
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)
@@ -1054,7 +1050,7 @@ class BackupManager:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/remoteTransferUtilities.py"
execPath = execPath + " writeAuthKey --pathToKey " + pathToKey
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(execPath)
if output.find("1,None") > -1:
pass
@@ -1129,8 +1125,8 @@ class BackupManager:
localBackupDir = os.path.join("/home", "backup")
if not os.path.exists(localBackupDir):
command = "sudo mkdir " + localBackupDir
subprocess.call(shlex.split(command))
execPath = "sudo mkdir " + localBackupDir
ProcessUtilities.executioner(execPath)
## create local directory that will host backups
@@ -1138,8 +1134,8 @@ class BackupManager:
## making local storage directory for backups
command = "sudo mkdir " + localStoragePath
subprocess.call(shlex.split(command))
execPath = "sudo mkdir " + localStoragePath
ProcessUtilities.executioner(execPath)
final_json = json.dumps(
{'remoteTransferStatus': 1, 'error_message': "None", "dir": data['dir']})
@@ -1223,7 +1219,7 @@ class BackupManager:
execPath = execPath + " remoteBackupRestore --backupDirComplete " + backupDirComplete + " --backupDir " + str(
backupDir)
subprocess.Popen(shlex.split(execPath))
ProcessUtilities.popenExecutioner(execPath)
time.sleep(3)
@@ -1253,18 +1249,18 @@ class BackupManager:
time.sleep(3)
if os.path.isfile(backupLogPath):
command = "sudo cat " + backupLogPath
status = subprocess.check_output(shlex.split(command))
execPath = "sudo cat " + backupLogPath
status = ProcessUtilities.outputExecutioner(execPath)
if status.find("completed[success]") > -1:
command = "sudo rm -rf " + removalPath
# subprocess.call(shlex.split(command))
# ProcessUtilities.executioner(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
# subprocess.call(shlex.split(command))
# ProcessUtilities.executioner(shlex.split(command))
data = {'remoteTransferStatus': 0, 'error_message': status,
"status": "None", "complete": 0}
json_data = json.dumps(data)
@@ -1311,14 +1307,14 @@ class BackupManager:
path = "/home/backup/transfer-" + str(dir)
pathpid = path + "/pid"
command = "sudo cat " + pathpid
pid = subprocess.check_output(shlex.split(command))
execPath = "sudo cat " + pathpid
pid = ProcessUtilities.outputExecutioner(execPath)
command = "sudo kill -KILL " + pid
subprocess.call(shlex.split(command))
execPath = "sudo kill -KILL " + pid
ProcessUtilities.executioner(execPath)
command = "sudo rm -rf " + path
subprocess.call(shlex.split(command))
execPath = "sudo rm -rf " + path
ProcessUtilities.executioner(execPath)
data = {'cancelStatus': 1, 'error_message': "None"}
json_data = json.dumps(data)

View File

@@ -15,6 +15,7 @@ import shlex
import os
import plogical.CyberCPLogFileWriter as logging
from plogical.acl import ACLManager
from plogical.processUtilities import ProcessUtilities
# Create your views here.
@@ -110,7 +111,7 @@ def upgrade(request):
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
vers = version.objects.get(pk=1)

View File

@@ -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 = subprocess.check_output(["tail", "-n",str(numberOfLines),fileName])
lastFewLines = ProcessUtilities.outputExecutioner(["tail", "-n",str(numberOfLines),fileName])
return lastFewLines

View File

@@ -108,7 +108,7 @@ class CloudManager:
'domainName'] + " --bandwidth " + str(
website.package.bandwidth)
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(execPath)
bwData = output.split(",")
except BaseException:
bwData = [0, 0]
@@ -319,8 +319,8 @@ class CloudManager:
lastLine = statusData[-1]
if lastLine.find('[200]') > -1:
command = 'sudo rm -f ' + statusFile
subprocess.call(shlex.split(command))
execPath = 'sudo rm -f ' + statusFile
ProcessUtilities.outputExecutioner(execPath)
data_ret = {'status': 1, 'abort': 1, 'installationProgress': "100", 'currentStatus': lastLine}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -794,7 +794,7 @@ class CloudManager:
try:
pubKey = os.path.join("/root", ".ssh", 'cyberpanel.pub')
execPath = "sudo cat " + pubKey
data = subprocess.check_output(shlex.split(execPath))
data = ProcessUtilities.outputExecutioner(execPath)
data_ret = {
'status': 1,
@@ -1053,9 +1053,11 @@ class CloudManager:
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
finalData['conf'] = subprocess.check_output(shlex.split('sudo cat /etc/my.cnf'))
execPath = 'sudo cat /etc/my.cnf'
finalData['conf'] = ProcessUtilities.outputExecutioner(execPath)
else:
finalData['conf'] = subprocess.check_output(shlex.split('sudo cat /etc/mysql/my.cnf'))
execPath = 'sudo cat /etc/mysql/my.cnf'
finalData['conf'] = ProcessUtilities.outputExecutioner(execPath)
finalData['status'] = 1

View File

@@ -162,7 +162,7 @@ def saveWebsiteLimits(request):
cgrules = '/etc/cgrules.conf'
enforceString = '{} cpu,memory,blkio,net_cls {}/\n'.format(website.externalApp, website.externalApp)
cgrulesData = subprocess.check_output(shlex.split('sudo cat /etc/cgrules.conf')).splitlines()
cgrulesData = ProcessUtilities.outputExecutioner(shlex.split('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 = subprocess.check_output(shlex.split('sudo cat /etc/cgrules.conf')).splitlines()
cgrulesData = ProcessUtilities.outputExecutioner(shlex.split('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(subprocess.check_output(command, shell=True))
output = str(ProcessUtilities.outputExecutioner(command, shell=True))
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 = subprocess.check_output(command, shell=True).splitlines()
output = ProcessUtilities.outputExecutioner(command, shell=True).splitlines()
readCurrent = output[0].split(' ')[2]
writeCurrent = output[1].split(' ')[2]
@@ -333,7 +333,7 @@ def getUsageData(request):
finalData['writeRate'] = 0
except:
command = "sudo top -b -n 1 -u " + website.externalApp + " | awk 'NR>7 { sum += $9; } END { print sum; }'"
output = str(subprocess.check_output(command, shell=True))
output = str(ProcessUtilities.outputExecutioner(command, shell=True))
finalData = {}
if len(output) == 0:

View File

@@ -14,6 +14,7 @@ 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
class DatabaseManager:
@@ -174,7 +175,7 @@ class DatabaseManager:
command = 'sudo mysql -u root -p' + password + ' -e "' + passwordCMD + '"'
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
data_ret = {'status': 0, 'changePasswordStatus': 0,'error_message': "Please see CyberPanel main log file."}

View File

@@ -64,7 +64,7 @@ class ContainerManager(multi.Thread):
@staticmethod
def executioner(command, statusFile):
try:
res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile)
res = ProcessUtilities.executioner(shlex.split(command), stdout=statusFile, stderr=statusFile)
if res == 1:
return 0
else:

View File

@@ -12,6 +12,7 @@ import socket, smtplib
import DNS
from random import randint
import subprocess, shlex
from plogical.processUtilities import ProcessUtilities
class emailMarketing(multi.Thread):
@@ -212,7 +213,7 @@ class emailMarketing(multi.Thread):
messageFile.close()
command = "sudo sed -i 's/{{ unsubscribeCheck }}/" + removalLink + "/g' " + tempPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
messageFile = open(tempPath, 'r')
finalMessage = messageFile.read()

View File

@@ -54,7 +54,7 @@ def fetchPolicyServerStatus(request):
if request.method == 'POST':
command = 'sudo cat /etc/postfix/main.cf'
output = subprocess.check_output(shlex.split(command)).split('\n')
output = ProcessUtilities.outputExecutioner(shlex.split(command)).split('\n')
installCheck = 0
@@ -107,7 +107,7 @@ def savePolicyServerStatus(request):
execPath = execPath + " savePolicyServerStatus --install " + install
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'status': 1, 'error_message': "None"}
@@ -148,7 +148,7 @@ def listDomains(request):
## Check if Policy Server is installed.
command = 'sudo cat /etc/postfix/main.cf'
output = subprocess.check_output(shlex.split(command)).split('\n')
output = ProcessUtilities.outputExecutioner(shlex.split(command)).split('\n')
installCheck = 0
@@ -806,7 +806,7 @@ def installStatusSpamAssassin(request):
if request.method == 'POST':
command = "sudo cat " + mailUtilities.spamassassinInstallLogPath
installStatus = subprocess.check_output(shlex.split(command))
installStatus = ProcessUtilities.outputExecutioner(shlex.split(command))
if installStatus.find("[200]")>-1:
@@ -814,7 +814,7 @@ def installStatusSpamAssassin(request):
execPath = execPath + " configureSpamAssassin"
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
pass
@@ -884,7 +884,7 @@ def fetchSpamAssassinSettings(request):
command = "sudo cat " + confPath
data = subprocess.check_output(shlex.split(command)).splitlines()
data = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
for items in data:
if items.find('report_safe ') > -1:
@@ -987,7 +987,7 @@ def saveSpamAssassinConfigurations(request):
execPath = execPath + " saveSpamAssassinConfigs --tempConfigPath " + tempConfigPath
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'saveStatus': 1, 'error_message': "None"}

View File

@@ -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 = subprocess.check_output(shlex.split(command)).splitlines()
output = ProcessUtilities.outputExecutioner(shlex.split(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 = subprocess.check_output(shlex.split(command)).splitlines()
output = ProcessUtilities.outputExecutioner(shlex.split(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'] = subprocess.check_output(shlex.split(command))
finalData['fileContents'] = ProcessUtilities.outputExecutioner(shlex.split(command))
json_data = json.dumps(finalData)
return HttpResponse(json_data)

View File

@@ -54,10 +54,10 @@ def changePermissions(request):
externalApp = website.externalApp
command = "sudo chown -R " + externalApp + ":" + externalApp +" /home/"+domainName
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "sudo chown -R lscpd:lscpd /home/" + domainName+"/logs"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
data_ret = {'permissionsChanged': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)

View File

@@ -163,7 +163,7 @@ class FirewallManager:
command = 'sudo firewall-cmd --reload'
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 0:
final_dic = {'reload_status': 1, 'error_message': "None"}
@@ -194,7 +194,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 0:
final_dic = {'start_status': 1, 'error_message': "None"}
@@ -223,7 +223,7 @@ class FirewallManager:
command = 'sudo systemctl stop firewalld'
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 0:
final_dic = {'stop_status': 1, 'error_message': "None"}
@@ -252,7 +252,7 @@ class FirewallManager:
command = 'sudo systemctl status firewalld'
status = subprocess.check_output(shlex.split(command))
status = ProcessUtilities.outputExecutioner(shlex.split(command))
if status.find("active") > -1:
final_dic = {'status': 1, 'error_message': "none", 'firewallStatus': 1}
@@ -301,7 +301,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
pathToSSH = "/etc/ssh/sshd_config"
@@ -324,7 +324,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
final_dic = {'status': 1, 'permitRootLogin': permitRootLogin, 'sshPort': sshPort}
final_json = json.dumps(final_dic)
@@ -337,7 +337,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
pathToKeyFile = "/root/.ssh/authorized_keys"
@@ -378,7 +378,7 @@ class FirewallManager:
command = 'sudo chown -R root:root /root'
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json)
@@ -406,7 +406,7 @@ class FirewallManager:
command = 'sudo semanage port -a -t ssh_port_t -p tcp ' + sshPort
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
FirewallUtilities.addRule('tcp', sshPort, "0.0.0.0/0")
@@ -428,7 +428,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
##
@@ -461,7 +461,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
## changin back permissions
@@ -469,7 +469,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
##
@@ -499,7 +499,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
##
@@ -524,7 +524,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
##
@@ -554,7 +554,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
##
@@ -597,7 +597,7 @@ class FirewallManager:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
##
@@ -624,7 +624,7 @@ class FirewallManager:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath
httpdConfig = subprocess.check_output(shlex.split(command)).splitlines()
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
modSecInstalled = 0
@@ -669,7 +669,7 @@ class FirewallManager:
execPath = execPath + " installModSecConfigs"
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
pass
@@ -738,7 +738,7 @@ class FirewallManager:
if os.path.exists(modSecPath):
command = "sudo cat " + confPath
data = subprocess.check_output(shlex.split(command)).splitlines()
data = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
for items in data:
@@ -803,7 +803,7 @@ class FirewallManager:
command = "sudo cat " + confPath
data = subprocess.check_output(shlex.split(command)).splitlines()
data = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
for items in data:
if items.find('SecAuditEngine ') > -1:
@@ -917,7 +917,7 @@ class FirewallManager:
execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
@@ -973,7 +973,7 @@ class FirewallManager:
execPath = execPath + " saveModSecConfigs --tempConfigPath " + tempConfigPath
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
@@ -1004,7 +1004,7 @@ class FirewallManager:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath
httpdConfig = subprocess.check_output(shlex.split(command)).splitlines()
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
modSecInstalled = 0
@@ -1034,7 +1034,7 @@ class FirewallManager:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath
httpdConfig = subprocess.check_output(shlex.split(command)).splitlines()
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
modSecInstalled = 0
@@ -1047,7 +1047,7 @@ class FirewallManager:
if modSecInstalled:
command = "sudo cat " + rulesPath
currentModSecRules = subprocess.check_output(shlex.split(command))
currentModSecRules = ProcessUtilities.outputExecutioner(shlex.split(command))
final_dic = {'modSecInstalled': 1,
'currentModSecRules': currentModSecRules}
@@ -1063,7 +1063,7 @@ class FirewallManager:
rulesPath = os.path.join(virtualHostUtilities.Server_root + "/conf/rules.conf")
command = "sudo cat " + rulesPath
currentModSecRules = subprocess.check_output(shlex.split(command))
currentModSecRules = ProcessUtilities.outputExecutioner(shlex.split(command))
final_dic = {'modSecInstalled': 1,
'currentModSecRules': currentModSecRules}
@@ -1098,7 +1098,7 @@ class FirewallManager:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
execPath = execPath + " saveModSecRules"
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
@@ -1130,7 +1130,7 @@ class FirewallManager:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath
httpdConfig = subprocess.check_output(shlex.split(command)).splitlines()
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
modSecInstalled = 0
@@ -1160,7 +1160,7 @@ class FirewallManager:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
command = "sudo cat " + confPath
httpdConfig = subprocess.check_output(shlex.split(command)).splitlines()
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
modSecInstalled = 0
@@ -1174,7 +1174,7 @@ class FirewallManager:
if modSecInstalled:
command = "sudo cat " + confPath
httpdConfig = subprocess.check_output(shlex.split(command)).splitlines()
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
for items in httpdConfig:
@@ -1205,7 +1205,7 @@ class FirewallManager:
try:
command = 'sudo cat /usr/local/lsws/conf/comodo_litespeed/rules.conf.main'
res = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(shlex.split(command))
if res == 0:
comodoInstalled = 1
@@ -1242,7 +1242,7 @@ class FirewallManager:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
execPath = execPath + " " + packName
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
@@ -1260,7 +1260,7 @@ class FirewallManager:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
execPath = execPath + " " + packName
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
@@ -1292,7 +1292,7 @@ class FirewallManager:
confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/httpd_config.conf')
command = "sudo cat " + confPath
httpdConfig = subprocess.check_output(shlex.split(command)).splitlines()
httpdConfig = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
json_data = "["
checker = 0
@@ -1334,7 +1334,7 @@ class FirewallManager:
comodoPath = '/usr/local/lsws/conf/comodo_litespeed'
command = 'sudo chown -R cyberpanel:cyberpanel /usr/local/lsws/conf'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
json_data = "["
@@ -1370,7 +1370,7 @@ class FirewallManager:
json_data = json_data + ',' + json.dumps(dic)
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
json_data = json_data + ']'
final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data})
@@ -1403,7 +1403,7 @@ class FirewallManager:
execPath = execPath + " " + functionName + ' --packName ' + packName + ' --fileName ' + fileName
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
@@ -1433,7 +1433,7 @@ class FirewallManager:
csfInstalled = 1
try:
command = 'sudo csf -h'
res = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(shlex.split(command))
if res == 1:
csfInstalled = 0
except subprocess.CalledProcessError:
@@ -1454,7 +1454,7 @@ class FirewallManager:
execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " installCSF"
subprocess.Popen(shlex.split(execPath))
ProcessUtilities.popenExecutioner(shlex.split(execPath))
time.sleep(2)
@@ -1477,7 +1477,7 @@ class FirewallManager:
if installStatus.find("[200]")>-1:
command = 'sudo rm -f ' + CSF.installLogPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
final_json = json.dumps({
'error_message': "None",
@@ -1488,7 +1488,7 @@ class FirewallManager:
return HttpResponse(final_json)
elif installStatus.find("[404]") > -1:
command = 'sudo rm -f ' + CSF.installLogPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
final_json = json.dumps({
'abort':1,
'installed':0,
@@ -1522,7 +1522,7 @@ class FirewallManager:
execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " removeCSF"
subprocess.Popen(shlex.split(execPath))
ProcessUtilities.popenExecutioner(shlex.split(execPath))
time.sleep(2)
@@ -1581,7 +1581,7 @@ class FirewallManager:
execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " changeStatus --controller " + controller + " --status " + status
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {"status": 1}
@@ -1615,7 +1615,7 @@ class FirewallManager:
execPath = "sudo /usr/local/CyberCP/bin/python2 " + virtualHostUtilities.cyberPanel + "/plogical/csf.py"
execPath = execPath + " modifyPorts --protocol " + protocol + " --ports " + ports
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {"status": 1}

View File

@@ -85,7 +85,7 @@ 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 = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'status': 1, 'creatFTPStatus': 1, 'error_message': 'None'}
json_data = json.dumps(data_ret)

View File

@@ -55,7 +55,7 @@ class HAManager(multi.Thread):
for command in commands:
try:
result = subprocess.call(command, shell=True)
result = ProcessUtilities.executioner(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 = subprocess.check_output(shlex.split(command)).splitlines()
output = ProcessUtilities.outputExecutioner(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 = subprocess.check_output(shlex.split(command)).splitlines()
output = ProcessUtilities.outputExecutioner(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 = subprocess.call(command, shell=True)
result = ProcessUtilities.executioner(command, shell=True)
if result != 0:
logging.writeToFile(command + ' Failed.')
except BaseException, msg:

View File

@@ -1,6 +1,5 @@
#!/usr/bin/env bash
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
cp composer.phar /usr/bin/composer
mv composer.phar /usr/bin/composer

View File

@@ -8,7 +8,7 @@ class FirewallUtilities:
import install as inst
try:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(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

View File

@@ -337,7 +337,7 @@ class InstallCyberPanel:
while (1):
command = "systemctl start mysqld@1"
res = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(shlex.split(command))
if install.preFlightsChecks.resFailed(self.distro, res):
count = count + 1
@@ -357,7 +357,7 @@ class InstallCyberPanel:
while (1):
command = "systemctl enable mysqld@1"
res = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(shlex.split(command))
if install.preFlightsChecks.resFailed(self.distro, res):
count = count + 1
@@ -546,7 +546,7 @@ class InstallCyberPanel:
shutil.copy(ftpdPath + "/pureftpd-mysql.conf", '/etc/pure-ftpd/db/mysql.conf')
command = 'echo 1 > /etc/pure-ftpd/conf/TLS'
subprocess.call(command, shell=True)
ProcessUtilities.executioner(command, shell=True)
command = 'systemctl restart pure-ftpd-mysql.service'
install.preFlightsChecks.call(command, self.distro, '[installPureFTPDConfigurations]',
@@ -565,12 +565,12 @@ class InstallCyberPanel:
if self.distro == ubuntu:
command = 'systemctl stop systemd-resolved'
res = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(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 = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(shlex.split(command))
if res != 0:
InstallCyberPanel.stdOut(
'Unable to disable systemd.resolved, prohits install of PowerDNS, error #' +

View File

@@ -19,7 +19,7 @@ class mysqlUtilities:
command = 'mysql -u root -p' + password + ' -e "' + createDB + '"'
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(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 = subprocess.call(cmd)
res = ProcessUtilities.executioner(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 = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
return 0

View File

@@ -9,7 +9,7 @@ def installCertBot():
cmd.append("install")
cmd.append("certbot")
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
installCertBot()

View File

@@ -44,7 +44,7 @@ class unInstallCyberPanel:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
shutil.rmtree("/etc/postfix")
shutil.rmtree("etc/dovecot")
@@ -66,7 +66,7 @@ class unInstallCyberPanel:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
shutil.rmtree("/var/lib/mysql")
os.remove("/etc/my.cnf")
@@ -88,7 +88,7 @@ class unInstallCyberPanel:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
shutil.rmtree("/usr/local/lsws")
@@ -122,7 +122,7 @@ class unInstallCyberPanel:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
shutil.rmtree("/etc/pure-ftpd")
@@ -141,7 +141,7 @@ class unInstallCyberPanel:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
shutil.rmtree("/etc/pdns")
@@ -160,7 +160,7 @@ class unInstallCyberPanel:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
shutil.rmtree("/etc/pdns")

View File

@@ -181,30 +181,6 @@ 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()

View File

@@ -76,7 +76,7 @@ class MailServerManager:
execPath = execPath + " createEmailAccount --domain " + domainName + " --userName " \
+ userName + " --password " + password
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'status': 1, 'createEmailStatus': 1, 'error_message': "None"}
@@ -391,13 +391,13 @@ class MailServerManager:
try:
path = "/etc/opendkim/keys/" + domainName + "/default.txt"
command = "sudo cat " + path
output = subprocess.check_output(shlex.split(command))
output = ProcessUtilities.outputExecutioner(shlex.split(command))
leftIndex = output.index('(') + 2
rightIndex = output.rindex(')') - 1
path = "/etc/opendkim/keys/" + domainName + "/default.private"
command = "sudo cat " + path
privateKey = subprocess.check_output(shlex.split(command))
privateKey = ProcessUtilities.outputExecutioner(shlex.split(command))
data_ret = {'status': 1, 'fetchStatus': 1, 'keysAvailable': 1, 'publicKey': output[leftIndex:rightIndex],
'privateKey': privateKey, 'dkimSuccessMessage': 'Keys successfully fetched!',
@@ -428,7 +428,7 @@ class MailServerManager:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
execPath = execPath + " generateKeys --domain " + domainName
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
admin = Administrator.objects.get(pk=userID)
DNS.dnsTemplate(domainName, admin)
@@ -444,7 +444,7 @@ class MailServerManager:
path = "/etc/opendkim/keys/" + domainName + "/default.txt"
command = "sudo cat " + path
output = subprocess.check_output(shlex.split(command))
output = ProcessUtilities.outputExecutioner(shlex.split(command))
leftIndex = output.index('(') + 2
rightIndex = output.rindex(')') - 1
@@ -492,7 +492,7 @@ class MailServerManager:
def installStatusOpenDKIM(self):
try:
command = "sudo cat " + mailUtilities.installLogPath
installStatus = subprocess.check_output(shlex.split(command))
installStatus = ProcessUtilities.outputExecutioner(shlex.split(command))
if installStatus.find("[200]") > -1:
@@ -500,7 +500,7 @@ class MailServerManager:
execPath = execPath + " configureOpenDKIM"
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
pass

View File

@@ -1320,7 +1320,7 @@ def getRequestStatus(request):
requestStatusSize = len(requestStatus)
if requestStatus.find("PHP Extension Installed") > -1:
if subprocess.check_output(checkCommand).find(extensionName) > -1:
if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1:
ext = installedPackages.objects.get(extensionName=extensionName)
ext.status = 1
ext.save()
@@ -1337,7 +1337,7 @@ def getRequestStatus(request):
return HttpResponse(final_json)
elif requestStatus.find("Can not be installed") > -1:
if subprocess.check_output(checkCommand).find(extensionName) > -1:
if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1:
ext = installedPackages.objects.get(extensionName=extensionName)
ext.status = 1
ext.save()
@@ -1354,7 +1354,7 @@ def getRequestStatus(request):
return HttpResponse(final_json)
elif requestStatus.find("Can not un-install Extension") > -1:
if subprocess.check_output(checkCommand).find(extensionName) > -1:
if ProcessUtilities.outputExecutioner(checkCommand).find(extensionName) > -1:
ext = installedPackages.objects.get(extensionName=extensionName)
ext.status = 1
ext.save()
@@ -1552,7 +1552,7 @@ def savePHPConfigBasic(request):
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 = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'saveStatus': 1}
@@ -1650,7 +1650,7 @@ def savePHPConfigAdvance(request):
execPath = execPath + " savePHPConfigAdvance --phpVers " + path + " --tempPath " + tempPath
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
status = {"saveStatus": 1, "configData": data['configData']}

View File

@@ -76,7 +76,7 @@ def issueSSL(request):
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
execPath = execPath + " issueSSL --virtualHostName " + virtualHost + " --administratorEmail " + adminEmail + " --path " + path
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
pass
@@ -151,7 +151,7 @@ def obtainHostNameSSL(request):
execPath = execPath + " issueSSLForHostName --virtualHostName " + virtualHost + " --path " + path
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {"status": 1, "SSL": 1,
@@ -221,7 +221,7 @@ def obtainMailServerSSL(request):
execPath = execPath + " issueSSLForMailServer --virtualHostName " + virtualHost + " --path " + path
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {"status": 1, "SSL": 1,

View File

@@ -12,7 +12,7 @@ class ServiceManager:
type = self.extraArgs['type']
path = '/etc/pdns/pdns.conf'
data = subprocess.check_output(shlex.split('sudo cat ' + path)).splitlines()
data = ProcessUtilities.outputExecutioner(shlex.split('sudo cat ' + path)).splitlines()
if type == 'MASTER':
counter = 0

View File

@@ -174,10 +174,10 @@ def saveStatus(request):
sm.managePDNS()
command = 'sudo systemctl enable pdns'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo systemctl restart pdns'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
else:
@@ -186,10 +186,10 @@ def saveStatus(request):
pdns.save()
command = 'sudo systemctl stop pdns'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo systemctl disable pdns'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
elif service == 'postfix':
@@ -199,13 +199,13 @@ def saveStatus(request):
writeToFile = open(servicePath, 'w+')
writeToFile.close()
command = 'sudo systemctl start postfix'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
else:
command = 'sudo systemctl stop postfix'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo systemctl disable postfix'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
try:
os.remove(servicePath)
@@ -223,13 +223,13 @@ def saveStatus(request):
writeToFile = open(servicePath, 'w+')
writeToFile.close()
command = 'sudo systemctl start ' + serviceName
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
else:
command = 'sudo systemctl stop ' + serviceName
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo systemctl disable ' + serviceName
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
try:
os.remove(servicePath)

View File

@@ -31,7 +31,7 @@ class CyberCPLogFileWriter:
def readLastNFiles(numberOfLines,fileName):
try:
lastFewLines = subprocess.check_output(["tail", "-n",str(numberOfLines),fileName])
lastFewLines = ProcessUtilities.outputExecutioner(["tail", "-n",str(numberOfLines),fileName])
return lastFewLines

View File

@@ -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'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo chmod +x wp-cli.phar'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo mv wp-cli.phar /usr/bin/wp'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(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'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
else:
command = 'sudo yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo yum install git -y'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
except BaseException, msg:
logging.writeToFile( str(msg) + ' [ApplicationInstaller.installGit]')
@@ -158,7 +158,7 @@ class ApplicationInstaller(multi.Thread):
try:
command = 'sudo wp --info'
res = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(shlex.split(command))
if res == 1:
self.installWPCLI()
@@ -235,7 +235,7 @@ class ApplicationInstaller(multi.Thread):
if not os.path.exists(finalPath):
command = 'sudo mkdir -p ' + finalPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
## checking for directories/files
@@ -249,7 +249,7 @@ class ApplicationInstaller(multi.Thread):
statusFile.close()
command = "sudo wp core download --allow-root --path=" + finalPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(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
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(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
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
##
@@ -276,21 +276,21 @@ class ApplicationInstaller(multi.Thread):
statusFile.close()
command = "sudo wp plugin install litespeed-cache --allow-root --path=" + finalPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Activating LSCache Plugin,90')
statusFile.close()
command = "sudo wp plugin activate litespeed-cache --allow-root --path=" + finalPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
##
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Successfully Installed. [200]")
@@ -308,7 +308,7 @@ class ApplicationInstaller(multi.Thread):
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
try:
mysqlUtilities.deleteDatabase(dbName, dbUser)
@@ -406,7 +406,7 @@ class ApplicationInstaller(multi.Thread):
if not os.path.exists(finalPath):
command = 'sudo mkdir -p ' + finalPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
## checking for directories/files
@@ -420,13 +420,13 @@ class ApplicationInstaller(multi.Thread):
statusFile.close()
command = "sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "sudo unzip -o prestashop_1.7.4.2.zip -d " + finalPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "sudo unzip -o " + finalPath + "prestashop.zip -d " + finalPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
##
@@ -449,22 +449,22 @@ 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
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
##
command = "sudo rm -rf " + finalPath + "install"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
##
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
command = "sudo rm -f prestashop_1.7.4.2.zip"
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("Successfully Installed. [200]")
@@ -480,7 +480,7 @@ class ApplicationInstaller(multi.Thread):
if not os.path.exists(homeDir):
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
try:
mysqlUtilities.deleteDatabase(dbName, dbUser)
@@ -512,7 +512,7 @@ class ApplicationInstaller(multi.Thread):
try:
command = 'sudo git --help'
res = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(shlex.split(command))
if res == 1:
statusFile = open(tempStatusPath, 'w')
@@ -561,7 +561,7 @@ class ApplicationInstaller(multi.Thread):
if not os.path.exists(finalPath):
command = 'sudo mkdir -p ' + finalPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
## checking for directories/files
@@ -579,7 +579,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)
subprocess.check_output(shlex.split(command))
ProcessUtilities.outputExecutioner(shlex.split(command))
except subprocess.CalledProcessError, msg:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('Failed to clone repository, make sure you deployed your key to repository. [404]')
@@ -590,7 +590,7 @@ class ApplicationInstaller(multi.Thread):
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
vhost.addRewriteRules(domainName)
installUtilities.reStartLiteSpeed()
@@ -633,7 +633,7 @@ class ApplicationInstaller(multi.Thread):
return 0
command = 'sudo git --git-dir=' + finalPath + '.git --work-tree=' + finalPath +' pull'
subprocess.check_output(shlex.split(command))
ProcessUtilities.outputExecutioner(shlex.split(command))
##
@@ -642,7 +642,7 @@ class ApplicationInstaller(multi.Thread):
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
cmd = shlex.split(command)
subprocess.call(cmd)
ProcessUtilities.executioner(cmd)
return 0
@@ -674,16 +674,16 @@ class ApplicationInstaller(multi.Thread):
command = 'sudo rm -rf ' + finalPath
subprocess.check_output(shlex.split(command))
ProcessUtilities.outputExecutioner(shlex.split(command))
command = 'sudo mkdir ' + finalPath
subprocess.check_output(shlex.split(command))
ProcessUtilities.outputExecutioner(shlex.split(command))
##
command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath
cmd = shlex.split(command)
subprocess.call(cmd)
ProcessUtilities.executioner(cmd)
gitPath = '/home/cyberpanel/' + domain + '.git'
@@ -731,7 +731,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 = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
else:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines("File already exists." + " [404]")
@@ -741,12 +741,12 @@ class ApplicationInstaller(multi.Thread):
command = 'unzip ' + finalPath + 'staging.zip -d ' + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
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 = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
shutil.rmtree(finalPath + "joomla-cms-staging")
os.rename(finalPath + "installation/configuration.php-dist", finalPath + "configuration.php")
@@ -816,7 +816,7 @@ class ApplicationInstaller(multi.Thread):
f2.close()
# Restore SQL
proc = subprocess.Popen(["mysql", "--user=%s" % dbUser, "--password=%s" % dbPassword, dbName],
proc = ProcessUtilities.popenExecutioner(["mysql", "--user=%s" % dbUser, "--password=%s" % dbPassword, dbName],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
usercreation = """INSERT INTO `%susers`
@@ -833,7 +833,7 @@ class ApplicationInstaller(multi.Thread):
command = "sudo chown -R " + virtualHostUser + ":" + virtualHostUser + " " + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
vhost.addRewriteRules(domainName)
@@ -852,7 +852,7 @@ class ApplicationInstaller(multi.Thread):
if not os.path.exists(homeDir):
command = "sudo chown -R " + virtualHostUser + ":" + virtualHostUser + " " + homeDir
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
try:
mysqlUtilities.deleteDatabase(dbName, dbUser)
@@ -881,11 +881,11 @@ class ApplicationInstaller(multi.Thread):
try:
command = 'sudo git --git-dir=' + finalPath + '/.git checkout -b ' + githubBranch
subprocess.check_output(shlex.split(command))
ProcessUtilities.outputExecutioner(shlex.split(command))
except:
try:
command = 'sudo git --git-dir=' + finalPath + '/.git checkout ' + githubBranch
subprocess.check_output(shlex.split(command))
ProcessUtilities.outputExecutioner(shlex.split(command))
except subprocess.CalledProcessError, msg:
logging.writeToFile('Failed to change branch: ' + str(msg))
return 0

View File

@@ -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") + "/"
subprocess.call(shlex.split(command), stdout=writeToFile)
ProcessUtilities.executioner(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")
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
pass
for virtualHost in os.listdir("/home"):

View File

@@ -638,7 +638,7 @@ class backupUtilities:
## Change permissions
command = "chmod -r vmail:vmail " + emailHome
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
except:
pass
@@ -656,7 +656,7 @@ class backupUtilities:
command = "chown -R " + externalApp + ":" + externalApp + " " + websiteHome
cmd = shlex.split(command)
subprocess.call(cmd)
ProcessUtilities.executioner(cmd)
except BaseException, msg:
status = os.path.join(completPath, 'status')
@@ -778,7 +778,7 @@ class backupUtilities:
@staticmethod
def checkIfHostIsUp(IPAddress):
try:
if subprocess.check_output(['ping', IPAddress, '-c 1']).find("0% packet loss") > -1:
if ProcessUtilities.outputExecutioner(['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:
subprocess.call(['kill', str(checkConn.pid)])
ProcessUtilities.executioner(['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:
subprocess.call(['kill', str(checkConn.pid)])
ProcessUtilities.executioner(['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:
subprocess.call(['kill', str(checkConn.pid)])
ProcessUtilities.executioner(['kill', str(checkConn.pid)])
return [1, "None"]
elif index == 4:
subprocess.call(['kill', str(checkConn.pid)])
ProcessUtilities.executioner(['kill', str(checkConn.pid)])
return [1, "None"]
else:
subprocess.call(['kill', str(checkConn.pid)])
ProcessUtilities.executioner(['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"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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"'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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"'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
return 1
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [host_key_verification]")

View File

@@ -9,6 +9,7 @@ import tarfile
import shutil
from mailUtilities import mailUtilities
import threading as multi
from plogical.processUtilities import ProcessUtilities
class CSF(multi.Thread):
installLogPath = "/home/cyberpanel/csfInstallLog"
@@ -140,7 +141,7 @@ class CSF(multi.Thread):
currentSettings = {}
command = 'sudo cat /etc/csf/csf.conf'
output = subprocess.check_output(shlex.split(command)).splitlines()
output = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
for items in output:
if items.find('TESTING') > -1 and items.find('=') > -1 and (items[0]!= '#') and items.find('TESTING_INTERVAL') == -1:
@@ -166,7 +167,7 @@ class CSF(multi.Thread):
currentSettings['firewallStatus'] = 0
command = 'sudo iptables -nv -L'
output = subprocess.check_output(shlex.split(command))
output = ProcessUtilities.outputExecutioner(shlex.split(command))
if output.find('0.0.0.0/0') > -1:
currentSettings['firewallStatus'] = 1
@@ -258,10 +259,10 @@ class CSF(multi.Thread):
def allowIP(ipAddress):
try:
command = 'sudo csf -dr ' + ipAddress
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo csf -a ' + ipAddress
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[allowIP]")
@@ -271,10 +272,10 @@ class CSF(multi.Thread):
try:
command = 'sudo csf -tr ' + ipAddress
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo csf -d ' + ipAddress
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[blockIP]")

View File

@@ -326,7 +326,7 @@ class DNS:
path = "/etc/opendkim/keys/" + topLevelDomain + "/default.txt"
command = "sudo cat " + path
output = subprocess.check_output(shlex.split(command))
output = ProcessUtilities.outputExecutioner(shlex.split(command))
leftIndex = output.index('(') + 2
rightIndex = output.rindex(')') - 1

View File

@@ -127,7 +127,7 @@ class findBWUsage:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
logging.CyberCPLogFileWriter.writeToFile("1440 [setup_cron]")

View File

@@ -19,7 +19,7 @@ class FirewallUtilities:
def doCommand(command):
try:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if FirewallUtilities.resFailed(res):
logging.CyberCPLogFileWriter.writeToFile("Failed to apply rule: " + command + " Error #" + str(res))
return 0

View File

@@ -32,7 +32,7 @@ class FTPUtilities:
cmd.append("ftpuser:2001")
cmd.append(path)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
print "Permissions not changed."
else:
@@ -58,7 +58,7 @@ class FTPUtilities:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
print "Permissions not changed."
@@ -72,7 +72,7 @@ class FTPUtilities:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
return 0
@@ -96,7 +96,7 @@ class FTPUtilities:
command = "chown " + externalApp + ":" + externalApp + " " + path
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
return 1,'None'

View File

@@ -19,7 +19,7 @@ class installUtilities:
cmd.append("-y")
cmd.append("install")
cmd.append("epel-release")
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(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 = subprocess.call(cmd)
res = ProcessUtilities.executioner(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 = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
@@ -111,7 +111,7 @@ class installUtilities:
cmd.append("/usr/local/lsws/bin/lswsctrl")
cmd.append("start")
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
print("###############################################")
@@ -144,7 +144,7 @@ class installUtilities:
command = "sudo /usr/local/lsws/bin/lswsctrl restart"
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except OSError, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [reStartLiteSpeed]")
@@ -165,7 +165,7 @@ class installUtilities:
command = "sudo /usr/local/lsws/bin/lswsctrl restart"
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
print("###############################################")
@@ -216,7 +216,7 @@ class installUtilities:
cmd.append("groupinstall")
cmd.append("lsphp-all")
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
print("###############################################")
@@ -310,7 +310,7 @@ class installUtilities:
cmd.append("remove")
cmd.append("openlitespeed-1.4.26")
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
print("###############################################")
@@ -338,7 +338,7 @@ class installUtilities:
cmd.append("remove")
cmd.append("lsphp*")
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
print("###############################################")
@@ -380,7 +380,7 @@ class installUtilities:
cmd.append("start")
cmd.append("mariadb")
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
print("###############################################")
@@ -416,7 +416,7 @@ class installUtilities:
cmd.append("install")
cmd.append("mariadb-server")
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
print("###############################################")
@@ -456,7 +456,7 @@ class installUtilities:
cmd.append("enable")
cmd.append("mariadb")
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 1:
print("###############################################")

View File

@@ -80,13 +80,13 @@ class mailUtilities:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data/_data_'
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(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"
subprocess.call(shlex.split(command),stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(shlex.split(command),stdout=FNULL, stderr=subprocess.STDOUT)
## Fix permissions
command = "chown -R root:opendkim /etc/opendkim/keys/" + virtualHostName
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "chmod 640 /etc/opendkim/keys/" + virtualHostName + "/default.private"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "chmod 644 /etc/opendkim/keys/" + virtualHostName + "/default.txt"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
## Edit key file
@@ -202,10 +202,10 @@ class mailUtilities:
## Restart postfix and OpenDKIM
command = "systemctl restart opendkim"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "systemctl restart postfix"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
return 1, "None"
@@ -221,7 +221,7 @@ class mailUtilities:
path = "/etc/opendkim.conf"
command = "sudo cat " + path
res = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(shlex.split(command))
if res == 1:
return 0
@@ -285,15 +285,15 @@ milter_default_action = accept
#### Restarting Postfix and OpenDKIM
command = "systemctl start opendkim"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "systemctl enable opendkim"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
##
command = "systemctl start postfix"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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
subprocess.call(shlex.split(command), stdout=FNULL)
ProcessUtilities.executioner(shlex.split(command), stdout=FNULL)
command = "sudo chown -R cyberpanel:cyberpanel " + mailUtilities.cyberPanelHome
subprocess.call(shlex.split(command), stdout=FNULL)
ProcessUtilities.executioner(shlex.split(command), stdout=FNULL)
except:
FNULL = open(os.devnull, 'w')
command = "sudo chown -R cyberpanel:cyberpanel " + mailUtilities.cyberPanelHome
subprocess.call(shlex.split(command), stdout=FNULL)
ProcessUtilities.executioner(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 = subprocess.call(cmd, stdout=f)
res = ProcessUtilities.executioner(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'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'systemctl restart dovecot'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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 = subprocess.call(cmd, stdout=f)
res = ProcessUtilities.executioner(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 = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(shlex.split(command))
if res == 1:
return 0
@@ -443,21 +443,21 @@ milter_default_action = accept
command = "groupadd spamd"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
##
command = "chown spamd:spamd /var/log/spamassassin"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "systemctl enable spamassassin"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "systemctl start spamassassin"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
## Configuration to postfix
@@ -478,7 +478,7 @@ milter_default_action = accept
writeToFile.close()
command = 'systemctl restart postfix'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
print "1,None"
@@ -531,7 +531,7 @@ milter_default_action = accept
conf.close()
command = 'systemctl restart spamassassin'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'systemctl start cpecs'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
else:
data = open(postfixPath, 'r').readlines()
@@ -580,10 +580,10 @@ milter_default_action = accept
writeToFile.close()
command = 'systemctl stop cpecs'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'systemctl restart postfix'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
print "1,None"
return

View File

@@ -29,7 +29,7 @@ class modSec:
cmd = shlex.split(command)
with open(modSec.installLogPath, 'w') as f:
res = subprocess.call(cmd, stdout=f)
res = ProcessUtilities.executioner(cmd, stdout=f)
if res == 1:
writeToFile = open(modSec.installLogPath, 'a')
@@ -230,7 +230,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 = subprocess.call(shlex.split(command))
result = ProcessUtilities.executioner(shlex.split(command))
if result == 1:
return 0
@@ -250,13 +250,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 = subprocess.call(shlex.split(command))
result = ProcessUtilities.executioner(shlex.split(command))
if result == 1:
return 0
command = "unzip cpanel_litespeed_vendor -d " + extractLocation
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
return 1
@@ -334,16 +334,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 = subprocess.call(shlex.split(command))
result = ProcessUtilities.executioner(shlex.split(command))
if result == 1:
return 0
command = "unzip cpanel_litespeed_vendor -d " + extractLocation
result = subprocess.call(shlex.split(command))
result = ProcessUtilities.executioner(shlex.split(command))
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
print "1,None"
return
@@ -398,7 +398,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 = subprocess.call(shlex.split(command))
result = ProcessUtilities.executioner(shlex.split(command))
if result == 1:
return 0

View File

@@ -116,7 +116,7 @@ class mysqlUtilities:
cmd = shlex.split(command)
with open(tempStoragePath+"/"+databaseName+'.sql', 'w') as f:
res = subprocess.call(cmd,stdout=f)
res = ProcessUtilities.executioner(cmd,stdout=f)
if res == 1:
logging.CyberCPLogFileWriter.writeToFile("Database: "+databaseName + "could not be backed! [createDatabaseBackup]")
@@ -143,7 +143,7 @@ class mysqlUtilities:
with open(tempStoragePath + "/" + databaseName + '.sql', 'r') as f:
res = subprocess.call(cmd, stdin=f)
res = ProcessUtilities.executioner(cmd, stdin=f)
if res == 1:
logging.CyberCPLogFileWriter.writeToFile("Could not restore MYSQL database: " +databaseName +"! [restoreDatabaseBackup]")
@@ -347,7 +347,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'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return 0, str(msg)
@@ -383,7 +383,7 @@ class mysqlUtilities:
except BaseException, msg:
command = 'sudo mv /etc/my.cnf.bak /etc/my.cnf'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
logging.CyberCPLogFileWriter.writeToFile(str(msg))
return 0, str(msg)

View File

@@ -27,7 +27,7 @@ class phpUtilities:
try:
with open(phpUtilities.installLogPath, 'w') as f:
subprocess.call(cmd, stdout=f)
ProcessUtilities.executioner(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:
subprocess.call(cmd, stdout=f)
ProcessUtilities.executioner(cmd, stdout=f)
writeToFile = open(phpUtilities.installLogPath, 'a')
writeToFile.writelines("PHP Extension Removed.\n")

View File

@@ -39,7 +39,7 @@ class ProcessUtilities:
command = "sudo /usr/local/lsws/bin/lswsctrl restart"
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(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 = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
if res == 0:
return 1
@@ -68,17 +68,6 @@ class ProcessUtilities:
except subprocess.CalledProcessError, msg:
logging.writeToFile(str(msg) + "[stopLitespeed]")
@staticmethod
def executioner(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:
@@ -118,7 +107,7 @@ class ProcessUtilities:
def containerCheck():
try:
command = 'sudo cat /etc/cgrules.conf'
result = subprocess.call(shlex.split(command))
result = ProcessUtilities.executioner(shlex.split(command))
if result == 1:
return 0
else:
@@ -126,5 +115,24 @@ class ProcessUtilities:
except BaseException:
return 0
@staticmethod
def executioner(command):
try:
res = subprocess.call(shlex.split(command))
if res == 0:
return 1
else:
return 0
except BaseException, msg:
return 0
@staticmethod
def outputExecutioner(command):
return subprocess.check_output(shlex.split(command))
@staticmethod
def popenExecutioner(command):
return subprocess.Popen(shlex.split(command))

View File

@@ -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
subprocess.call(shlex.split(command), stdout=writeToFile)
ProcessUtilities.executioner(shlex.split(command), stdout=writeToFile)
os.remove(completedPathToSend)
except BaseException, msg:

View File

@@ -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 + "/"
subprocess.call(shlex.split(command), stdout=writeToFile)
ProcessUtilities.executioner(shlex.split(command), stdout=writeToFile)
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")

View File

@@ -236,14 +236,14 @@ class sslUtilities:
if not os.path.exists(acmePath):
command = 'wget -O - https://get.acme.sh | sh'
subprocess.call(command, shell=True)
ProcessUtilities.executioner(command, shell=True)
if aliasDomain == None:
existingCertPath = '/etc/letsencrypt/live/' + virtualHostName
if not os.path.exists(existingCertPath):
command = 'mkdir -p ' + existingCertPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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 = subprocess.check_output(shlex.split(command))
output = ProcessUtilities.outputExecutioner(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 = subprocess.check_output(shlex.split(command))
output = ProcessUtilities.outputExecutioner(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
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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 = subprocess.check_output(shlex.split(command))
output = ProcessUtilities.outputExecutioner(shlex.split(command))
logging.CyberCPLogFileWriter.writeToFile(
"Successfully obtained SSL for: " + virtualHostName + ", www." + virtualHostName + ", " + aliasDomain + "and www." + aliasDomain + ",")

View File

@@ -15,7 +15,7 @@ class tuning:
try:
dataToReturn = {}
command = "sudo cat /usr/local/lsws/conf/httpd_config.conf"
datas = subprocess.check_output(shlex.split(command)).split("\n")
datas = ProcessUtilities.outputExecutioner(shlex.split(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 = subprocess.check_output(shlex.split(command))
datas = ProcessUtilities.outputExecutioner(shlex.split(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 = subprocess.check_output(shlex.split(command)).split("\n")
datas = ProcessUtilities.outputExecutioner(shlex.split(command)).split("\n")
dataToReturn = {}
@@ -230,7 +230,7 @@ class tuning:
else:
try:
command = "sudo cat /usr/local/lsws/conf/httpd_config.xml"
datas = subprocess.check_output(shlex.split(command))
datas = ProcessUtilities.outputExecutioner(shlex.split(command))
comTree = ElementTree.fromstring(datas)
extProcessorList = comTree.findall('extProcessorList/extProcessor')

View File

@@ -35,7 +35,7 @@ class Upgrade:
try:
count = 0
while True:
res = subprocess.call(shlex.split(command))
res = ProcessUtilities.executioner(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'
subprocess.call(['virtualenv', env_path])
ProcessUtilities.executioner(['virtualenv', env_path])
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
execfile(activate_this, dict(__file__=activate_this))

View File

@@ -0,0 +1,44 @@
#!/usr/local/CyberCP/bin/python2
import sys
sys.path.append('/usr/local/CyberCP')
import subprocess, shlex
import os
class UpgradeCritical:
@staticmethod
def executioner(command):
try:
FNULL = open(os.devnull, 'w')
res = ProcessUtilities.executioner(shlex.split(command), stdout=FNULL)
if res == 0:
return 1
else:
return 0
except BaseException, msg:
return 0
@staticmethod
def UpgradeImportantPackages():
if os.path.exists('/etc/lsb-release'):
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)
command = "yum -y upgrade pdns pdns-backend-mysql pure-ftpd postfix dovecot dovecot-mysql"
UpgradeCritical.executioner(command)
def main():
UpgradeCritical.UpgradeImportantPackages()
if __name__ == "__main__":
main()

View File

@@ -39,15 +39,15 @@ class vhost:
command = "adduser " + virtualHostUser + " -M -d " + path
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
command = "groupadd " + virtualHostUser
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
command = "usermod -a -G " + virtualHostUser + " " + virtualHostUser
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except:
pass
@@ -69,11 +69,11 @@ class vhost:
command = "chown " + virtualHostUser + ":" + virtualHostUser + " " + path
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
command = "chmod 711 " + path
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
vhostPath = vhost.Server_root + "/conf/vhosts"
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(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
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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 = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
@@ -607,7 +607,7 @@ class vhost:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
vhostPath = vhost.Server_root + "/conf/vhosts"
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + vhostPath
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except OSError, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + "329 [Not able to create directories for virtual host [createDirectoryForDomain]]")

View File

@@ -166,10 +166,10 @@ class virtualHostUtilities:
def getAccessLogs(fileName, page):
try:
numberOfTotalLines = int(subprocess.check_output(["wc", "-l", fileName]).split(" ")[0])
numberOfTotalLines = int(ProcessUtilities.outputExecutioner(["wc", "-l", fileName]).split(" ")[0])
if numberOfTotalLines < 25:
data = subprocess.check_output(["cat", fileName])
data = ProcessUtilities.outputExecutioner(["cat", fileName])
else:
if page == 1:
end = numberOfTotalLines
@@ -199,10 +199,10 @@ class virtualHostUtilities:
def getErrorLogs(fileName, page):
try:
numberOfTotalLines = int(subprocess.check_output(["wc", "-l", fileName]).split(" ")[0])
numberOfTotalLines = int(ProcessUtilities.outputExecutioner(["wc", "-l", fileName]).split(" ")[0])
if numberOfTotalLines < 25:
data = subprocess.check_output(["cat", fileName])
data = ProcessUtilities.outputExecutioner(["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 = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
command = 'tar -xzvf latest.tar.gz -C ' + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
## Get plugin
@@ -318,13 +318,13 @@ class virtualHostUtilities:
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
command = 'unzip litespeed-cache.1.1.5.1.zip -d ' + finalPath
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
root = finalPath
@@ -368,7 +368,7 @@ class virtualHostUtilities:
cmd = shlex.split(command)
res = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(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 = subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
res = ProcessUtilities.executioner(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)
subprocess.call(cmd)
ProcessUtilities.executioner(cmd)
print "1,None"
return 1,'None'
@@ -838,7 +838,7 @@ class virtualHostUtilities:
pathToStoreSSL = '/etc/letsencrypt/live/' + virtualHost
command = 'mkdir -p ' + pathToStoreSSL
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
print "1,None"
@@ -1002,7 +1002,7 @@ class virtualHostUtilities:
def getDiskUsage(path, totalAllowed):
try:
totalUsageInMB = subprocess.check_output(["sudo", "du", "-hs", path, "--block-size=1M"]).split()[0]
totalUsageInMB = ProcessUtilities.outputExecutioner(["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 = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
@@ -1033,7 +1033,7 @@ class virtualHostUtilities:
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))

View File

@@ -296,7 +296,7 @@ class WebsiteManager:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
execPath = execPath + " deleteVirtualHostConfigurations --virtualHostName " + websiteName
subprocess.check_output(shlex.split(execPath))
ProcessUtilities.outputExecutioner(shlex.split(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
subprocess.check_output(shlex.split(execPath))
ProcessUtilities.outputExecutioner(shlex.split(execPath))
data_ret = {'status': 1, 'websiteDeleteStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
@@ -346,18 +346,18 @@ class WebsiteManager:
if state == "Suspend":
confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + websiteName
command = "sudo mv " + confPath + " " + confPath + "-suspended"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
installUtilities.reStartLiteSpeed()
website.state = 0
else:
confPath = virtualHostUtilities.Server_root + "/conf/vhosts/" + websiteName
command = "sudo mv " + confPath + "-suspended" + " " + confPath
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "chown -R " + "lsadm" + ":" + "lsadm" + " " + confPath
cmd = shlex.split(command)
subprocess.call(cmd)
ProcessUtilities.executioner(cmd)
installUtilities.reStartLiteSpeed()
website.state = 1
@@ -506,7 +506,7 @@ class WebsiteManager:
execPath = execPath + " changePHP --phpVersion '" + phpVersion + "' --path " + completePathToConfigFile
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
pass
@@ -574,7 +574,7 @@ class WebsiteManager:
execPath = execPath + " findDomainBW --virtualHostName " + self.domain + " --bandwidth " + str(
website.package.bandwidth)
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
bwData = output.split(",")
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
@@ -639,7 +639,7 @@ class WebsiteManager:
execPath = execPath + " findDomainBW --virtualHostName " + self.domain + " --bandwidth " + str(
website.package.bandwidth)
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
bwData = output.split(",")
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))
@@ -695,7 +695,7 @@ class WebsiteManager:
execPath = execPath + " getAccessLogs --path " + fileName + " --page " + str(page)
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
final_json = json.dumps(
@@ -757,7 +757,7 @@ class WebsiteManager:
execPath = execPath + " getErrorLogs --path " + fileName + " --page " + str(page)
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
final_json = json.dumps(
@@ -783,7 +783,7 @@ class WebsiteManager:
filePath = installUtilities.Server_root_path + "/conf/vhosts/" + self.domain + "/vhost.conf"
command = 'sudo cat ' + filePath
configData = subprocess.check_output(shlex.split(command))
configData = ProcessUtilities.outputExecutioner(shlex.split(command))
if len(configData) == 0:
status = {'status': 0, "configstatus": 0, "error_message": "Configuration file is currently empty!"}
@@ -825,7 +825,7 @@ class WebsiteManager:
execPath = execPath + " saveVHostConfigs --path " + filePath + " --tempPath " + tempPath
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
status = {"configstatus": 1}
@@ -908,7 +908,7 @@ class WebsiteManager:
execPath = execPath + " saveRewriteRules --virtualHostName " + self.domain + " --path " + filePath + " --tempPath " + tempPath
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
status = {"rewriteStatus": 1, 'error_message': output}
@@ -953,7 +953,7 @@ class WebsiteManager:
execPath = execPath + " saveSSL --virtualHostName " + self.domain + " --tempKeyPath " + tempKeyPath + " --tempCertPath " + tempCertPath
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'sslStatus': 1, 'error_message': "None"}
@@ -986,7 +986,7 @@ class WebsiteManager:
execPath = execPath + " changePHP --phpVersion '" + phpVersion + "' --path " + completePathToConfigFile
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
pass
@@ -1036,8 +1036,8 @@ class WebsiteManager:
crons = []
try:
# f = subprocess.check_output(["sudo", "cat", cronPath])
f = subprocess.check_output(["sudo", "crontab", "-u", website.externalApp, "-l"])
# 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)
@@ -1093,8 +1093,8 @@ class WebsiteManager:
crons = []
try:
# f = subprocess.check_output(["sudo", "cat", cronPath])
f = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
# f = ProcessUtilities.outputExecutioner(["sudo", "cat", cronPath])
f = ProcessUtilities.outputExecutioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
print f
except subprocess.CalledProcessError as error:
dic = {'getWebsiteCron': 0, 'error_message': 'Unable to access Cron file'}
@@ -1161,7 +1161,7 @@ class WebsiteManager:
finalCron = "%s %s %s %s %s %s" % (minute, hour, monthday, month, weekday, command)
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
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'}
@@ -1172,7 +1172,7 @@ class WebsiteManager:
file.write(output)
# Confirming that directory is read/writable
o = subprocess.call(['sudo', 'chown', 'cyberpanel:cyberpanel', tempPath])
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)
@@ -1186,7 +1186,7 @@ class WebsiteManager:
with open(tempPath, 'w') as file:
file.writelines(data)
output = subprocess.call(["sudo", "/usr/bin/crontab", "-u", website.externalApp, tempPath])
output = ProcessUtilities.executioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, tempPath])
os.remove(tempPath)
if output != 0:
@@ -1222,7 +1222,7 @@ class WebsiteManager:
line -= 1
website = Websites.objects.get(domain=self.domain)
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
output = ProcessUtilities.outputExecutioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
if "no crontab for" in output:
data_ret = {'addNewCron': 0, 'error_message': 'No Cron exists for this user'}
@@ -1235,7 +1235,7 @@ class WebsiteManager:
file.write(output)
# Confirming that directory is read/writable
o = subprocess.call(['sudo', 'chown', 'cyberpanel:cyberpanel', tempPath])
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)
@@ -1249,7 +1249,7 @@ class WebsiteManager:
with open(tempPath, 'w') as file:
file.writelines(data)
output = subprocess.call(["sudo", "/usr/bin/crontab", "-u", website.externalApp, tempPath])
output = ProcessUtilities.executioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, tempPath])
os.remove(tempPath)
if output != 0:
@@ -1291,23 +1291,23 @@ class WebsiteManager:
website = Websites.objects.get(domain=self.domain)
try:
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
output = ProcessUtilities.outputExecutioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
except:
try:
subprocess.call(('sudo', 'crontab', '-u', website.externalApp, '-'))
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 = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
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)
subprocess.call(('sudo', 'crontab', '-u', website.externalApp, '-'), stdin=echo.stdout)
ProcessUtilities.executioner(('sudo', 'crontab', '-u', website.externalApp, '-'), stdin=echo.stdout)
echo.wait()
echo.stdout.close()
output = subprocess.check_output(["sudo", "/usr/bin/crontab", "-u", website.externalApp, "-l"])
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)
@@ -1320,7 +1320,7 @@ class WebsiteManager:
with open(tempPath, "a") as file:
file.write(output + finalCron + "\n")
output = subprocess.call(["sudo", "/usr/bin/crontab", "-u", website.externalApp, tempPath])
output = ProcessUtilities.executioner(["sudo", "/usr/bin/crontab", "-u", website.externalApp, tempPath])
os.remove(tempPath)
if output != 0:
@@ -1363,7 +1363,7 @@ class WebsiteManager:
execPath = execPath + " createAlias --masterDomain " + self.domain + " --aliasDomain " + aliasDomain + " --ssl " + str(
ssl) + " --sslPath " + sslpath + " --administratorEmail " + admin.email + ' --websiteOwner ' + admin.userName
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
pass
@@ -1408,7 +1408,7 @@ class WebsiteManager:
execPath = execPath + " issueAliasSSL --masterDomain " + self.domain + " --aliasDomain " + aliasDomain + " --sslPath " + sslpath + " --administratorEmail " + admin.email
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'sslStatus': 1, 'error_message': "None", "existsStatus": 0}
@@ -1444,7 +1444,7 @@ class WebsiteManager:
execPath = execPath + " deleteAlias --masterDomain " + self.domain + " --aliasDomain " + aliasDomain
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'deleteAlias': 1, 'error_message': "None", "existsStatus": 0}
@@ -1478,7 +1478,7 @@ class WebsiteManager:
execPath = execPath + " changeOpenBasedir --virtualHostName '" + self.domain + "' --openBasedirValue " + openBasedirValue
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
pass
@@ -1566,7 +1566,7 @@ class WebsiteManager:
if lastLine.find('[200]') > -1:
command = 'sudo rm -f ' + statusFile
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
data_ret = {'abort': 1, 'installStatus': 1, 'installationProgress': "100",
'currentStatus': 'Successfully Installed.'}
json_data = json.dumps(data_ret)
@@ -1802,7 +1802,7 @@ Host gitlab.com
ProcessUtilities.executioner(command)
command = 'sudo cat /root/.ssh/git.pub'
deploymentKey = subprocess.check_output(shlex.split(command)).strip('\n')
deploymentKey = ProcessUtilities.outputExecutioner(shlex.split(command)).strip('\n')
return render(request, 'websiteFunctions/setupGit.html',
{'domainName': self.domain, 'deploymentKey': deploymentKey, 'installed': 0})

View File

@@ -26,7 +26,7 @@ class pluginInstaller:
def extractPlugin(pluginName):
pathToPlugin = pluginName + '.zip'
command = 'unzip ' + pathToPlugin + ' -d /usr/local/CyberCP'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
@staticmethod
def upgradingSettingsFile(pluginName):
@@ -65,7 +65,7 @@ class pluginInstaller:
pluginFile = pluginPath + '/' + pluginName
command = 'touch ' + pluginFile
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
@staticmethod
def addInterfaceLink(pluginName):
@@ -87,15 +87,15 @@ class pluginInstaller:
currentDir = os.getcwd()
command = "rm -rf /usr/local/lscp/cyberpanel/static"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
os.chdir('/usr/local/CyberCP')
command = "python manage.py collectstatic --noinput"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = "mv /usr/local/CyberCP/static /usr/local/lscp/cyberpanel"
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = pluginHome + '/pre_install'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = pluginHome + '/post_install'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
@staticmethod
@@ -286,7 +286,7 @@ class pluginInstaller:
@staticmethod
def restartGunicorn():
command = 'systemctl restart gunicorn.socket'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))

View File

@@ -139,7 +139,7 @@ def getLogsFromFile(request):
try:
command = "sudo tail -50 " + fileName
fewLinesOfLogFile = subprocess.check_output(shlex.split(command))
fewLinesOfLogFile = ProcessUtilities.outputExecutioner(shlex.split(command))
status = {"status": 1, "logstatus": 1, "logsdata": fewLinesOfLogFile}
final_json = json.dumps(status)
return HttpResponse(final_json)
@@ -175,7 +175,7 @@ def clearLogFile(request):
execPath = execPath + " cleanLogFile --fileName " + fileName
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'cleanStatus': 1, 'error_message': "None"}

View File

@@ -24,7 +24,7 @@ class ServerStatusUtil:
@staticmethod
def executioner(command, statusFile):
try:
res = subprocess.call(shlex.split(command), stdout=statusFile, stderr=statusFile)
res = ProcessUtilities.executioner(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
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(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)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg))

View File

@@ -46,7 +46,7 @@ def litespeedStatus(request):
OLS = 1
try:
versionInformation = subprocess.check_output(["/usr/local/lsws/bin/lshttpd", "-v"]).split("\n")
versionInformation = ProcessUtilities.outputExecutioner(["/usr/local/lsws/bin/lshttpd", "-v"]).split("\n")
lsversion = versionInformation[0]
modules = versionInformation[1]
@@ -193,7 +193,7 @@ def servicesStatus(request):
mailStatus = []
dockerStatus = []
processlist = subprocess.check_output(['ps', '-A'])
processlist = ProcessUtilities.outputExecutioner(['ps', '-A'])
def getServiceStats(service):
if service in processlist:
@@ -309,7 +309,7 @@ def servicesAction(request):
command = 'sudo systemctl %s %s' % (action, service)
cmd = shlex.split(command)
res = subprocess.call(cmd)
res = ProcessUtilities.executioner(cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
result = p.communicate()[0]
@@ -366,7 +366,7 @@ def switchTOLSWSStatus(request):
try:
command = 'sudo cat ' + serverStatusUtil.ServerStatusUtil.lswsInstallStatusPath
output = subprocess.check_output(shlex.split(command))
output = ProcessUtilities.outputExecutioner(shlex.split(command))
if output.find('[404]') > -1:
data_ret = {'abort': 1, 'requestStatus': output, 'installed': 0}
@@ -400,10 +400,10 @@ def licenseStatus(request):
return ACLManager.loadErrorJson('status', 0)
command = 'sudo cat /usr/local/lsws/conf/serial.no'
serial = subprocess.check_output(shlex.split(command))
serial = ProcessUtilities.outputExecutioner(shlex.split(command))
command = 'sudo /usr/local/lsws/bin/lshttpd -V'
expiration = subprocess.check_output(shlex.split(command))
expiration = ProcessUtilities.outputExecutioner(shlex.split(command))
final_dic = {'status': 1, "erroMessage": 0, 'lsSerial': serial, 'lsexpiration': expiration}
final_json = json.dumps(final_dic)
@@ -435,7 +435,7 @@ def changeLicense(request):
newKey = data['newKey']
command = 'sudo chown -R cyberpanel:cyberpanel /usr/local/lsws/conf'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
serialPath = '/usr/local/lsws/conf/serial.no'
serialFile = open(serialPath, 'w')
@@ -443,13 +443,13 @@ def changeLicense(request):
serialFile.close()
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo /usr/local/lsws/bin/lshttpd -r'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
command = 'sudo /usr/local/lsws/bin/lswsctrl restart'
subprocess.call(shlex.split(command))
ProcessUtilities.executioner(shlex.split(command))
final_dic = {'status': 1, "erroMessage": 'None'}
final_json = json.dumps(final_dic)
@@ -488,7 +488,7 @@ def topProcessesStatus(request):
try:
with open("/home/cyberpanel/top", "w") as outfile:
subprocess.call("sudo top -n1 -b", shell=True, stdout=outfile)
ProcessUtilities.executioner("sudo top -n1 -b", shell=True, stdout=outfile)
data = open('/home/cyberpanel/top', 'r').readlines()
@@ -574,7 +574,7 @@ def topProcessesStatus(request):
## CPU Details
command = 'sudo cat /proc/cpuinfo'
output = subprocess.check_output(shlex.split(command)).splitlines()
output = ProcessUtilities.outputExecutioner(shlex.split(command)).splitlines()
import psutil

View File

@@ -121,7 +121,7 @@ class tuningManager:
execPath = execPath + " saveTuningDetails --maxConn " + maxConn + " --maxSSLConn " + maxSSLConn + " --connTime " + connTime + " --keepAlive " + keepAlive + " --inMemCache '" + inMemCache + "' --gzipCompression " + gzipCompression
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'fetch_status': 1, 'error_message': "None", 'tuneStatus': 1}
@@ -166,7 +166,7 @@ class tuningManager:
execPath = execPath + " tunePHP --virtualHost " + domainSelection + " --initTimeout " + initTimeout + " --maxConns " + maxConns + " --memSoftLimit " + memSoftLimit + " --memHardLimit '" + memHardLimit + "' --procSoftLimit " + procSoftLimit + " --procHardLimit " + procHardLimit + " --persistConn " + persistConn
output = subprocess.check_output(shlex.split(execPath))
output = ProcessUtilities.outputExecutioner(shlex.split(execPath))
if output.find("1,None") > -1:
data_ret = {'tuneStatus': 1, 'fetch_status': 0, 'error_message': "None"}