From 83870baea15f3b9f1eef58e4c2832d8ed9f8eaa4 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Wed, 14 Feb 2024 21:46:55 +0500 Subject: [PATCH] bug fix: docker problem with csf: ref https://community.cyberpanel.net/t/docker-and-csf-problems/52284/2 --- plogical/DockerSites.py | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/plogical/DockerSites.py b/plogical/DockerSites.py index a58c0ee56..d1c8556bc 100644 --- a/plogical/DockerSites.py +++ b/plogical/DockerSites.py @@ -3,6 +3,8 @@ import json import os import sys import time +from random import randint + sys.path.append('/usr/local/CyberCP') try: @@ -44,6 +46,60 @@ class Docker_Sites(multi.Thread): except: pass + command = 'cat /etc/csf/csf.conf' + result = ProcessUtilities.outputExecutioner(command) + + if result.find('SECTION:Initial Settings') > -1: + + from plogical.csf import CSF + from plogical.virtualHostUtilities import virtualHostUtilities + currentSettings = CSF.fetchCSFSettings() + + tcpIN = currentSettings['tcpIN'] + + if os.path.exists(ProcessUtilities.debugPath): + logging.writeToFile(f'TCPIN docker: {tcpIN}') + + + + if tcpIN.find('8088') == -1: + + ports = f'{tcpIN},8088' + + portsPath = '/home/cyberpanel/' + str(randint(1000, 9999)) + + if os.path.exists(portsPath): + os.remove(portsPath) + + writeToFile = open(portsPath, 'w') + writeToFile.write(ports) + writeToFile.close() + + execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" + execPath = execPath + f" modifyPorts --protocol TCP_IN --ports " + portsPath + ProcessUtilities.executioner(execPath) + + tcpOUT = currentSettings['tcpOUT'] + if tcpOUT.find('8088') == -1: + + ports = f'{tcpOUT},8088' + + portsPath = '/home/cyberpanel/' + str(randint(1000, 9999)) + + if os.path.exists(portsPath): + os.remove(portsPath) + + writeToFile = open(portsPath, 'w') + writeToFile.write(ports) + writeToFile.close() + + execPath = "sudo /usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/csf.py" + execPath = execPath + f" modifyPorts --protocol TCP_OUT --ports " + portsPath + ProcessUtilities.executioner(execPath) + + + + def run(self): try: if self.function_run == 'DeployWPContainer':