mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
Merge branch 'v2.3.5-dev' of https://github.com/usmannasir/cyberpanel into v2.3.5-dev
This commit is contained in:
@@ -1175,7 +1175,6 @@ class ContainerManager(multi.Thread):
|
|||||||
if admin.acl.adminStatus != 1:
|
if admin.acl.adminStatus != 1:
|
||||||
return ACLManager.loadError()
|
return ACLManager.loadError()
|
||||||
|
|
||||||
|
|
||||||
name = data['name']
|
name = data['name']
|
||||||
WPusername = data['WPusername']
|
WPusername = data['WPusername']
|
||||||
WPemail = data['WPemail']
|
WPemail = data['WPemail']
|
||||||
@@ -1211,3 +1210,55 @@ class ContainerManager(multi.Thread):
|
|||||||
data_ret = {'removeImageStatus': 0, 'error_message': str(msg)}
|
data_ret = {'removeImageStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
def RestartContainerAPP(self, userID=None, data=None):
|
||||||
|
try:
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
if admin.acl.adminStatus != 1:
|
||||||
|
return ACLManager.loadError()
|
||||||
|
|
||||||
|
name = data['name']
|
||||||
|
containerID = data['id']
|
||||||
|
|
||||||
|
passdata = {}
|
||||||
|
passdata['containerID'] = containerID
|
||||||
|
|
||||||
|
da = Docker_Sites(None, passdata)
|
||||||
|
retdata = da.RestartContainer()
|
||||||
|
|
||||||
|
|
||||||
|
data_ret = {'status': 1, 'error_message': 'None', 'data':retdata}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
data_ret = {'removeImageStatus': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
def StopContainerAPP(self, userID=None, data=None):
|
||||||
|
try:
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
|
if admin.acl.adminStatus != 1:
|
||||||
|
return ACLManager.loadError()
|
||||||
|
|
||||||
|
name = data['name']
|
||||||
|
containerID = data['id']
|
||||||
|
|
||||||
|
passdata = {}
|
||||||
|
passdata['containerID'] = containerID
|
||||||
|
|
||||||
|
da = Docker_Sites(None, passdata)
|
||||||
|
retdata = da.StopContainer()
|
||||||
|
|
||||||
|
|
||||||
|
data_ret = {'status': 1, 'error_message': 'None', 'data':retdata}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
data_ret = {'removeImageStatus': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
@@ -37,6 +37,8 @@ class Docker_Sites(multi.Thread):
|
|||||||
self.DeployWPContainer()
|
self.DeployWPContainer()
|
||||||
elif self.function_run == 'SubmitDockersiteCreation':
|
elif self.function_run == 'SubmitDockersiteCreation':
|
||||||
self.SubmitDockersiteCreation()
|
self.SubmitDockersiteCreation()
|
||||||
|
elif self.function_run == 'DeployN8NContainer':
|
||||||
|
self.DeployN8NContainer()
|
||||||
|
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
@@ -399,8 +401,12 @@ services:
|
|||||||
)
|
)
|
||||||
dockersiteobj.save()
|
dockersiteobj.save()
|
||||||
|
|
||||||
|
if self.data['App'] == 'WordPress':
|
||||||
background = Docker_Sites('DeployWPContainer', f_data)
|
background = Docker_Sites('DeployWPContainer', f_data)
|
||||||
background.start()
|
background.start()
|
||||||
|
elif self.data['App'] == 'n8n':
|
||||||
|
background = Docker_Sites('DeployN8NContainer', f_data)
|
||||||
|
background.start()
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
logging.writeToFile("Error Submit Docker site Creation ....... %s" % str(msg))
|
logging.writeToFile("Error Submit Docker site Creation ....... %s" % str(msg))
|
||||||
@@ -549,6 +555,38 @@ services:
|
|||||||
self.DeleteDockerApp()
|
self.DeleteDockerApp()
|
||||||
self.SubmitDockersiteCreation()
|
self.SubmitDockersiteCreation()
|
||||||
|
|
||||||
|
def RestartContainer(self):
|
||||||
|
try:
|
||||||
|
import docker
|
||||||
|
# Create a Docker client
|
||||||
|
client = docker.from_env()
|
||||||
|
|
||||||
|
# Get the container by ID
|
||||||
|
container = client.containers.get(self.data['containerID'])
|
||||||
|
|
||||||
|
container.restart()
|
||||||
|
|
||||||
|
return 1, None
|
||||||
|
except BaseException as msg:
|
||||||
|
logging.writeToFile("List Container ....... %s" % str(msg))
|
||||||
|
return 0, str(msg)
|
||||||
|
|
||||||
|
def StopContainer(self):
|
||||||
|
try:
|
||||||
|
import docker
|
||||||
|
# Create a Docker client
|
||||||
|
client = docker.from_env()
|
||||||
|
|
||||||
|
# Get the container by ID
|
||||||
|
container = client.containers.get(self.data['containerID'])
|
||||||
|
|
||||||
|
container.stop()
|
||||||
|
|
||||||
|
return 1, None
|
||||||
|
except BaseException as msg:
|
||||||
|
logging.writeToFile("List Container ....... %s" % str(msg))
|
||||||
|
return 0, str(msg)
|
||||||
|
|
||||||
##### N8N Container
|
##### N8N Container
|
||||||
|
|
||||||
def DeployN8NContainer(self):
|
def DeployN8NContainer(self):
|
||||||
@@ -578,42 +616,38 @@ volumes:
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
'{self.data['ServiceName']}-db':
|
'{self.data['ServiceName']}-db':
|
||||||
image: postgres:11
|
image: docker.io/bitnami/postgresql:16
|
||||||
|
user: root
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER:"root"
|
# - POSTGRES_USER:root
|
||||||
- POSTGRES_PASSWORD:"{self.data['MySQLPassword']}"
|
- POSTGRESQL_USERNAME={self.data['MySQLDBNUser']}
|
||||||
- POSTGRES_DB:"{self.data['MySQLDBName']}"
|
- POSTGRESQL_DATABASE={self.data['MySQLDBName']}
|
||||||
- POSTGRES_NON_ROOT_USER:"{self.data['MySQLDBNUser']}"
|
- POSTGRESQL_POSTGRES_PASSWORD={self.data['MySQLPassword']}
|
||||||
- POSTGRES_NON_ROOT_PASSWORD:"{self.data['MySQLPassword']}"
|
- POSTGRESQL_PASSWORD={self.data['MySQLPassword']}
|
||||||
volumes:
|
volumes:
|
||||||
- "/home/docker/{self.data['finalURL']}/db:/var/lib/postgresql/data"
|
# - "/home/docker/{self.data['finalURL']}/db:/var/lib/postgresql/data"
|
||||||
healthcheck:
|
- "/home/docker/{self.data['finalURL']}/db:/bitnami/postgresql"
|
||||||
test: ['CMD-SHELL', 'pg_isready -h localhost -U "{self.data['MySQLDBNUser']}" -d "{self.data['MySQLDBName']}"']
|
|
||||||
interval: 5s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 10
|
|
||||||
|
|
||||||
'{self.data['ServiceName']}':
|
'{self.data['ServiceName']}':
|
||||||
image: docker.n8n.io/n8nio/n8n
|
image: docker.n8n.io/n8nio/n8n
|
||||||
|
user: root
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- DB_TYPE=postgresdb
|
- DB_TYPE=postgresdb
|
||||||
- DB_POSTGRESDB_HOST='{self.data['ServiceName']}-db'
|
- DB_POSTGRESDB_HOST={self.data['ServiceName']}-db
|
||||||
- DB_POSTGRESDB_PORT=5432
|
- DB_POSTGRESDB_PORT=5432
|
||||||
- DB_POSTGRESDB_DATABASE="{self.data['MySQLDBName']}"
|
- DB_POSTGRESDB_DATABASE={self.data['MySQLDBName']}
|
||||||
- DB_POSTGRESDB_USER="{self.data['MySQLDBNUser']}"
|
- DB_POSTGRESDB_USER={self.data['MySQLDBNUser']}
|
||||||
- DB_POSTGRESDB_PASSWORD="{self.data['MySQLPassword']}"
|
- DB_POSTGRESDB_PASSWORD={self.data['MySQLPassword']}
|
||||||
ports:
|
ports:
|
||||||
- "{self.data['port']}:5678"
|
- "{self.data['port']}:5678"
|
||||||
links:
|
links:
|
||||||
- postgres
|
- {self.data['ServiceName']}-db
|
||||||
volumes:
|
volumes:
|
||||||
- n8n_storage:/home/node/.n8n
|
|
||||||
- "/home/docker/{self.data['finalURL']}/data:/home/node/.n8n"
|
- "/home/docker/{self.data['finalURL']}/data:/home/node/.n8n"
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
- '{self.data['ServiceName']}-db'
|
||||||
condition: service_healthy
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
### WriteConfig to compose-file
|
### WriteConfig to compose-file
|
||||||
@@ -666,13 +700,13 @@ services:
|
|||||||
execPath = execPath + f" SetupHTAccess --port {self.data['port']} --htaccess {self.data['htaccessPath']}"
|
execPath = execPath + f" SetupHTAccess --port {self.data['port']} --htaccess {self.data['htaccessPath']}"
|
||||||
ProcessUtilities.executioner(execPath, self.data['externalApp'])
|
ProcessUtilities.executioner(execPath, self.data['externalApp'])
|
||||||
|
|
||||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
# if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||||
group = 'nobody'
|
# group = 'nobody'
|
||||||
else:
|
# else:
|
||||||
group = 'nogroup'
|
# group = 'nogroup'
|
||||||
|
#
|
||||||
command = f"chown -R nobody:{group} /home/docker/{self.data['finalURL']}/data"
|
# command = f"chown -R nobody:{group} /home/docker/{self.data['finalURL']}/data"
|
||||||
ProcessUtilities.executioner(command)
|
# ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
### just restart ls for htaccess
|
### just restart ls for htaccess
|
||||||
|
|
||||||
@@ -710,7 +744,7 @@ def Main():
|
|||||||
# port, SitePath, CPUsSite, MemorySite, SiteName
|
# port, SitePath, CPUsSite, MemorySite, SiteName
|
||||||
# finalURL, blogTitle, adminUser, adminPassword, adminEmail, htaccessPath, externalApp
|
# finalURL, blogTitle, adminUser, adminPassword, adminEmail, htaccessPath, externalApp
|
||||||
data = {
|
data = {
|
||||||
"JobID": '/home/cyberpanel/error-logs.txt',
|
"JobID": '/home/cyberpanel/hey.txt',
|
||||||
"ComposePath": "/home/docker.cyberpanel.net/docker-compose.yml",
|
"ComposePath": "/home/docker.cyberpanel.net/docker-compose.yml",
|
||||||
"MySQLPath": '/home/docker.cyberpanel.net/public_html/sqldocker',
|
"MySQLPath": '/home/docker.cyberpanel.net/public_html/sqldocker',
|
||||||
"MySQLRootPass": 'testdbwp12345',
|
"MySQLRootPass": 'testdbwp12345',
|
||||||
@@ -734,7 +768,7 @@ def Main():
|
|||||||
"docRoot": "/home/docker.cyberpanel.net"
|
"docRoot": "/home/docker.cyberpanel.net"
|
||||||
}
|
}
|
||||||
ds = Docker_Sites('', data)
|
ds = Docker_Sites('', data)
|
||||||
ds.DeployWPContainer()
|
ds.DeployN8NContainer()
|
||||||
|
|
||||||
elif args.function == 'DeleteDockerApp':
|
elif args.function == 'DeleteDockerApp':
|
||||||
data = {
|
data = {
|
||||||
|
|||||||
@@ -169,7 +169,8 @@
|
|||||||
<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>WordPress</option>
|
||||||
|
<option>n8n</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6663,7 +6663,7 @@ StrictHostKeyChecking no
|
|||||||
if PackageAssignment.objects.all().count() == 0:
|
if PackageAssignment.objects.all().count() == 0:
|
||||||
|
|
||||||
name = 'Default'
|
name = 'Default'
|
||||||
cpu = 1
|
cpu = 2
|
||||||
Memory = 1024
|
Memory = 1024
|
||||||
Bandwidth = '100'
|
Bandwidth = '100'
|
||||||
disk = '100'
|
disk = '100'
|
||||||
@@ -6866,23 +6866,7 @@ StrictHostKeyChecking no
|
|||||||
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Blacklisted domain."}
|
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Blacklisted domain."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
# extraArgs = {}
|
|
||||||
# extraArgs['admin'] = admin
|
|
||||||
# extraArgs['domainName'] = data['domain']
|
|
||||||
# extraArgs['home'] = data['home']
|
|
||||||
# extraArgs['shopName'] = data['shopName']
|
|
||||||
# extraArgs['firstName'] = data['firstName']
|
|
||||||
# extraArgs['lastName'] = data['lastName']
|
|
||||||
# extraArgs['databasePrefix'] = data['databasePrefix']
|
|
||||||
# extraArgs['email'] = data['email']
|
|
||||||
# extraArgs['password'] = data['passwordByPass']
|
|
||||||
# extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
|
||||||
#
|
|
||||||
# if data['home'] == '0':
|
|
||||||
# extraArgs['path'] = data['path']
|
|
||||||
#
|
|
||||||
# background = ApplicationInstaller('prestashop', extraArgs)
|
|
||||||
# background.start()
|
|
||||||
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
@@ -6899,6 +6883,7 @@ StrictHostKeyChecking no
|
|||||||
data['WPusername'] = WPusername
|
data['WPusername'] = WPusername
|
||||||
data['WPpasswd'] = WPpasswd
|
data['WPpasswd'] = WPpasswd
|
||||||
data['externalApp'] = "".join(re.findall("[a-zA-Z]+", Domain))[:5] + str(randint(1000, 9999))
|
data['externalApp'] = "".join(re.findall("[a-zA-Z]+", Domain))[:5] + str(randint(1000, 9999))
|
||||||
|
data['App'] = App
|
||||||
|
|
||||||
background = Docker_Sites('SubmitDockersiteCreation', data)
|
background = Docker_Sites('SubmitDockersiteCreation', data)
|
||||||
background.start()
|
background.start()
|
||||||
|
|||||||
Reference in New Issue
Block a user