mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
execute git commands from the repo folder
This commit is contained in:
@@ -179,7 +179,7 @@ class ProcessUtilities(multi.Thread):
|
|||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def sendCommand(command, user=None):
|
def sendCommand(command, user=None, dir=None):
|
||||||
try:
|
try:
|
||||||
ret = ProcessUtilities.setupUDSConnection()
|
ret = ProcessUtilities.setupUDSConnection()
|
||||||
|
|
||||||
@@ -201,12 +201,20 @@ class ProcessUtilities(multi.Thread):
|
|||||||
if os.path.exists(ProcessUtilities.debugPath):
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
logging.writeToFile(ProcessUtilities.token + command)
|
logging.writeToFile(ProcessUtilities.token + command)
|
||||||
|
|
||||||
|
if dir == None:
|
||||||
sock.sendall((ProcessUtilities.token + command).encode('utf-8'))
|
sock.sendall((ProcessUtilities.token + command).encode('utf-8'))
|
||||||
else:
|
else:
|
||||||
|
command = '%s-d %s %s' % (ProcessUtilities.token, dir, command)
|
||||||
|
sock.sendall(command.encode('utf-8'))
|
||||||
|
else:
|
||||||
|
if dir == None:
|
||||||
command = '%s-u %s %s' % (ProcessUtilities.token, user, command)
|
command = '%s-u %s %s' % (ProcessUtilities.token, user, command)
|
||||||
|
else:
|
||||||
|
command = '%s-u %s -d %s %s' % (ProcessUtilities.token, user, dir, command)
|
||||||
command = command.replace('sudo', '')
|
command = command.replace('sudo', '')
|
||||||
if os.path.exists(ProcessUtilities.debugPath):
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
logging.writeToFile(command)
|
logging.writeToFile(command)
|
||||||
|
|
||||||
sock.sendall(command.encode('utf-8'))
|
sock.sendall(command.encode('utf-8'))
|
||||||
|
|
||||||
data = ""
|
data = ""
|
||||||
@@ -250,7 +258,7 @@ class ProcessUtilities(multi.Thread):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def outputExecutioner(command, user=None, shell = None):
|
def outputExecutioner(command, user=None, shell = None, dir = None):
|
||||||
try:
|
try:
|
||||||
if getpass.getuser() == 'root':
|
if getpass.getuser() == 'root':
|
||||||
if os.path.exists(ProcessUtilities.debugPath):
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
@@ -264,7 +272,7 @@ class ProcessUtilities(multi.Thread):
|
|||||||
if type(command) == list:
|
if type(command) == list:
|
||||||
command = " ".join(command)
|
command = " ".join(command)
|
||||||
|
|
||||||
return ProcessUtilities.sendCommand(command, user)[:-1]
|
return ProcessUtilities.sendCommand(command, user, dir)[:-1]
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
logging.writeToFile(str(msg) + "[outputExecutioner:188]")
|
logging.writeToFile(str(msg) + "[outputExecutioner:188]")
|
||||||
|
|
||||||
|
|||||||
@@ -4208,14 +4208,14 @@ StrictHostKeyChecking no
|
|||||||
GitLogs(owner=self.web, type='INFO',
|
GitLogs(owner=self.web, type='INFO',
|
||||||
message='Running: %s' % (command)).save()
|
message='Running: %s' % (command)).save()
|
||||||
|
|
||||||
result = ProcessUtilities.outputExecutioner(command, self.web.externalApp)
|
result = ProcessUtilities.outputExecutioner(command, self.web.externalApp, None, self.folder)
|
||||||
GitLogs(owner=self.web, type='INFO',
|
GitLogs(owner=self.web, type='INFO',
|
||||||
message='Result: %s' % (result)).save()
|
message='Result: %s' % (result)).save()
|
||||||
else:
|
else:
|
||||||
GitLogs(owner=self.web, type='INFO',
|
GitLogs(owner=self.web, type='INFO',
|
||||||
message='Running: %s' % (gitConf['commands'])).save()
|
message='Running: %s' % (gitConf['commands'])).save()
|
||||||
|
|
||||||
result = ProcessUtilities.outputExecutioner(gitConf['commands'], self.web.externalApp)
|
result = ProcessUtilities.outputExecutioner(gitConf['commands'], self.web.externalApp, None, self.folder)
|
||||||
GitLogs(owner=self.web, type='INFO',
|
GitLogs(owner=self.web, type='INFO',
|
||||||
message='Result: %s' % (result)).save()
|
message='Result: %s' % (result)).save()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user