mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 21:35:55 +01:00
docker sites
This commit is contained in:
41
dockerManager/Dockerfile
Normal file
41
dockerManager/Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
||||
# Use Debian as the base image
|
||||
FROM debian:11.0
|
||||
|
||||
# Install required dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y wget gnupg ca-certificates
|
||||
|
||||
# Install OpenLiteSpeed
|
||||
RUN wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debian_repo.sh | bash
|
||||
|
||||
RUN apt-get install -y openlitespeed
|
||||
|
||||
# Install PHP and required PHP extensions for WordPress
|
||||
RUN apt-get install -y lsphp82*
|
||||
|
||||
###
|
||||
|
||||
RUN rm -rf /usr/local/lsws/Example/html/*
|
||||
|
||||
# Install WP CLI
|
||||
|
||||
RUN wget https://github.com/wp-cli/wp-cli/releases/download/v2.7.1/wp-cli-2.7.1.phar
|
||||
RUN chmod +x wp-cli-2.7.1.phar
|
||||
RUN mv wp-cli-2.7.1.phar /usr/bin/wp
|
||||
|
||||
## set up vh conf
|
||||
|
||||
RUN rm -f /usr/local/lsws/conf/vhosts/Example/vhconf.conf
|
||||
COPY ./vhconf.conf /usr/local/lsws/conf/vhosts/Example/vhconf.conf
|
||||
|
||||
# Expose necessary ports
|
||||
EXPOSE 8088
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
|
||||
# Set execute permissions
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
# Define entrypoint
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
29
dockerManager/docker-compose.yml
Normal file
29
dockerManager/docker-compose.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
wordpress:
|
||||
image: cyberpanel/openlitespeed:latest
|
||||
ports:
|
||||
- "8000:8088"
|
||||
# - "443:443"
|
||||
environment:
|
||||
DB_NAME: "wordpress"
|
||||
DB_USER: "wpuser"
|
||||
DB_PASSWORD: "wppassword"
|
||||
WP_ADMIN_EMAIL: "admin@example.com"
|
||||
WP_ADMIN_USER: "admin"
|
||||
WP_ADMIN_PASSWORD: "adminpass"
|
||||
WP_URL: docker.cyberpanel.net
|
||||
DB_Host: mariadb:3306
|
||||
SITE_NAME: "CyberPanel Docker Site"
|
||||
depends_on:
|
||||
- mariadb
|
||||
mariadb:
|
||||
image: mariadb
|
||||
restart: always
|
||||
environment:
|
||||
ALLOW_EMPTY_PASSWORD=no
|
||||
MYSQL_DATABASE: 'wordpress'
|
||||
MYSQL_USER: 'wpuser'
|
||||
MYSQL_PASSWORD: 'wppassword'
|
||||
MYSQL_ROOT_PASSWORD: 'rootpassword'
|
||||
31
dockerManager/entrypoint.sh
Normal file
31
dockerManager/entrypoint.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Environment variables for WordPress installation
|
||||
DB_NAME=${DB_NAME:-"wordpress"}
|
||||
DB_USER=${DB_USER:-"wpuser"}
|
||||
DB_PASSWORD=${DB_PASSWORD:-"wppassword"}
|
||||
WP_ADMIN_EMAIL=${WP_ADMIN_EMAIL:-"admin@example.com"}
|
||||
WP_ADMIN_USER=${WP_ADMIN_USER:-"admin"}
|
||||
WP_ADMIN_PASSWORD=${WP_ADMIN_PASSWORD:-"adminpass"}
|
||||
WP_URL=${WP_URL:-"docker.cyberpanel.net"}
|
||||
DB_Host=${DB_Host:-"mariadb:3306"}
|
||||
SITE_NAME=${SITE_NAME:-"CyberPanel Site"}
|
||||
|
||||
# Install WordPress using WP CLI
|
||||
/usr/local/lsws/lsphp82/bin/php /usr/bin/wp core download --path=/usr/local/lsws/Example/html --allow-root
|
||||
|
||||
# Set up WP config
|
||||
/usr/local/lsws/lsphp82/bin/php /usr/bin/wp core config --dbname="$DB_NAME" --dbuser="$DB_USER" --dbpass="$DB_PASSWORD" --path="/usr/local/lsws/Example/html" --dbhost="$DB_Host" --skip-check --allow-root
|
||||
|
||||
# Install WordPress
|
||||
/usr/local/lsws/lsphp82/bin/php /usr/bin/wp core install --title="$SITE_NAME" --url="$WP_URL" --title="My WordPress Site" --admin_user="$WP_ADMIN_USER" --admin_password="$WP_ADMIN_PASSWORD" --admin_email="$WP_ADMIN_EMAIL" --path="/usr/local/lsws/Example/html" --skip-email --allow-root
|
||||
|
||||
### Install LSCache plugin
|
||||
|
||||
/usr/local/lsws/lsphp82/bin/php /usr/bin/wp plugin install litespeed-cache --allow-root --path="/usr/local/lsws/Example/html"
|
||||
|
||||
# Start OpenLiteSpeed
|
||||
/usr/local/lsws/bin/lswsctrl start
|
||||
|
||||
# Keep container running
|
||||
tail -f /dev/null
|
||||
100
dockerManager/vhconf.conf
Normal file
100
dockerManager/vhconf.conf
Normal file
@@ -0,0 +1,100 @@
|
||||
docRoot $VH_ROOT/html/
|
||||
enableGzip 1
|
||||
|
||||
|
||||
context / {
|
||||
allowBrowse 1
|
||||
location $DOC_ROOT/
|
||||
rewrite {
|
||||
RewriteFile .htaccess
|
||||
}
|
||||
}
|
||||
|
||||
expires {
|
||||
enableExpires 1
|
||||
}
|
||||
|
||||
index {
|
||||
indexFiles index.php
|
||||
autoIndex 0
|
||||
useServer 0
|
||||
}
|
||||
|
||||
errorPage 404{
|
||||
url /error404.html
|
||||
}
|
||||
|
||||
errorlog $VH_ROOT/logs/error.log{
|
||||
logLevel DEBUG
|
||||
rollingSize 10M
|
||||
useServer 1
|
||||
}
|
||||
|
||||
accessLog $VH_ROOT/logs/access.log{
|
||||
compressArchive 0
|
||||
logReferer 1
|
||||
keepDays 30
|
||||
rollingSize 10M
|
||||
logUserAgent 1
|
||||
useServer 0
|
||||
}
|
||||
|
||||
rewrite {
|
||||
enable 1
|
||||
logLevel 0
|
||||
}
|
||||
|
||||
hotlinkCtrl {
|
||||
suffixes gif, jpeg, jpg
|
||||
allowedHosts
|
||||
allowDirectAccess 1
|
||||
enableHotlinkCtrl 0
|
||||
onlySelf 1
|
||||
}
|
||||
|
||||
accessControl {
|
||||
deny
|
||||
allow *
|
||||
}
|
||||
|
||||
realm SampleProtectedArea {
|
||||
userDB {
|
||||
cacheTimeout 60
|
||||
maxCacheSize 200
|
||||
location conf/vhosts/$VH_NAME/htpasswd
|
||||
}
|
||||
|
||||
groupDB {
|
||||
cacheTimeout 60
|
||||
maxCacheSize 200
|
||||
location conf/vhosts/$VH_NAME/htgroup
|
||||
}
|
||||
}
|
||||
|
||||
general {
|
||||
enableContextAC 0
|
||||
}
|
||||
|
||||
scripthandler {
|
||||
add lsapi:cyberpanel php
|
||||
}
|
||||
|
||||
extprocessor cyberpanel {
|
||||
type lsapi
|
||||
address UDS://tmp/lshttpd/cyberpanel.sock
|
||||
maxConns 10
|
||||
env LSAPI_CHILDREN=10
|
||||
initTimeout 600
|
||||
retryTimeout 0
|
||||
persistConn 1
|
||||
pcKeepAliveTimeout 1
|
||||
respBuffer 0
|
||||
autoStart 1
|
||||
path /usr/local/lsws/lsphp82/bin/lsphp
|
||||
# extUser nobody
|
||||
# extGroup nobody
|
||||
memSoftLimit 2047M
|
||||
memHardLimit 2047M
|
||||
procSoftLimit 400
|
||||
procHardLimit 500
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/usr/local/CyberCP/bin/python
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
import django
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
|
||||
import argparse
|
||||
|
||||
class DockerSites:
|
||||
|
||||
@@ -23,16 +24,64 @@ class DockerSites:
|
||||
else:
|
||||
return 0, ReturnCode
|
||||
|
||||
@staticmethod
|
||||
def SetupProxy(port):
|
||||
ConfPath = '/usr/local/lsws/conf/httpd_config.conf'
|
||||
data = open(ConfPath, 'r').read()
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
StringCheck = f"127.0.0.1:{port}"
|
||||
if data.find(StringCheck) == -1:
|
||||
ProxyContent = f"""
|
||||
extprocessor docker{port} {{
|
||||
type proxy
|
||||
address 127.0.0.1:{port}
|
||||
maxConns 100
|
||||
pcKeepAliveTimeout 60
|
||||
initTimeout 60
|
||||
retryTimeout 0
|
||||
respBuffer 0
|
||||
}}
|
||||
"""
|
||||
|
||||
WriteToFile = open(ConfPath, 'a')
|
||||
WriteToFile.write(ProxyContent)
|
||||
WriteToFile.close()
|
||||
|
||||
@staticmethod
|
||||
def SetupHTAccess(port, htaccess):
|
||||
### Update htaccess
|
||||
|
||||
StringCheck = f'docker{port}'
|
||||
|
||||
try:
|
||||
Content = open(htaccess, 'r').read()
|
||||
except:
|
||||
Content = ''
|
||||
|
||||
print(f'value of content {Content}')
|
||||
|
||||
if Content.find(StringCheck) == -1:
|
||||
HTAccessContent = f'''
|
||||
RewriteEngine On
|
||||
REWRITERULE ^(.*)$ HTTP://docker{port}/$1 [P]
|
||||
'''
|
||||
WriteToFile = open(htaccess, 'a')
|
||||
WriteToFile.write(HTAccessContent)
|
||||
WriteToFile.close()
|
||||
|
||||
ProcessUtilities.restartLitespeed()
|
||||
|
||||
|
||||
# Takes
|
||||
# ComposePath, MySQLPath, MySQLRootPass, MySQLDBName, MySQLDBNUser, MySQLPassword, CPUsMySQL, MemoryMySQL,
|
||||
# port, SitePath, CPUsSite, MemorySite, ComposePath, SiteName
|
||||
# finalURL, blogTitle, adminUser, adminPassword, adminEmail
|
||||
# finalURL, blogTitle, adminUser, adminPassword, adminEmail, htaccessPath, externalApp
|
||||
|
||||
def DeployWPContainer(self):
|
||||
|
||||
try:
|
||||
logging.statusWriter(self.JobID, 'Checking if Docker is installed..,0')
|
||||
|
||||
|
||||
command = 'docker --help'
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
print(f'return code of docker install {result}')
|
||||
@@ -44,51 +93,177 @@ class DockerSites:
|
||||
|
||||
logging.statusWriter(self.JobID, 'Docker is ready to use..,10')
|
||||
|
||||
WPSite = f"""
|
||||
version: "3.8"
|
||||
# WPSite = f"""
|
||||
# version: "3.8"
|
||||
#
|
||||
# services:
|
||||
# db:
|
||||
# image: mysql:5.7
|
||||
# restart: always
|
||||
# volumes:
|
||||
# - "{self.data['MySQLPath']}:/var/lib/mysql"
|
||||
# environment:
|
||||
# MYSQL_ROOT_PASSWORD: {self.data['MySQLRootPass']}
|
||||
# MYSQL_DATABASE: {self.data['MySQLDBName']}
|
||||
# MYSQL_USER: {self.data['MySQLDBNUser']}
|
||||
# MYSQL_PASSWORD: {self.data['MySQLPassword']}
|
||||
# deploy:
|
||||
# resources:
|
||||
# limits:
|
||||
# cpus: '{self.data['CPUsMySQL']}' # Use 50% of one CPU core
|
||||
# memory: {self.data['MemoryMySQL']}M # Limit memory to 512 megabytes
|
||||
# wordpress:
|
||||
# depends_on:
|
||||
# - db
|
||||
# image: wordpress:latest
|
||||
# restart: always
|
||||
# ports:
|
||||
# - "{self.data['port']}:80"
|
||||
# environment:
|
||||
# WORDPRESS_DB_HOST: db:3306
|
||||
# WORDPRESS_DB_USER: {self.data['MySQLDBNUser']}
|
||||
# WORDPRESS_DB_PASSWORD: {self.data['MySQLPassword']}
|
||||
# WORDPRESS_DB_NAME: {self.data['MySQLDBName']}
|
||||
# volumes:
|
||||
# - "{self.data['SitePath']}:/var/www/html"
|
||||
# deploy:
|
||||
# resources:
|
||||
# limits:
|
||||
# cpus: '{self.data['CPUsSite']}' # Use 50% of one CPU core
|
||||
# memory: {self.data['MemorySite']}M # Limit memory to 512 megabytes
|
||||
#
|
||||
# volumes:
|
||||
# mysql: {{}}
|
||||
# """
|
||||
#
|
||||
# WPSite = f"""
|
||||
# # Copyright VMware, Inc.
|
||||
# # SPDX-License-Identifier: APACHE-2.0
|
||||
#
|
||||
# version: '2'
|
||||
# services:
|
||||
# mariadb:
|
||||
# image: mariadb:10.5.9
|
||||
# user: root
|
||||
# command: --max_allowed_packet=256M
|
||||
# volumes:
|
||||
# - "{self.data['MySQLPath']}:/var/lib/mysql:delegated"
|
||||
# environment:
|
||||
# - ALLOW_EMPTY_PASSWORD=no
|
||||
# - MYSQL_USER={self.data['MySQLDBNUser']}
|
||||
# - MYSQL_PASSWORD={self.data['MySQLPassword']}
|
||||
# - MYSQL_DATABASE={self.data['MySQLDBName']}
|
||||
# - MYSQL_ROOT_PASSWORD={self.data['MySQLPassword']}
|
||||
# deploy:
|
||||
# resources:
|
||||
# limits:
|
||||
# cpus: '{self.data['CPUsMySQL']}' # Use 50% of one CPU core
|
||||
# memory: {self.data['MemoryMySQL']}M # Limit memory to 512 megabytes
|
||||
# wordpress:
|
||||
# image: litespeedtech/openlitespeed:latest
|
||||
# user: root
|
||||
# ports:
|
||||
# - "{self.data['port']}:80"
|
||||
# # - '443:8443'
|
||||
# volumes:
|
||||
# - {self.data['docRoot']}/lsws/conf:/usr/local/lsws/conf
|
||||
# - {self.data['docRoot']}/lsws/admin-conf:/usr/local/lsws/admin/conf
|
||||
# - {self.data['docRoot']}/bin:/usr/local/bin
|
||||
# - {self.data['SitePath']}:/var/www/vhosts/
|
||||
# - {self.data['docRoot']}/acme:/root/.acme.sh/
|
||||
# - {self.data['docRoot']}/logs:/usr/local/lsws/logs/
|
||||
# depends_on:
|
||||
# - mariadb
|
||||
# environment:
|
||||
# - TZ=America/New_York
|
||||
# - PHP_VERSION=lsphp82
|
||||
# - MYSQL_ROOT_PASSWORD={self.data['MySQLPassword']}
|
||||
# - DOMAIN={self.data['finalURL']}
|
||||
# - MYSQL_USER={self.data['MySQLDBNUser']}
|
||||
# - MYSQL_DATABASE={self.data['MySQLDBName']}
|
||||
# - MYSQL_PASSWORD={self.data['MySQLPassword']}
|
||||
# # - ALLOW_EMPTY_PASSWORD=no
|
||||
# # - WORDPRESS_DATABASE_HOST=mariadb
|
||||
# # - WORDPRESS_DATABASE_PORT_NUMBER=3306
|
||||
# # - WORDPRESS_USERNAME={self.data['adminUser']}
|
||||
# # - WORDPRESS_PASSWORD={self.data["adminPassword"]}
|
||||
# # - WORDPRESS_EMAIL={self.data["adminEmail"]}
|
||||
# # - WORDPRESS_BLOG_NAME={self.data["blogTitle"]}
|
||||
# # - WORDPRESS_ENABLE_REVERSE_PROXY=yes
|
||||
# deploy:
|
||||
# resources:
|
||||
# limits:
|
||||
# cpus: '{self.data['CPUsSite']}' # Use 50% of one CPU core
|
||||
# memory: {self.data['MemorySite']}M # Limit memory to 512 megabytes
|
||||
# # phpmyadmin:
|
||||
# # image: bitnami/phpmyadmin:latest
|
||||
# # ports:
|
||||
# # # - 8080:8080
|
||||
# # # - 8443:8443
|
||||
# # environment:
|
||||
# # DATABASE_HOST: mysql
|
||||
# # restart: always
|
||||
# # networks:
|
||||
# # - default
|
||||
#
|
||||
# volumes:
|
||||
# mariadb_data:
|
||||
# driver: local
|
||||
# wordpress_data:
|
||||
# driver: local
|
||||
# """
|
||||
|
||||
WPSite = f'''
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
db:
|
||||
image: mysql:5.7
|
||||
restart: always
|
||||
volumes:
|
||||
- "{self.data['MySQLPath']}:/var/lib/mysql"
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: {self.data['MySQLRootPass']}
|
||||
MYSQL_DATABASE: {self.data['MySQLDBName']}
|
||||
MYSQL_USER: {self.data['MySQLDBNUser']}
|
||||
MYSQL_PASSWORD: {self.data['MySQLPassword']}
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '{self.data['CPUsMySQL']}' # Use 50% of one CPU core
|
||||
memory: {self.data['MemoryMySQL']}M # Limit memory to 512 megabytes
|
||||
wordpress:
|
||||
depends_on:
|
||||
- db
|
||||
image: wordpress:latest
|
||||
restart: always
|
||||
user: root
|
||||
image: cyberpanel/openlitespeed:latest
|
||||
ports:
|
||||
- "{self.data['port']}:80"
|
||||
- "{self.data['port']}:8088"
|
||||
# - "443:443"
|
||||
environment:
|
||||
WORDPRESS_DB_HOST: db:3306
|
||||
WORDPRESS_DB_USER: {self.data['MySQLDBNUser']}
|
||||
WORDPRESS_DB_PASSWORD: {self.data['MySQLPassword']}
|
||||
WORDPRESS_DB_NAME: {self.data['MySQLDBName']}
|
||||
DB_NAME: "{self.data['MySQLDBName']}"
|
||||
DB_USER: "{self.data['MySQLDBNUser']}"
|
||||
DB_PASSWORD: "{self.data['MySQLPassword']}"
|
||||
WP_ADMIN_EMAIL: "{self.data['adminEmail']}"
|
||||
WP_ADMIN_USER: "{self.data['adminUser']}"
|
||||
WP_ADMIN_PASSWORD: "{self.data['adminPassword']}"
|
||||
WP_URL: {self.data['finalURL']}
|
||||
DB_Host: mariadb:3306
|
||||
SITE_NAME: '{self.data['SiteName']}'
|
||||
volumes:
|
||||
- "{self.data['SitePath']}:/var/www/html"
|
||||
# - "/home/docker/{self.data['finalURL']}:/usr/local/lsws/Example/html"
|
||||
- "/home/docker/{self.data['finalURL']}/data:/usr/local/lsws/Example/html"
|
||||
depends_on:
|
||||
- mariadb
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '{self.data['CPUsSite']}' # Use 50% of one CPU core
|
||||
memory: {self.data['MemorySite']}M # Limit memory to 512 megabytes
|
||||
|
||||
volumes:
|
||||
mysql: {{}}
|
||||
"""
|
||||
mariadb:
|
||||
image: mariadb
|
||||
restart: always
|
||||
environment:
|
||||
# ALLOW_EMPTY_PASSWORD=no
|
||||
MYSQL_DATABASE: '{self.data['MySQLDBName']}'
|
||||
MYSQL_USER: '{self.data['MySQLDBNUser']}'
|
||||
MYSQL_PASSWORD: '{self.data['MySQLPassword']}'
|
||||
MYSQL_ROOT_PASSWORD: '{self.data['MySQLPassword']}'
|
||||
volumes:
|
||||
- "/home/docker/{self.data['finalURL']}/db:/var/lib/mysql"
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '{self.data['CPUsMySQL']}' # Use 50% of one CPU core
|
||||
memory: {self.data['MemoryMySQL']}M # Limit memory to 512 megabytes
|
||||
'''
|
||||
|
||||
### WriteConfig to compose-file
|
||||
|
||||
|
||||
WriteToFile = open(self.data['ComposePath'], 'w')
|
||||
WriteToFile.write(WPSite)
|
||||
WriteToFile.close()
|
||||
@@ -96,42 +271,95 @@ volumes:
|
||||
####
|
||||
|
||||
command = f"docker-compose -f {self.data['ComposePath']} -p '{self.data['SiteName']}' up -d"
|
||||
ReturnCode = ProcessUtilities.executioner(command)
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
command = f"docker-compose -f {self.data['ComposePath']} ps -q wordpress"
|
||||
stdout = ProcessUtilities.outputExecutioner(command)
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(result)
|
||||
|
||||
self.ContainerID = stdout.rstrip('\n')
|
||||
|
||||
### Set up Proxy
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/DockerSites.py"
|
||||
execPath = execPath + f" SetupProxy --port {self.data['port']}"
|
||||
ProcessUtilities.executioner(execPath)
|
||||
|
||||
### Set up ht access
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/DockerSites.py"
|
||||
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)
|
||||
|
||||
# command = f"docker-compose -f {self.data['ComposePath']} ps -q wordpress"
|
||||
# stdout = ProcessUtilities.outputExecutioner(command)
|
||||
#
|
||||
# self.ContainerID = stdout.rstrip('\n')
|
||||
|
||||
|
||||
|
||||
command = f'docker-compose -f {self.data["ComposePath"]} exec {self.ContainerID} curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
||||
ReturnCode = ProcessUtilities.executioner(command)
|
||||
# command = f'docker-compose -f {self.data["ComposePath"]} exec {self.ContainerID} curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
||||
# result = ProcessUtilities.outputExecutioner(command)
|
||||
#
|
||||
# if os.path.exists(ProcessUtilities.debugPath):
|
||||
# logging.writeToFile(result)
|
||||
#
|
||||
# command = f"docker-compose -f {self.data['ComposePath']} exec {self.ContainerID} chmod + wp-cli.phar"
|
||||
# result = ProcessUtilities.outputExecutioner(command)
|
||||
#
|
||||
# if os.path.exists(ProcessUtilities.debugPath):
|
||||
# logging.writeToFile(result)
|
||||
#
|
||||
# command = f"docker-compose -f {self.data['ComposePath']} exec {self.ContainerID} mv wp-cli.phar /bin/wp"
|
||||
# result = ProcessUtilities.outputExecutioner(command)
|
||||
#
|
||||
# if os.path.exists(ProcessUtilities.debugPath):
|
||||
# logging.writeToFile(result)
|
||||
|
||||
command = f"docker-compose -f {self.data['ComposePath']} exec {self.ContainerID} chmod + wp-cli.phar"
|
||||
ReturnCode = ProcessUtilities.executioner(command)
|
||||
|
||||
command = f"docker-compose -f {self.data['ComposePath']} exec {self.ContainerID} mv wp-cli.phar /bin/wp"
|
||||
ReturnCode = ProcessUtilities.executioner(command)
|
||||
|
||||
command = f'docker-compose -f {self.data["ComposePath"]} exec {self.ContainerID} wp core install --url="http://{self.data["finalURL"]}" --title="{self.data["blogTitle"]}" --admin_user="{self.data["adminUser"]}" --admin_password="{self.data["adminPassword"]}" --admin_email="{self.data["adminEmail"]}" --path=. --allow-root'
|
||||
ReturnCode = ProcessUtilities.executioner(command)
|
||||
# command = f'docker-compose -f {self.data["ComposePath"]} exec {self.ContainerID} wp core install --url="http://{self.data["finalURL"]}" --title="{self.data["blogTitle"]}" --admin_user="{self.data["adminUser"]}" --admin_password="{self.data["adminPassword"]}" --admin_email="{self.data["adminEmail"]}" --path=. --allow-root'
|
||||
# result = ProcessUtilities.outputExecutioner(command)
|
||||
#
|
||||
# if os.path.exists(ProcessUtilities.debugPath):
|
||||
# logging.writeToFile(result)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(f'{str(msg)}. [DeployWPContainer]')
|
||||
print(str(msg))
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def Main():
|
||||
try:
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Docker Sites')
|
||||
parser.add_argument('function', help='Specify a function to call!')
|
||||
parser.add_argument('--port', help='')
|
||||
parser.add_argument('--htaccess', help='')
|
||||
parser.add_argument('--externalApp', help='')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.function == "SetupProxy":
|
||||
DockerSites.SetupProxy(args.port)
|
||||
elif args.function == 'SetupHTAccess':
|
||||
DockerSites.SetupHTAccess(args.port, args.htaccess)
|
||||
elif args.function == 'DeployWPDocker':
|
||||
# Takes
|
||||
# ComposePath, MySQLPath, MySQLRootPass, MySQLDBName, MySQLDBNUser, MySQLPassword, CPUsMySQL, MemoryMySQL,
|
||||
# port, SitePath, CPUsSite, MemorySite, SiteName
|
||||
# finalURL, blogTitle, adminUser, adminPassword, adminEmail
|
||||
# finalURL, blogTitle, adminUser, adminPassword, adminEmail, htaccessPath, externalApp
|
||||
data = {
|
||||
"JobID": '/home/cyberpanel/error-logs.txt',
|
||||
"ComposePath": "/home/cyberpanel.net/docker-compose.yml",
|
||||
"MySQLPath": '/home/cyberpanel.net/public_html/sqldocker',
|
||||
"ComposePath": "/home/docker.cyberpanel.net/docker-compose.yml",
|
||||
"MySQLPath": '/home/docker.cyberpanel.net/public_html/sqldocker',
|
||||
"MySQLRootPass": 'testdbwp12345',
|
||||
"MySQLDBName": 'testdbwp',
|
||||
"MySQLDBNUser": 'testdbwp',
|
||||
@@ -139,19 +367,23 @@ def Main():
|
||||
"CPUsMySQL": '2',
|
||||
"MemoryMySQL": '512',
|
||||
"port": '8000',
|
||||
"SitePath": '/home/cyberpanel.net/public_html/wpdocker',
|
||||
"SitePath": '/home/docker.cyberpanel.net/public_html/wpdocker',
|
||||
"CPUsSite": '2',
|
||||
"MemorySite": '512',
|
||||
"SiteName": 'wp docker test',
|
||||
"finalURL": '95.217.125.218:8001',
|
||||
"blogTitle": 'testdbwp',
|
||||
"finalURL": 'docker.cyberpanel.net',
|
||||
"blogTitle": 'docker site',
|
||||
"adminUser": 'testdbwp',
|
||||
"adminPassword": 'testdbwp',
|
||||
"adminEmail": 'testdbwp',
|
||||
"adminEmail": 'usman@cyberpersons.com',
|
||||
"htaccessPath": '/home/docker.cyberpanel.net/public_html/.htaccess',
|
||||
"externalApp": 'docke3339',
|
||||
"docRoot": "/home/docker.cyberpanel.net"
|
||||
}
|
||||
ds = DockerSites(data)
|
||||
|
||||
ds.DeployWPContainer()
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
print(str(msg))
|
||||
pass
|
||||
|
||||
@@ -18,6 +18,7 @@ try:
|
||||
from manageServices.models import PDNSStatus, SlaveServers
|
||||
except:
|
||||
pass
|
||||
|
||||
import CloudFlare
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
|
||||
@@ -1066,6 +1066,28 @@ bind-address=%s
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[deleteDatabase]")
|
||||
return str(msg)
|
||||
|
||||
@staticmethod
|
||||
def UpgradeMariaDB(tempStatusPath):
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Creating backup of MySQL..,10')
|
||||
|
||||
MySQLBackupDir = '/var/lib/mysql-backupcp'
|
||||
from os import getuid
|
||||
if getuid() != 0:
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'This function should run as root. [404]')
|
||||
return 0, 'This function should run as root.'
|
||||
|
||||
|
||||
if not os.path.exists(MySQLBackupDir):
|
||||
command = 'rsync -av /var/lib/mysql/ /var/lib/mysql-backupcp/'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'MySQL backup created..,20')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='CyberPanel')
|
||||
parser.add_argument('function', help='Specific a function to call!')
|
||||
|
||||
@@ -248,6 +248,10 @@ class phpUtilities:
|
||||
@staticmethod
|
||||
def WrapGetPHPVersionFromFileToGetVersionWithPHP(vhFile):
|
||||
result = phpUtilities.GetPHPVersionFromFile(vhFile)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(result)
|
||||
|
||||
command = result + " -v | awk '/^PHP/ {print $2}'"
|
||||
php_version = ProcessUtilities.outputExecutioner(command, None, True).rstrip('\n')
|
||||
return f"PHP {php_version}"
|
||||
|
||||
@@ -297,6 +297,8 @@ class ProcessUtilities(multi.Thread):
|
||||
@staticmethod
|
||||
def outputExecutioner(command, user=None, shell = None, dir = None, retRequired = None):
|
||||
try:
|
||||
if os.path.exists('/usr/local/CyberCP/debug'):
|
||||
logging.writeToFile(command)
|
||||
if getpass.getuser() == 'root':
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(command)
|
||||
|
||||
@@ -2354,11 +2354,29 @@ class WebsiteManager:
|
||||
pageNumber = int(data['page'])
|
||||
recordsToShow = int(data['recordsToShow'])
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 1..')
|
||||
|
||||
endPageNumber, finalPageNumber = self.recordsPointer(pageNumber, recordsToShow)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 2..')
|
||||
|
||||
websites = ACLManager.findWebsiteObjects(currentACL, userID)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 3..')
|
||||
|
||||
pagination = self.getPagination(len(websites), recordsToShow)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 4..')
|
||||
|
||||
json_data = self.findWebsitesListJson(websites[finalPageNumber:endPageNumber])
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(f'Fetch sites step 5..')
|
||||
|
||||
final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data,
|
||||
'pagination': pagination}
|
||||
final_json = json.dumps(final_dic)
|
||||
@@ -2415,9 +2433,14 @@ class WebsiteManager:
|
||||
|
||||
from plogical.phpUtilities import phpUtilities
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(f'findWebsitesListJson 1')
|
||||
|
||||
|
||||
|
||||
for items in websites:
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(f'findWebsitesListJson 2')
|
||||
if items.state == 0:
|
||||
state = "Suspended"
|
||||
else:
|
||||
@@ -2425,10 +2448,25 @@ class WebsiteManager:
|
||||
|
||||
vhFile = f'/usr/local/lsws/conf/vhosts/{items.domain}/vhost.conf'
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(vhFile)
|
||||
|
||||
try:
|
||||
PHPVersionActual = phpUtilities.WrapGetPHPVersionFromFileToGetVersionWithPHP(vhFile)
|
||||
except:
|
||||
PHPVersionActual = 'PHP 8.1'
|
||||
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(f'findWebsitesListJson 3')
|
||||
|
||||
DiskUsage, DiskUsagePercentage, bwInMB, bwUsage = virtualHostUtilities.FindStats(items)
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.CyberCPLogFileWriter.writeToFile(f'findWebsitesListJson 4')
|
||||
try:
|
||||
diskUsed = "%sMB" % str(DiskUsage)
|
||||
except:
|
||||
diskUsed = "%sMB" % str(0)
|
||||
|
||||
dic = {'domain': items.domain, 'adminEmail': items.adminEmail, 'ipAddress': ipAddress,
|
||||
'admin': items.admin.userName, 'package': items.package.packageName, 'state': state,
|
||||
|
||||
Reference in New Issue
Block a user