Skip to content

Commit

Permalink
improvement: LSWS Switch
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Sep 18, 2019
1 parent d165e1d commit 6b59900
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions serverStatus/serverStatusUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 6b59900

Please sign in to comment.