Skip to content

Commit

Permalink
docker sites model
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Dec 11, 2023
1 parent 16835d8 commit d2cc487
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
28 changes: 28 additions & 0 deletions dockerManager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from django.db import models
from loginSystem.models import Administrator
from websiteFunctions.website import Websites

# Create your models here.
class Containers(models.Model):
Expand All @@ -16,3 +17,30 @@ class Containers(models.Model):
volumes = models.TextField(default="{}")
env = models.TextField(default="{}")
startOnReboot = models.IntegerField(default=0)

# Takes
# ComposePath, MySQLPath, MySQLRootPass, MySQLDBName, MySQLDBNUser, MySQLPassword, CPUsMySQL, MemoryMySQL,
# port, SitePath, CPUsSite, MemorySite, SiteName
# finalURL, blogTitle, adminUser, adminPassword, adminEmail

### Site Type 0=wp, further tbd later

class DockerSites(models.Model):
admin = models.ForeignKey(Websites, on_delete=models.CASCADE)
ComposePath = models.TextField()
SitePath = models.TextField()
MySQLPath = models.TextField()
state = models.IntegerField(default=1)
SiteType = models.IntegerField(default=0) ## WP, Joomla etc
MySQLDBName = models.CharField(max_length=100)
MySQLDBNUser = models.CharField(max_length=100)
CPUsMySQL = models.CharField(max_length=100)
MemoryMySQL = models.CharField(max_length=100)
port = models.CharField(max_length=100)
CPUsSite = models.CharField(max_length=100)
MemorySite = models.CharField(max_length=100)
SiteName = models.TextField()
finalURL = models.TextField()
blogTitle = models.TextField()
adminUser = models.CharField(max_length=100)
adminEmail = models.CharField(max_length=100)
17 changes: 11 additions & 6 deletions plogical/DockerSites.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/local/CyberCP/bin/python
import sys
sys.path.append('/usr/local/CyberCP')
import django
from plogical.processUtilities import ProcessUtilities
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging

Expand Down Expand Up @@ -30,8 +34,9 @@ def DeployWPContainer(self):


command = 'docker --help'
ReturnCode = ProcessUtilities.executioner(command)
if ReturnCode == 0:
result = ProcessUtilities.outputExecutioner(command)
print(f'return code of docker install {result}')
if result.find("not found") > -1:
status, message = self.InstallDocker()
if status == 0:
logging.statusWriter(self.JobID, 'Failed to installed docker. [404]')
Expand Down Expand Up @@ -124,17 +129,17 @@ def Main():
# port, SitePath, CPUsSite, MemorySite, SiteName
# finalURL, blogTitle, adminUser, adminPassword, adminEmail
data = {
"JobID": 1122344566667778888,
"ComposePath": "/home/dockercloudpagescloud/docker-compose.yml",
"MySQLPath": '/home/dockercloudpagescloud/public_html/sqldocker',
"JobID": '/home/cyberpanel/error-logs.txt',
"ComposePath": "/home/cyberpanel.net/docker-compose.yml",
"MySQLPath": '/home/cyberpanel.net/public_html/sqldocker',
"MySQLRootPass": 'testdbwp12345',
"MySQLDBName": 'testdbwp',
"MySQLDBNUser": 'testdbwp',
"MySQLPassword": 'testdbwp12345',
"CPUsMySQL": '2',
"MemoryMySQL": '512',
"port": '8000',
"SitePath": '/home/dockercloudpagescloud/public_html/wpdocker',
"SitePath": '/home/cyberpanel.net/public_html/wpdocker',
"CPUsSite": '2',
"MemorySite": '512',
"SiteName": 'wp docker test',
Expand Down

0 comments on commit d2cc487

Please sign in to comment.