add static function to get cyberpanel version clean

This commit is contained in:
Michael Ramsey 2021-04-18 00:58:33 -04:00
parent 55c40f1bb9
commit b25215d807
8 changed files with 134 additions and 37 deletions

View File

@ -1,7 +1,9 @@
#!/usr/local/CyberCP/bin/python
import os,sys
import os, sys
sys.path.append('/usr/local/CyberCP')
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
django.setup()
from inspect import stack
@ -27,12 +29,19 @@ from plogical.backupSchedule import backupSchedule
# All that we see or seem is but a dream within a dream.
def get_cyberpanel_version():
with open('/usr/local/CyberCP/version.txt') as version:
version_file = version.read()
version = json.loads(str(version_file))
return f"{version['version']}.{version['build']}"
class cyberPanel:
def printStatus(self, operationStatus, errorMessage):
data = json.dumps({'success': operationStatus,
'errorMessage': errorMessage
})
})
print(data)
## Website Functions
@ -42,10 +51,10 @@ class cyberPanel:
from random import randint
externalApp = "".join(re.findall("[a-zA-Z]+", domainName))[:5] + str(randint(1000, 9999))
phpSelection = 'PHP ' + php
try:
counter = 0
_externalApp=externalApp
_externalApp = externalApp
while True:
tWeb = Websites.objects.get(externalApp=externalApp)
externalApp = '%s%s' % (_externalApp, str(counter))
@ -55,10 +64,10 @@ class cyberPanel:
time.sleep(2)
result = virtualHostUtilities.createVirtualHost(domainName, email, phpSelection, externalApp, ssl, dkim,
openBasedir, owner, package, 0)
openBasedir, owner, package, 0)
if result[0] == 1:
self.printStatus(1,'None')
self.printStatus(1, 'None')
else:
self.printStatus(0, result[1])
@ -72,10 +81,11 @@ class cyberPanel:
path = '/home/' + masterDomain + '/public_html/' + domainName
phpSelection = 'PHP ' + php
result = virtualHostUtilities.createDomain(masterDomain, domainName, phpSelection, path, ssl, dkim, openBasedir, owner, 0)
result = virtualHostUtilities.createDomain(masterDomain, domainName, phpSelection, path, ssl, dkim,
openBasedir, owner, 0)
if result[0] == 1:
self.printStatus(1,'None')
self.printStatus(1, 'None')
else:
self.printStatus(0, result[1])
@ -98,7 +108,7 @@ class cyberPanel:
result = virtualHostUtilities.deleteDomain(childDomain)
if result[0] == 1:
self.printStatus(1,'None')
self.printStatus(1, 'None')
else:
self.printStatus(0, result[1])
@ -123,13 +133,14 @@ class cyberPanel:
state = "Suspended"
else:
state = "Active"
dic = {'domain': items.domain, 'adminEmail': items.adminEmail,'ipAddress':ipAddress,'admin': items.admin.userName,'package': items.package.packageName,'state':state}
dic = {'domain': items.domain, 'adminEmail': items.adminEmail, 'ipAddress': ipAddress,
'admin': items.admin.userName, 'package': items.package.packageName, 'state': state}
if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data +',' + json.dumps(dic)
json_data = json_data + ',' + json.dumps(dic)
json_data = json_data + ']'
final_json = json.dumps(json_data)
@ -149,14 +160,16 @@ class cyberPanel:
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
table = PrettyTable(['ID','Domain', 'IP Address', 'Package', 'Owner', 'State', 'Email'])
table = PrettyTable(['ID', 'Domain', 'IP Address', 'Package', 'Owner', 'State', 'Email'])
for items in websites:
if items.state == 0:
state = "Suspended"
else:
state = "Active"
table.add_row([items.id, items.domain, ipAddress, items.package.packageName, items.admin.userName, state, items.adminEmail])
table.add_row(
[items.id, items.domain, ipAddress, items.package.packageName, items.admin.userName, state,
items.adminEmail])
print(table)
except BaseException as msg:
@ -174,7 +187,7 @@ class cyberPanel:
result = vhost.changePHP(completePathToConfigFile, phpVersion)
if result[0] == 1:
self.printStatus(1,'None')
self.printStatus(1, 'None')
else:
self.printStatus(0, result[1])
@ -338,7 +351,7 @@ class cyberPanel:
# Setup default backup path to /home/<domain name>/backup if not passed in
if backupPath is None:
backupPath = '/home/' + virtualHostName + '/backup'
# remove trailing slash in path
backupPath = backupPath.rstrip("/")
backuptime = time.strftime("%m.%d.%Y_%H-%M-%S")
@ -387,7 +400,8 @@ class cyberPanel:
## Packages
def createPackage(self, owner, packageName, diskSpace, bandwidth, emailAccounts, dataBases, ftpAccounts, allowedDomains):
def createPackage(self, owner, packageName, diskSpace, bandwidth, emailAccounts, dataBases, ftpAccounts,
allowedDomains):
try:
admin = Administrator.objects.get(userName=owner)
@ -431,7 +445,7 @@ class cyberPanel:
'bandwidth': items.bandwidth,
'ftpAccounts ': items.ftpAccounts,
'dataBases': items.dataBases,
'emailAccounts':items.emailAccounts
'emailAccounts': items.emailAccounts
}
if checker == 0:
@ -454,10 +468,13 @@ class cyberPanel:
records = Package.objects.all()
table = PrettyTable(['Name', 'Domains', 'Disk Space', 'Bandwidth', 'FTP Accounts', 'Databases', 'Email Accounts'])
table = PrettyTable(
['Name', 'Domains', 'Disk Space', 'Bandwidth', 'FTP Accounts', 'Databases', 'Email Accounts'])
for items in records:
table.add_row([items.packageName, items.allowedDomains, items.diskSpace, items.bandwidth, items.ftpAccounts, items.dataBases, items.emailAccounts])
table.add_row(
[items.packageName, items.allowedDomains, items.diskSpace, items.bandwidth, items.ftpAccounts,
items.dataBases, items.emailAccounts])
print(table)
except BaseException as msg:
@ -584,8 +601,8 @@ class cyberPanel:
for items in records:
dic = {
'email': items.email,
}
'email': items.email,
}
if checker == 0:
json_data = json_data + json.dumps(dic)
@ -857,7 +874,8 @@ def main():
else:
openBasedir = 0
cyberpanel.createWebsite(args.package, args.owner, args.domainName, args.email, args.php, ssl, dkim, openBasedir)
cyberpanel.createWebsite(args.package, args.owner, args.domainName, args.email, args.php, ssl, dkim,
openBasedir)
elif args.function == "deleteWebsite":
completeCommandExample = 'cyberpanel deleteWebsite --domainName cyberpanel.net'
@ -1086,8 +1104,6 @@ def main():
print("\n\nPlease enter value for Allowed Child Domains. For example:\n\n" + completeCommandExample + "\n\n")
return
cyberpanel.createPackage(args.owner, args.packageName, args.diskSpace, args.bandwidth, args.emailAccounts,
args.dataBases, args.ftpAccounts, args.allowedDomains)
elif args.function == "deletePackage":
@ -1334,14 +1350,7 @@ def main():
ProcessUtilities.executioner(command)
elif args.function == 'version' or args.function == 'v' or args.function == 'V':
## Get CurrentVersion
with open('/usr/local/CyberCP/version.txt') as file:
file_contents = file.read()
version = re.search('\d.\d', file_contents)
version = version.group()
build = file_contents[-2:]
build = build[0:1]
currentversion = version + '.' + build
print (currentversion)
print(get_cyberpanel_version())
### User Functions
@ -1574,6 +1583,5 @@ def main():
wm.installJoomla(1, data)
if __name__ == "__main__":
main()

View File

@ -351,6 +351,26 @@ SecFilterSelective ARGS &quot;into[[:space:]]+outfile|load[[:space:]]+data|/\*.+
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor>
<extProcessor>
<type>lsapi</type>
<name>lsphp80</name>
<address>uds://tmp/lshttpd/lsphp80.sock</address>
<maxConns>35</maxConns>
<env>PHP_LSAPI_CHILDREN=35</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<persistConn>1</persistConn>
<respBuffer>0</respBuffer>
<autoStart>3</autoStart>
<path>$SERVER_ROOT/lsphp80/bin/lsphp</path>
<backlog>100</backlog>
<instances>1</instances>
<priority>0</priority>
<memSoftLimit>2047M</memSoftLimit>
<memHardLimit>2047M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>500</procHardLimit>
</extProcessor>
</extProcessorList>
<scriptHandlerList>
<scriptHandler>
@ -408,6 +428,11 @@ SecFilterSelective ARGS &quot;into[[:space:]]+outfile|load[[:space:]]+data|/\*.+
<type>lsapi</type>
<handler>lsphp74</handler>
</scriptHandler>
<scriptHandler>
<suffix>php80</suffix>
<type>lsapi</type>
<handler>lsphp80</handler>
</scriptHandler>
</scriptHandlerList>
<phpConfig>
</phpConfig>

View File

@ -393,7 +393,7 @@ max_input_time = 60
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M
memory_limit = 256M
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
@ -660,7 +660,7 @@ auto_globals_jit = On
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 8M
post_max_size = 20M
; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
@ -808,7 +808,7 @@ file_uploads = On
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 2M
upload_max_filesize = 20M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20

View File

@ -1,4 +1,4 @@
extprocessor php71 {
php71.confextprocessor php71 {
type lsapi
address uds://tmp/lshttpd/lsphp71.sock
maxConns 50

16
install/phpconfigs/php72.conf Executable file
View File

@ -0,0 +1,16 @@
php72.confextprocessor php72 {
type lsapi
address uds://tmp/lshttpd/lsphp72.sock
maxConns 50
initTimeout 60
retryTimeout 0
persistConn 1
respBuffer 0
autoStart 1
path /usr/local/lsws/lsphp72/bin/lsphp
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 400
procHardLimit 500
}

16
install/phpconfigs/php73.conf Executable file
View File

@ -0,0 +1,16 @@
php73.confextprocessor php73 {
type lsapi
address uds://tmp/lshttpd/lsphp73.sock
maxConns 50
initTimeout 60
retryTimeout 0
persistConn 1
respBuffer 0
autoStart 1
path /usr/local/lsws/lsphp73/bin/lsphp
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 400
procHardLimit 500
}

16
install/phpconfigs/php74.conf Executable file
View File

@ -0,0 +1,16 @@
php80.confextprocessor php80 {
type lsapi
address uds://tmp/lshttpd/lsphp80.sock
maxConns 50
initTimeout 60
retryTimeout 0
persistConn 1
respBuffer 0
autoStart 1
path /usr/local/lsws/lsphp80/bin/lsphp
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 400
procHardLimit 500
}

16
install/phpconfigs/php80.conf Executable file
View File

@ -0,0 +1,16 @@
php74.confextprocessor php74 {
type lsapi
address uds://tmp/lshttpd/lsphp74.sock
maxConns 50
initTimeout 60
retryTimeout 0
persistConn 1
respBuffer 0
autoStart 1
path /usr/local/lsws/lsphp74/bin/lsphp
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 400
procHardLimit 500
}