|
10 | 10 | import shutil |
11 | 11 | import plogical.CyberCPLogFileWriter as logging |
12 | 12 | from plogical.processUtilities import ProcessUtilities |
13 | | -from websiteFunctions.models import Websites, ChildDomains, aliasDomains |
| 13 | +from websiteFunctions.models import Websites |
14 | 14 | from plogical.virtualHostUtilities import virtualHostUtilities |
15 | 15 | from plogical.sslUtilities import sslUtilities |
16 | 16 | from plogical.vhost import vhost |
17 | | - |
| 17 | +from shutil import copytree, ignore_patterns |
18 | 18 |
|
19 | 19 |
|
20 | 20 | class ServerStatusUtil: |
@@ -145,7 +145,10 @@ def recover(): |
145 | 145 | if os.path.exists('/usr/local/lsws'): |
146 | 146 | shutil.rmtree('/usr/local/lsws') |
147 | 147 |
|
148 | | - command = 'mv /usr/local/lsws.bak /usr/local/lsws' |
| 148 | + command = 'mv /usr/local/lswsbak /usr/local/lsws' |
| 149 | + ServerStatusUtil.executioner(command, FNULL) |
| 150 | + |
| 151 | + command = '/usr/local/lsws/bin/openlitespeed' |
149 | 152 | ServerStatusUtil.executioner(command, FNULL) |
150 | 153 |
|
151 | 154 | @staticmethod |
@@ -279,18 +282,9 @@ def switchTOLSWS(licenseKey): |
279 | 282 | ProcessUtilities.killLiteSpeed() |
280 | 283 |
|
281 | 284 | if os.path.exists('/usr/local/lsws'): |
282 | | - command = 'mkdir /usr/local/lsws.bak' |
283 | | - if ServerStatusUtil.executioner(command, FNULL) == 0: |
284 | | - logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, "Failed to create backup of current LSWS. [mkdir] [404]", 1) |
285 | | - ServerStatusUtil.recover() |
286 | | - return 0 |
287 | 285 |
|
288 | | - command = 'cp -R /usr/local/lsws/* /usr/local/lsws.bak/' |
289 | | - if ServerStatusUtil.executioner(command, FNULL) == 0: |
290 | | - logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, |
291 | | - "Failed to create backup of current LSWS. [cp][404]", 1) |
292 | | - ServerStatusUtil.recover() |
293 | | - return 0 |
| 286 | + if not os.path.exists('/usr/local/lswsbak'): |
| 287 | + shutil.copytree('/usr/local/lsws', '/usr/local/lswsbak', symlinks=True, ignore=ignore_patterns('*.sock*')) |
294 | 288 |
|
295 | 289 | dirs = os.listdir('/usr/local/lsws') |
296 | 290 | for dir in dirs: |
@@ -345,6 +339,8 @@ def switchTOLSWS(licenseKey): |
345 | 339 | logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,"Successfully switched to LITESPEED ENTERPRISE WEB SERVER. [200]\n", 1) |
346 | 340 |
|
347 | 341 | except BaseException, msg: |
| 342 | + logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, |
| 343 | + "%s. [404]" % (str(msg)), 1) |
348 | 344 | logging.CyberCPLogFileWriter.writeToFile(str(msg)) |
349 | 345 | ServerStatusUtil.recover() |
350 | 346 |
|
|
0 commit comments