mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
detached mode: instantly change php version
This commit is contained in:
@@ -9,4 +9,4 @@ from websiteFunctions.models import Websites
|
|||||||
class Databases(models.Model):
|
class Databases(models.Model):
|
||||||
website = models.ForeignKey(Websites)
|
website = models.ForeignKey(Websites)
|
||||||
dbName = models.CharField(max_length=50,unique=True)
|
dbName = models.CharField(max_length=50,unique=True)
|
||||||
dbUser = models.CharField(max_length=50, unique=True)
|
dbUser = models.CharField(max_length=50)
|
||||||
|
|||||||
@@ -212,6 +212,15 @@ class cPanelImporter:
|
|||||||
|
|
||||||
externalApp = "".join(re.findall("[a-zA-Z]+", DomainName))[:7]
|
externalApp = "".join(re.findall("[a-zA-Z]+", DomainName))[:7]
|
||||||
|
|
||||||
|
try:
|
||||||
|
counter = 0
|
||||||
|
while 1:
|
||||||
|
tWeb = Websites.objects.get(externalApp=externalApp)
|
||||||
|
externalApp = '%s%s' % (tWeb.externalApp, str(counter))
|
||||||
|
counter = counter + 1
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
result = virtualHostUtilities.createVirtualHost(DomainName, self.email, self.PHPVersion, externalApp, 0, 0,
|
result = virtualHostUtilities.createVirtualHost(DomainName, self.email, self.PHPVersion, externalApp, 0, 0,
|
||||||
0, 'admin', 'Default', 0)
|
0, 'admin', 'Default', 0)
|
||||||
|
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ class ProcessUtilities(multi.Thread):
|
|||||||
# for items in CommandArgs:
|
# for items in CommandArgs:
|
||||||
# finalCommand = '%s %s' % (finalCommand, items)
|
# finalCommand = '%s %s' % (finalCommand, items)
|
||||||
|
|
||||||
|
#logging.writeToFile(command)
|
||||||
if user == None:
|
if user == None:
|
||||||
sock.sendall(ProcessUtilities.token + command)
|
sock.sendall(ProcessUtilities.token + command)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -254,6 +254,8 @@ class sslUtilities:
|
|||||||
+ ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
|
+ ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
|
||||||
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
|
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
|
||||||
|
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(command)
|
||||||
|
|
||||||
output = subprocess.check_output(shlex.split(command))
|
output = subprocess.check_output(shlex.split(command))
|
||||||
logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName + " and: www." + virtualHostName)
|
logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName + " and: www." + virtualHostName)
|
||||||
|
|
||||||
|
|||||||
@@ -498,6 +498,7 @@ class vhost:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def changePHP(vhFile, phpVersion):
|
def changePHP(vhFile, phpVersion):
|
||||||
|
phpDetachUpdatePath = '/home/%s/.lsphp_restart.txt' % (vhFile.split('/')[-2])
|
||||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||||
try:
|
try:
|
||||||
if ApacheVhost.changePHP(phpVersion, vhFile) == 0:
|
if ApacheVhost.changePHP(phpVersion, vhFile) == 0:
|
||||||
@@ -521,7 +522,14 @@ class vhost:
|
|||||||
|
|
||||||
writeDataToFile.close()
|
writeDataToFile.close()
|
||||||
|
|
||||||
|
writeToFile = open(phpDetachUpdatePath, 'w')
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
installUtilities.installUtilities.reStartLiteSpeed()
|
installUtilities.installUtilities.reStartLiteSpeed()
|
||||||
|
try:
|
||||||
|
os.remove(phpDetachUpdatePath)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
php = PHPManager.getPHPString(phpVersion)
|
php = PHPManager.getPHPString(phpVersion)
|
||||||
command = "systemctl restart php%s-php-fpm" % (php)
|
command = "systemctl restart php%s-php-fpm" % (php)
|
||||||
@@ -556,7 +564,14 @@ class vhost:
|
|||||||
|
|
||||||
writeDataToFile.close()
|
writeDataToFile.close()
|
||||||
|
|
||||||
|
writeToFile = open(phpDetachUpdatePath, 'w')
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
installUtilities.installUtilities.reStartLiteSpeed()
|
installUtilities.installUtilities.reStartLiteSpeed()
|
||||||
|
try:
|
||||||
|
os.remove(phpDetachUpdatePath)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
print "1,None"
|
print "1,None"
|
||||||
return 1, 'None'
|
return 1, 'None'
|
||||||
|
|||||||
@@ -89,11 +89,19 @@ class StagingSetup(multi.Thread):
|
|||||||
|
|
||||||
for items in data:
|
for items in data:
|
||||||
if items.find('DB_NAME') > -1:
|
if items.find('DB_NAME') > -1:
|
||||||
dbName = items.split("'")[3]
|
try:
|
||||||
if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'):
|
dbName = items.split("'")[3]
|
||||||
break
|
if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'):
|
||||||
else:
|
break
|
||||||
raise BaseException('Failed to create database backup.')
|
else:
|
||||||
|
raise BaseException('Failed to create database backup.')
|
||||||
|
except:
|
||||||
|
dbName = items.split('"')[1]
|
||||||
|
if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise BaseException('Failed to create database backup.')
|
||||||
|
|
||||||
|
|
||||||
databasePath = '%s/%s.sql' % ('/home/cyberpanel', dbName)
|
databasePath = '%s/%s.sql' % ('/home/cyberpanel', dbName)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user