bug fix: docker install

This commit is contained in:
usmannasir
2024-02-07 15:08:40 +05:00
parent ca39cdbcc3
commit a22346d71b
2 changed files with 12 additions and 8 deletions

View File

@@ -10,7 +10,7 @@ import time
class DockerInstall: class DockerInstall:
@staticmethod @staticmethod
def submitInstallDocker(): def submitInstallDocker(CommandCP = 0):
try: try:
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w') statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
@@ -29,16 +29,20 @@ class DockerInstall:
else: else:
command = 'DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-compose' command = 'DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-compose'
if CommandCP:
ProcessUtilities.executioner(command, 'root', True)
else:
if not ServerStatusUtil.executioner(command, statusFile): if not ServerStatusUtil.executioner(command, statusFile):
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Failed to install Docker. [404]\n", 1) "Failed to install Docker. [404]\n", 1)
return 0 return 0
command = 'sudo systemctl enable docker' command = 'sudo systemctl enable docker'
ServerStatusUtil.executioner(command, statusFile)
ProcessUtilities.executioner(command, 'root', True)
command = 'sudo systemctl start docker' command = 'sudo systemctl start docker'
ServerStatusUtil.executioner(command, statusFile) ProcessUtilities.executioner(command, 'root', True)
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Docker successfully installed.[200]\n", 1) "Docker successfully installed.[200]\n", 1)

View File

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