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:
|
||||
return ACLManager.loadError()
|
||||
|
||||
|
||||
name = data['name']
|
||||
WPusername = data['WPusername']
|
||||
WPemail = data['WPemail']
|
||||
@@ -1211,3 +1210,55 @@ class ContainerManager(multi.Thread):
|
||||
data_ret = {'removeImageStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
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()
|
||||
elif self.function_run == 'SubmitDockersiteCreation':
|
||||
self.SubmitDockersiteCreation()
|
||||
elif self.function_run == 'DeployN8NContainer':
|
||||
self.DeployN8NContainer()
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
@@ -399,8 +401,12 @@ services:
|
||||
)
|
||||
dockersiteobj.save()
|
||||
|
||||
if self.data['App'] == 'WordPress':
|
||||
background = Docker_Sites('DeployWPContainer', f_data)
|
||||
background.start()
|
||||
elif self.data['App'] == 'n8n':
|
||||
background = Docker_Sites('DeployN8NContainer', f_data)
|
||||
background.start()
|
||||
|
||||
except BaseException as msg:
|
||||
logging.writeToFile("Error Submit Docker site Creation ....... %s" % str(msg))
|
||||
@@ -549,6 +555,38 @@ services:
|
||||
self.DeleteDockerApp()
|
||||
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
|
||||
|
||||
def DeployN8NContainer(self):
|
||||
@@ -578,42 +616,38 @@ volumes:
|
||||
|
||||
services:
|
||||
'{self.data['ServiceName']}-db':
|
||||
image: postgres:11
|
||||
image: docker.io/bitnami/postgresql:16
|
||||
user: root
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_USER:"root"
|
||||
- POSTGRES_PASSWORD:"{self.data['MySQLPassword']}"
|
||||
- POSTGRES_DB:"{self.data['MySQLDBName']}"
|
||||
- POSTGRES_NON_ROOT_USER:"{self.data['MySQLDBNUser']}"
|
||||
- POSTGRES_NON_ROOT_PASSWORD:"{self.data['MySQLPassword']}"
|
||||
# - POSTGRES_USER:root
|
||||
- POSTGRESQL_USERNAME={self.data['MySQLDBNUser']}
|
||||
- POSTGRESQL_DATABASE={self.data['MySQLDBName']}
|
||||
- POSTGRESQL_POSTGRES_PASSWORD={self.data['MySQLPassword']}
|
||||
- POSTGRESQL_PASSWORD={self.data['MySQLPassword']}
|
||||
volumes:
|
||||
- "/home/docker/{self.data['finalURL']}/db:/var/lib/postgresql/data"
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -h localhost -U "{self.data['MySQLDBNUser']}" -d "{self.data['MySQLDBName']}"']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
# - "/home/docker/{self.data['finalURL']}/db:/var/lib/postgresql/data"
|
||||
- "/home/docker/{self.data['finalURL']}/db:/bitnami/postgresql"
|
||||
|
||||
'{self.data['ServiceName']}':
|
||||
image: docker.n8n.io/n8nio/n8n
|
||||
user: root
|
||||
restart: always
|
||||
environment:
|
||||
- DB_TYPE=postgresdb
|
||||
- DB_POSTGRESDB_HOST='{self.data['ServiceName']}-db'
|
||||
- DB_POSTGRESDB_HOST={self.data['ServiceName']}-db
|
||||
- DB_POSTGRESDB_PORT=5432
|
||||
- DB_POSTGRESDB_DATABASE="{self.data['MySQLDBName']}"
|
||||
- DB_POSTGRESDB_USER="{self.data['MySQLDBNUser']}"
|
||||
- DB_POSTGRESDB_PASSWORD="{self.data['MySQLPassword']}"
|
||||
- DB_POSTGRESDB_DATABASE={self.data['MySQLDBName']}
|
||||
- DB_POSTGRESDB_USER={self.data['MySQLDBNUser']}
|
||||
- DB_POSTGRESDB_PASSWORD={self.data['MySQLPassword']}
|
||||
ports:
|
||||
- "{self.data['port']}:5678"
|
||||
links:
|
||||
- postgres
|
||||
- {self.data['ServiceName']}-db
|
||||
volumes:
|
||||
- n8n_storage:/home/node/.n8n
|
||||
- "/home/docker/{self.data['finalURL']}/data:/home/node/.n8n"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
- '{self.data['ServiceName']}-db'
|
||||
'''
|
||||
|
||||
### WriteConfig to compose-file
|
||||
@@ -666,13 +700,13 @@ services:
|
||||
execPath = execPath + f" SetupHTAccess --port {self.data['port']} --htaccess {self.data['htaccessPath']}"
|
||||
ProcessUtilities.executioner(execPath, self.data['externalApp'])
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
group = 'nobody'
|
||||
else:
|
||||
group = 'nogroup'
|
||||
|
||||
command = f"chown -R nobody:{group} /home/docker/{self.data['finalURL']}/data"
|
||||
ProcessUtilities.executioner(command)
|
||||
# if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
# group = 'nobody'
|
||||
# else:
|
||||
# group = 'nogroup'
|
||||
#
|
||||
# command = f"chown -R nobody:{group} /home/docker/{self.data['finalURL']}/data"
|
||||
# ProcessUtilities.executioner(command)
|
||||
|
||||
### just restart ls for htaccess
|
||||
|
||||
@@ -710,7 +744,7 @@ def Main():
|
||||
# port, SitePath, CPUsSite, MemorySite, SiteName
|
||||
# finalURL, blogTitle, adminUser, adminPassword, adminEmail, htaccessPath, externalApp
|
||||
data = {
|
||||
"JobID": '/home/cyberpanel/error-logs.txt',
|
||||
"JobID": '/home/cyberpanel/hey.txt',
|
||||
"ComposePath": "/home/docker.cyberpanel.net/docker-compose.yml",
|
||||
"MySQLPath": '/home/docker.cyberpanel.net/public_html/sqldocker',
|
||||
"MySQLRootPass": 'testdbwp12345',
|
||||
@@ -734,7 +768,7 @@ def Main():
|
||||
"docRoot": "/home/docker.cyberpanel.net"
|
||||
}
|
||||
ds = Docker_Sites('', data)
|
||||
ds.DeployWPContainer()
|
||||
ds.DeployN8NContainer()
|
||||
|
||||
elif args.function == 'DeleteDockerApp':
|
||||
data = {
|
||||
|
||||
@@ -169,7 +169,8 @@
|
||||
<label class="col-sm-3 control-label">{% trans "Select App" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="App" class="form-control">
|
||||
<option>Wordpress</option>
|
||||
<option>WordPress</option>
|
||||
<option>n8n</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6663,7 +6663,7 @@ StrictHostKeyChecking no
|
||||
if PackageAssignment.objects.all().count() == 0:
|
||||
|
||||
name = 'Default'
|
||||
cpu = 1
|
||||
cpu = 2
|
||||
Memory = 1024
|
||||
Bandwidth = '100'
|
||||
disk = '100'
|
||||
@@ -6866,23 +6866,7 @@ StrictHostKeyChecking no
|
||||
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Blacklisted domain."}
|
||||
json_data = json.dumps(data_ret)
|
||||
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))
|
||||
data = {}
|
||||
|
||||
@@ -6899,6 +6883,7 @@ StrictHostKeyChecking no
|
||||
data['WPusername'] = WPusername
|
||||
data['WPpasswd'] = WPpasswd
|
||||
data['externalApp'] = "".join(re.findall("[a-zA-Z]+", Domain))[:5] + str(randint(1000, 9999))
|
||||
data['App'] = App
|
||||
|
||||
background = Docker_Sites('SubmitDockersiteCreation', data)
|
||||
background.start()
|
||||
|
||||
Reference in New Issue
Block a user