Skip to content
Permalink
Browse files

detached mode: instantly change php version

  • Loading branch information...
usmannasir committed Sep 29, 2019
1 parent e7437af commit 8582dfa6c266d0bfb7ff7c4a7ebbfa18ff687536
@@ -9,4 +9,4 @@
class Databases(models.Model):
website = models.ForeignKey(Websites)
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 @@ def CreateMainWebsite(self):

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,
0, 'admin', 'Default', 0)

@@ -189,7 +189,7 @@ def sendCommand(command, user=None):
# for items in CommandArgs:
# finalCommand = '%s %s' % (finalCommand, items)


#logging.writeToFile(command)
if user == None:
sock.sendall(ProcessUtilities.token + command)
else:
@@ -254,6 +254,8 @@ def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None):
+ ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
+ ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'

logging.CyberCPLogFileWriter.writeToFile(command)

output = subprocess.check_output(shlex.split(command))
logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName + " and: www." + virtualHostName)

@@ -498,6 +498,7 @@ def checkIfVirtualHostExists(virtualHostName):

@staticmethod
def changePHP(vhFile, phpVersion):
phpDetachUpdatePath = '/home/%s/.lsphp_restart.txt' % (vhFile.split('/')[-2])
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
try:
if ApacheVhost.changePHP(phpVersion, vhFile) == 0:
@@ -521,7 +522,14 @@ def changePHP(vhFile, phpVersion):

writeDataToFile.close()

writeToFile = open(phpDetachUpdatePath, 'w')
writeToFile.close()

installUtilities.installUtilities.reStartLiteSpeed()
try:
os.remove(phpDetachUpdatePath)
except:
pass
else:
php = PHPManager.getPHPString(phpVersion)
command = "systemctl restart php%s-php-fpm" % (php)
@@ -556,7 +564,14 @@ def changePHP(vhFile, phpVersion):

writeDataToFile.close()

writeToFile = open(phpDetachUpdatePath, 'w')
writeToFile.close()

installUtilities.installUtilities.reStartLiteSpeed()
try:
os.remove(phpDetachUpdatePath)
except:
pass

print "1,None"
return 1, 'None'
@@ -89,11 +89,19 @@ def startCloning(self):

for items in data:
if items.find('DB_NAME') > -1:
dbName = items.split("'")[3]
if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'):
break
else:
raise BaseException('Failed to create database backup.')
try:
dbName = items.split("'")[3]
if mysqlUtilities.createDatabaseBackup(dbName, '/home/cyberpanel'):
break
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)

0 comments on commit 8582dfa

Please sign in to comment.
You can’t perform that action at this time.