mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-11 15:56:11 +01:00
several bug fixes to docker apps feature
This commit is contained in:
@@ -1098,7 +1098,6 @@ class ContainerManager(multi.Thread):
|
|||||||
da = Docker_Sites(None, passdata)
|
da = Docker_Sites(None, passdata)
|
||||||
retdata = da.ListContainers()
|
retdata = da.ListContainers()
|
||||||
|
|
||||||
|
|
||||||
data_ret = {'status': 1, 'error_message': 'None', 'data':retdata}
|
data_ret = {'status': 1, 'error_message': 'None', 'data':retdata}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/local/CyberCP/bin/python
|
#!/usr/local/CyberCP/bin/python
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
sys.path.append('/usr/local/CyberCP')
|
sys.path.append('/usr/local/CyberCP')
|
||||||
import plogical.CyberCPLogFileWriter as logging
|
import plogical.CyberCPLogFileWriter as logging
|
||||||
@@ -20,6 +21,12 @@ class DockerInstall:
|
|||||||
|
|
||||||
if ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
if ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||||
|
|
||||||
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(f'Docker installation started for cent8/9')
|
||||||
|
|
||||||
|
command = 'sudo yum install -y yum-utils'
|
||||||
|
ServerStatusUtil.executioner(command, statusFile)
|
||||||
|
|
||||||
command = 'yum install yum-utils -y'
|
command = 'yum install yum-utils -y'
|
||||||
ServerStatusUtil.executioner(command, statusFile)
|
ServerStatusUtil.executioner(command, statusFile)
|
||||||
|
|
||||||
|
|||||||
@@ -421,6 +421,7 @@ def removeImage(request):
|
|||||||
return coreResult
|
return coreResult
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
@preDockerRun
|
@preDockerRun
|
||||||
def getDockersiteList(request):
|
def getDockersiteList(request):
|
||||||
import json
|
import json
|
||||||
|
|||||||
@@ -98,8 +98,6 @@ class Docker_Sites(multi.Thread):
|
|||||||
ProcessUtilities.executioner(execPath)
|
ProcessUtilities.executioner(execPath)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
if self.function_run == 'DeployWPContainer':
|
if self.function_run == 'DeployWPContainer':
|
||||||
@@ -233,9 +231,16 @@ REWRITERULE ^(.*)$ HTTP://docker{port}/$1 [P]
|
|||||||
|
|
||||||
command = 'docker --help'
|
command = 'docker --help'
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
result = ProcessUtilities.outputExecutioner(command)
|
||||||
print(f'return code of docker install {result}')
|
|
||||||
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
logging.writeToFile(f'return code of docker install {result}')
|
||||||
|
|
||||||
if result.find("not found") > -1:
|
if result.find("not found") > -1:
|
||||||
DockerInstall.submitInstallDocker(1)
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
logging.writeToFile(f'About to run docker install function...')
|
||||||
|
|
||||||
|
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/dockerManager/dockerInstall.py"
|
||||||
|
ProcessUtilities.executioner(execPath)
|
||||||
|
|
||||||
logging.statusWriter(self.JobID, 'Docker is ready to use..,10')
|
logging.statusWriter(self.JobID, 'Docker is ready to use..,10')
|
||||||
|
|
||||||
@@ -316,7 +321,12 @@ services:
|
|||||||
|
|
||||||
####
|
####
|
||||||
|
|
||||||
command = f"docker-compose -f {self.data['ComposePath']} -p '{self.data['SiteName']}' up -d"
|
if ProcessUtilities.decideDistro() == ProcessUtilities.cent8 or ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||||
|
dockerCommand = 'docker compose'
|
||||||
|
else:
|
||||||
|
dockerCommand = 'docker-compose'
|
||||||
|
|
||||||
|
command = f"{dockerCommand} -f {self.data['ComposePath']} -p '{self.data['SiteName']}' up -d"
|
||||||
result, message = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
result, message = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
if os.path.exists(ProcessUtilities.debugPath):
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
@@ -330,6 +340,25 @@ services:
|
|||||||
|
|
||||||
time.sleep(25)
|
time.sleep(25)
|
||||||
|
|
||||||
|
### checking if everything ran properly
|
||||||
|
|
||||||
|
passdata = {}
|
||||||
|
passdata["JobID"] = None
|
||||||
|
passdata['name'] = self.data['ServiceName']
|
||||||
|
da = Docker_Sites(None, passdata)
|
||||||
|
retdata, containers = da.ListContainers()
|
||||||
|
|
||||||
|
containers = json.loads(containers)
|
||||||
|
|
||||||
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
logging.writeToFile(str(containers))
|
||||||
|
|
||||||
|
### it means less then two containers which means something went wrong
|
||||||
|
if len(containers) < 2:
|
||||||
|
logging.writeToFile(f'Unkonwn error, containers not running. [DeployWPContainer]')
|
||||||
|
logging.statusWriter(self.JobID, f'Unkonwn error, containers not running. [DeployWPContainer]')
|
||||||
|
return 0
|
||||||
|
|
||||||
### Set up Proxy
|
### Set up Proxy
|
||||||
|
|
||||||
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/DockerSites.py"
|
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/DockerSites.py"
|
||||||
@@ -572,6 +601,10 @@ services:
|
|||||||
command = f'docker rm {container.short_id}'
|
command = f'docker rm {container.short_id}'
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
|
||||||
|
command = f"rm -rf /home/{self.data['domain']}/public_html/.htaccess'"
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
from plogical.installUtilities import installUtilities
|
from plogical.installUtilities import installUtilities
|
||||||
installUtilities.reStartLiteSpeed()
|
installUtilities.reStartLiteSpeed()
|
||||||
|
|
||||||
@@ -718,9 +751,16 @@ services:
|
|||||||
|
|
||||||
command = 'docker --help'
|
command = 'docker --help'
|
||||||
result = ProcessUtilities.outputExecutioner(command)
|
result = ProcessUtilities.outputExecutioner(command)
|
||||||
print(f'return code of docker install {result}')
|
|
||||||
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
logging.writeToFile(f'return code of docker install {result}')
|
||||||
|
|
||||||
if result.find("not found") > -1:
|
if result.find("not found") > -1:
|
||||||
DockerInstall.submitInstallDocker()
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
logging.writeToFile(f'About to run docker install function...')
|
||||||
|
|
||||||
|
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/dockerManager/dockerInstall.py"
|
||||||
|
ProcessUtilities.executioner(execPath)
|
||||||
|
|
||||||
logging.statusWriter(self.JobID, 'Docker is ready to use..,10')
|
logging.statusWriter(self.JobID, 'Docker is ready to use..,10')
|
||||||
|
|
||||||
@@ -799,9 +839,15 @@ services:
|
|||||||
|
|
||||||
####
|
####
|
||||||
|
|
||||||
command = f"docker-compose -f {self.data['ComposePath']} -p '{self.data['SiteName']}' up -d"
|
if ProcessUtilities.decideDistro() == ProcessUtilities.cent8 or ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||||
|
dockerCommand = 'docker compose'
|
||||||
|
else:
|
||||||
|
dockerCommand = 'docker-compose'
|
||||||
|
|
||||||
|
command = f"{dockerCommand} -f {self.data['ComposePath']} -p '{self.data['SiteName']}' up -d"
|
||||||
result, message = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
result, message = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
|
||||||
|
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
logging.statusWriter(self.JobID, f'Error {str(message)} . [404]')
|
logging.statusWriter(self.JobID, f'Error {str(message)} . [404]')
|
||||||
return 0
|
return 0
|
||||||
@@ -810,6 +856,26 @@ services:
|
|||||||
|
|
||||||
time.sleep(25)
|
time.sleep(25)
|
||||||
|
|
||||||
|
|
||||||
|
### checking if everything ran properly
|
||||||
|
|
||||||
|
passdata = {}
|
||||||
|
passdata["JobID"] = None
|
||||||
|
passdata['name'] = self.data['ServiceName']
|
||||||
|
da = Docker_Sites(None, passdata)
|
||||||
|
retdata, containers = da.ListContainers()
|
||||||
|
|
||||||
|
containers = json.loads(containers)
|
||||||
|
|
||||||
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
logging.writeToFile(str(containers))
|
||||||
|
|
||||||
|
### it means less then two containers which means something went wrong
|
||||||
|
if len(containers) < 2:
|
||||||
|
logging.writeToFile(f'Unkonwn error, containers not running. [DeployN8NContainer]')
|
||||||
|
logging.statusWriter(self.JobID, f'Unkonwn error, containers not running. [DeployN8NContainer]')
|
||||||
|
return 0
|
||||||
|
|
||||||
### Set up Proxy
|
### Set up Proxy
|
||||||
|
|
||||||
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/DockerSites.py"
|
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/DockerSites.py"
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ class ServerStatusUtil(multi.Thread):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def executioner(command, statusFile):
|
def executioner(command, statusFile):
|
||||||
try:
|
try:
|
||||||
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(command)
|
||||||
|
|
||||||
res = subprocess.call(command, stdout=statusFile, stderr=statusFile, shell=True)
|
res = subprocess.call(command, stdout=statusFile, stderr=statusFile, shell=True)
|
||||||
if res == 1:
|
if res == 1:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -169,7 +169,6 @@
|
|||||||
<label class="col-sm-3 control-label">{% trans "Select App" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Select App" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<select ng-model="App" class="form-control">
|
<select ng-model="App" class="form-control">
|
||||||
<option>WordPress</option>
|
|
||||||
<option>n8n</option>
|
<option>n8n</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user