Skip to content
Permalink
Browse files

improvement: LSWS Switch

  • Loading branch information...
usmannasir committed Sep 18, 2019
1 parent d165e1d commit 6b5990015305d89b78d65b3ea78d7796b9ce94bd
Showing with 10 additions and 14 deletions.
  1. +10 −14 serverStatus/serverStatusUtil.py
@@ -10,11 +10,11 @@
import shutil
import plogical.CyberCPLogFileWriter as logging
from plogical.processUtilities import ProcessUtilities
from websiteFunctions.models import Websites, ChildDomains, aliasDomains
from websiteFunctions.models import Websites
from plogical.virtualHostUtilities import virtualHostUtilities
from plogical.sslUtilities import sslUtilities
from plogical.vhost import vhost

from shutil import copytree, ignore_patterns


class ServerStatusUtil:
@@ -145,7 +145,10 @@ def recover():
if os.path.exists('/usr/local/lsws'):
shutil.rmtree('/usr/local/lsws')

command = 'mv /usr/local/lsws.bak /usr/local/lsws'
command = 'mv /usr/local/lswsbak /usr/local/lsws'
ServerStatusUtil.executioner(command, FNULL)

command = '/usr/local/lsws/bin/openlitespeed'
ServerStatusUtil.executioner(command, FNULL)

@staticmethod
@@ -279,18 +282,9 @@ def switchTOLSWS(licenseKey):
ProcessUtilities.killLiteSpeed()

if os.path.exists('/usr/local/lsws'):
command = 'mkdir /usr/local/lsws.bak'
if ServerStatusUtil.executioner(command, FNULL) == 0:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Failed to create backup of current LSWS. [mkdir] [404]", 1)
ServerStatusUtil.recover()
return 0

command = 'cp -R /usr/local/lsws/* /usr/local/lsws.bak/'
if ServerStatusUtil.executioner(command, FNULL) == 0:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"Failed to create backup of current LSWS. [cp][404]", 1)
ServerStatusUtil.recover()
return 0
if not os.path.exists('/usr/local/lswsbak'):
shutil.copytree('/usr/local/lsws', '/usr/local/lswsbak', symlinks=True, ignore=ignore_patterns('*.sock*'))

dirs = os.listdir('/usr/local/lsws')
for dir in dirs:
@@ -345,6 +339,8 @@ def switchTOLSWS(licenseKey):
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Successfully switched to LITESPEED ENTERPRISE WEB SERVER. [200]\n", 1)

except BaseException, msg:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
"%s. [404]" % (str(msg)), 1)
logging.CyberCPLogFileWriter.writeToFile(str(msg))
ServerStatusUtil.recover()

0 comments on commit 6b59900

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