mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-11 15:56:11 +01:00
bug fix: encoding and python path
This commit is contained in:
@@ -3,9 +3,9 @@ Description = CyberPanel SSH Websocket Daemon
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
ExecStart = /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/WebTerminal/servCTRL.py start
|
ExecStart = /usr/local/CyberCP/bin/python /usr/local/CyberCP/WebTerminal/servCTRL.py start
|
||||||
ExecStop = /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/WebTerminal/servCTRL.py stop
|
ExecStop = /usr/local/CyberCP/bin/python /usr/local/CyberCP/WebTerminal/servCTRL.py stop
|
||||||
Restart = /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/WebTerminal/servCTRL.py restart
|
Restart = /usr/local/CyberCP/bin/python /usr/local/CyberCP/WebTerminal/servCTRL.py restart
|
||||||
Restart=on-abnormal
|
Restart=on-abnormal
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ class FirewallManager:
|
|||||||
else:
|
else:
|
||||||
return ACLManager.loadErrorJson()
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
command = 'sudo systemctl status firewalld'
|
command = 'systemctl status firewalld'
|
||||||
status = ProcessUtilities.outputExecutioner(command)
|
status = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
if status.find("dead") > -1:
|
if status.find("dead") > -1:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import socket
|
|||||||
import threading as multi
|
import threading as multi
|
||||||
import time
|
import time
|
||||||
import getpass
|
import getpass
|
||||||
|
import codecs
|
||||||
|
|
||||||
class ProcessUtilities(multi.Thread):
|
class ProcessUtilities(multi.Thread):
|
||||||
litespeedProcess = "litespeed"
|
litespeedProcess = "litespeed"
|
||||||
@@ -167,12 +168,6 @@ class ProcessUtilities(multi.Thread):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def sendCommand(command, user=None):
|
def sendCommand(command, user=None):
|
||||||
try:
|
try:
|
||||||
# if user == None:
|
|
||||||
# pass
|
|
||||||
# else:
|
|
||||||
# cmd = 'usermod -a -G %s %s' % ('cyberpanel', user)
|
|
||||||
# ProcessUtilities.executioner(cmd)
|
|
||||||
|
|
||||||
ret = ProcessUtilities.setupUDSConnection()
|
ret = ProcessUtilities.setupUDSConnection()
|
||||||
|
|
||||||
if ret[0] == -1:
|
if ret[0] == -1:
|
||||||
@@ -193,18 +188,23 @@ class ProcessUtilities(multi.Thread):
|
|||||||
sock.sendall(command.encode('utf-8'))
|
sock.sendall(command.encode('utf-8'))
|
||||||
|
|
||||||
data = ""
|
data = ""
|
||||||
|
dataSTR = ""
|
||||||
|
|
||||||
while (1):
|
while (1):
|
||||||
currentData = sock.recv(32)
|
currentData = sock.recv(32)
|
||||||
if len(currentData) == 0 or currentData == None:
|
if len(currentData) == 0 or currentData == None:
|
||||||
break
|
break
|
||||||
data = data + currentData.decode("utf-8")
|
try:
|
||||||
|
data = data + currentData.decode(encoding = 'UTF-8',errors = 'ignore')
|
||||||
|
except BaseException as msg:
|
||||||
|
logging.writeToFile('Some data could not be decoded to str, error message: %s' % str(msg))
|
||||||
|
|
||||||
|
dataSTR = dataSTR + str(currentData)
|
||||||
|
|
||||||
|
|
||||||
sock.close()
|
sock.close()
|
||||||
|
logging.writeToFile('Final data: %s.' % (dataSTR))
|
||||||
logging.writeToFile(data)
|
return data, dataSTR
|
||||||
|
|
||||||
return data
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
logging.writeToFile(str(msg) + " [sendCommand]")
|
logging.writeToFile(str(msg) + " [sendCommand]")
|
||||||
return "0" + str(msg)
|
return "0" + str(msg)
|
||||||
@@ -216,10 +216,10 @@ class ProcessUtilities(multi.Thread):
|
|||||||
ProcessUtilities.normalExecutioner(command)
|
ProcessUtilities.normalExecutioner(command)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
ret = ProcessUtilities.sendCommand(command, user)
|
ret, dataSTR = ProcessUtilities.sendCommand(command, user)
|
||||||
|
|
||||||
exitCode = ret[len(ret) -1]
|
exitCode = ret[len(ret) -1]
|
||||||
exitCode = int(exitCode.encode('hex'), 16)
|
exitCode = int(codecs.encode(exitCode.encode(), 'hex'))
|
||||||
|
|
||||||
if exitCode == 0:
|
if exitCode == 0:
|
||||||
return 1
|
return 1
|
||||||
@@ -238,8 +238,8 @@ class ProcessUtilities(multi.Thread):
|
|||||||
|
|
||||||
if type(command) == list:
|
if type(command) == list:
|
||||||
command = " ".join(command)
|
command = " ".join(command)
|
||||||
|
data, dataSTR = ProcessUtilities.sendCommand(command, user)
|
||||||
return ProcessUtilities.sendCommand(command, user)[:-1]
|
return dataSTR[:-1]
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
logging.writeToFile(str(msg) + "[outputExecutioner:188]")
|
logging.writeToFile(str(msg) + "[outputExecutioner:188]")
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
## Then run it like below.
|
## Then run it like below.
|
||||||
## /usr/local/CyberCP/upgrade.sh
|
## /usr/local/CyberCP/upgrade.sh
|
||||||
|
|
||||||
cd /usr/local/CyberCP && /usr/local/CyberCP/bin/python2 manage.py collectstatic --no-input
|
cd /usr/local/CyberCP && /usr/local/CyberCP/bin/python manage.py collectstatic --no-input
|
||||||
rm -rf /usr/local/CyberCP/public/static/*
|
rm -rf /usr/local/CyberCP/public/static/*
|
||||||
cp -R /usr/local/CyberCP/static/* /usr/local/CyberCP/public/static/
|
cp -R /usr/local/CyberCP/static/* /usr/local/CyberCP/public/static/
|
||||||
find /usr/local/CyberCP -type d -exec chmod 0755 {} \;
|
find /usr/local/CyberCP -type d -exec chmod 0755 {} \;
|
||||||
|
|||||||
Reference in New Issue
Block a user