This commit is contained in:
usmannasir
2023-11-26 14:32:35 +04:00
parent f41f07d8f2
commit 6a4e63bf93
7 changed files with 223 additions and 55 deletions

View File

@@ -1,6 +1,7 @@
#!/usr/local/CyberCP/bin/python
import os,sys
from ApachController.ApacheVhosts import ApacheVhost
from manageServices.models import PDNSStatus
from .processUtilities import ProcessUtilities
@@ -674,8 +675,6 @@ class ACLManager:
@staticmethod
def checkOwnership(domain, admin, currentACL):
try:
childDomain = ChildDomains.objects.get(domain=domain)
@@ -995,3 +994,70 @@ class ACLManager:
except BaseException as msg:
return 0, str(msg), None
@staticmethod
def FindDocRootOfSite(vhostConf,domainName):
try:
if vhostConf == None:
vhostConf = f'/usr/local/lsws/conf/vhosts/{domainName}/vhost.conf'
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
command = "awk '/docRoot/ {print $2}' " + vhostConf
docRoot = ProcessUtilities.outputExecutioner(command, 'root', True).rstrip('\n')
#docRoot = docRoot.replace('$VH_ROOT', f'/home/{domainName}')
return docRoot
else:
command = "awk '/DocumentRoot/ {print $2; exit}' " + vhostConf
docRoot = ProcessUtilities.outputExecutioner(command, 'root', True).rstrip('\n')
return docRoot
except:
pass
@staticmethod
def ReplaceDocRoot(vhostConf, domainName, NewDocRoot):
try:
if vhostConf == None:
vhostConf = f'/usr/local/lsws/conf/vhosts/{domainName}/vhost.conf'
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
#command = f"sed -i 's/docRoot\s\s*.*/docRoot {NewDocRoot}/g " + vhostConf
command = f"sed -i 's#docRoot\s\s*.*#docRoot {NewDocRoot}#g' " + vhostConf
ProcessUtilities.executioner(command, 'root', True)
else:
command = f"sed -i 's#DocumentRoot\s\s*[^[:space:]]*#DocumentRoot {NewDocRoot}#g' " + vhostConf
ProcessUtilities.executioner(command, 'root', True)
except:
pass
@staticmethod
def FindDocRootOfSiteApache(vhostConf, domainName):
try:
finalConfPath = ApacheVhost.configBasePath + domainName + '.conf'
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
if os.path.exists(finalConfPath):
command = "awk '/DocumentRoot/ {print $2; exit}' " + finalConfPath
docRoot = ProcessUtilities.outputExecutioner(command, 'root', True).rstrip('\n')
return docRoot
else:
return None
else:
return None
except:
return None
@staticmethod
def ReplaceDocRootApache(vhostConf, domainName, NewDocRoot):
try:
finalConfPath = ApacheVhost.configBasePath + domainName + '.conf'
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
command = f"sed -i 's#DocumentRoot\s\s*[^[:space:]]*#DocumentRoot {NewDocRoot}#g' " + finalConfPath
ProcessUtilities.executioner(command, 'root', True)
except:
pass