mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
dynamically detect php version in ref to: https://community.cyberpanel.net/t/php-8-2-in-cyberpanel/49703
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user