feat: convert WordOps from Nginx to OpenLiteSpeed + LSPHP + LSCache
Complete conversion of the WordOps stack from Nginx + PHP-FPM to OpenLiteSpeed + LSPHP + LSCache. This is a full rewrite across all 7 phases of the codebase: - Foundation: OLS paths, variables, services, removed pynginxconfig dep - Templates: 11 new OLS mustache templates, removed nginx-specific ones - Stack: stack_pref, stack, stack_services, stack_upgrade, stack_migrate - Site: site_functions, site, site_create, site_update - Plugins: debug, info, log, clean rewritten for OLS - SSL/ACME: acme.sh deploy uses lswsctrl, OLS vhssl blocks - Other: secure, backup, clone, install script Additional features: - Debian 13 (trixie) support - PHP 8.5 support - WP Fort Knox mu-plugin integration (wo secure --lockdown/--unlock) - --nginx CLI flag preserved for backward compatibility Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,24 +15,25 @@ class WOService():
|
||||
Similar to `service xyz start`
|
||||
"""
|
||||
try:
|
||||
if service_name in ['nginx']:
|
||||
Log.wait(self, "Testing Nginx configuration ")
|
||||
# Check Nginx configuration before executing command
|
||||
sub = subprocess.Popen('nginx -t', stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
if service_name in ['lsws']:
|
||||
Log.wait(self, "Testing OpenLiteSpeed configuration ")
|
||||
sub = subprocess.Popen(
|
||||
'/usr/local/lsws/bin/openlitespeed -t',
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
output = sub.communicate()
|
||||
if 'emerg' not in str(output):
|
||||
Log.valide(self, "Testing Nginx configuration ")
|
||||
Log.wait(self, "Starting Nginx")
|
||||
service_cmd = ('service {0} start'.format(service_name))
|
||||
if sub.returncode == 0:
|
||||
Log.valide(self, "Testing OpenLiteSpeed configuration ")
|
||||
Log.wait(self, "Starting OpenLiteSpeed")
|
||||
service_cmd = ('/usr/local/lsws/bin/lswsctrl start')
|
||||
retcode = subprocess.getstatusoutput(service_cmd)
|
||||
if retcode[0] == 0:
|
||||
Log.valide(self, "Starting Nginx ")
|
||||
Log.valide(self, "Starting OpenLiteSpeed ")
|
||||
return True
|
||||
else:
|
||||
Log.failed(self, "Starting Nginx")
|
||||
Log.failed(self, "Starting OpenLiteSpeed")
|
||||
else:
|
||||
Log.failed(self, "Testing Nginx configuration ")
|
||||
Log.failed(self, "Testing OpenLiteSpeed configuration ")
|
||||
return False
|
||||
else:
|
||||
service_cmd = ('service {0} start'.format(service_name))
|
||||
@@ -59,9 +60,14 @@ class WOService():
|
||||
Similar to `service xyz stop`
|
||||
"""
|
||||
try:
|
||||
Log.info(self, "Stop : {0:10}" .format(service_name), end='')
|
||||
retcode = subprocess.getstatusoutput('service {0} stop'
|
||||
.format(service_name))
|
||||
if service_name in ['lsws']:
|
||||
Log.info(self, "Stop : {0:10}" .format(service_name), end='')
|
||||
retcode = subprocess.getstatusoutput(
|
||||
'/usr/local/lsws/bin/lswsctrl stop')
|
||||
else:
|
||||
Log.info(self, "Stop : {0:10}" .format(service_name), end='')
|
||||
retcode = subprocess.getstatusoutput('service {0} stop'
|
||||
.format(service_name))
|
||||
if retcode[0] == 0:
|
||||
Log.info(self, "[" + Log.ENDC + Log.OKGREEN + "OK" +
|
||||
Log.ENDC + Log.OKBLUE + "]")
|
||||
@@ -81,22 +87,23 @@ class WOService():
|
||||
Similar to `service xyz restart`
|
||||
"""
|
||||
try:
|
||||
if service_name in ['nginx']:
|
||||
Log.wait(self, "Testing Nginx configuration ")
|
||||
# Check Nginx configuration before executing command
|
||||
sub = subprocess.Popen('nginx -t', stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
if service_name in ['lsws']:
|
||||
Log.wait(self, "Testing OpenLiteSpeed configuration ")
|
||||
sub = subprocess.Popen(
|
||||
'/usr/local/lsws/bin/openlitespeed -t',
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
output, error_output = sub.communicate()
|
||||
if 'emerg' not in str(error_output):
|
||||
Log.valide(self, "Testing Nginx configuration ")
|
||||
Log.wait(self, "Restarting Nginx")
|
||||
service_cmd = ('service {0} restart'.format(service_name))
|
||||
if sub.returncode == 0:
|
||||
Log.valide(self, "Testing OpenLiteSpeed configuration ")
|
||||
Log.wait(self, "Restarting OpenLiteSpeed")
|
||||
service_cmd = ('/usr/local/lsws/bin/lswsctrl restart')
|
||||
retcode = subprocess.getstatusoutput(service_cmd)
|
||||
if retcode[0] == 0:
|
||||
Log.valide(self, "Restarting Nginx")
|
||||
Log.valide(self, "Restarting OpenLiteSpeed")
|
||||
return True
|
||||
else:
|
||||
Log.failed(self, "Testing Nginx configuration ")
|
||||
Log.failed(self, "Testing OpenLiteSpeed configuration ")
|
||||
return False
|
||||
else:
|
||||
service_cmd = ('service {0} restart'.format(service_name))
|
||||
@@ -123,22 +130,23 @@ class WOService():
|
||||
Similar to `service xyz reload`
|
||||
"""
|
||||
try:
|
||||
if service_name in ['nginx']:
|
||||
# Check Nginx configuration before executing command
|
||||
Log.wait(self, "Testing Nginx configuration ")
|
||||
sub = subprocess.Popen('nginx -t', stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
if service_name in ['lsws']:
|
||||
Log.wait(self, "Testing OpenLiteSpeed configuration ")
|
||||
sub = subprocess.Popen(
|
||||
'/usr/local/lsws/bin/openlitespeed -t',
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell=True)
|
||||
output, error_output = sub.communicate()
|
||||
if 'emerg' not in str(error_output):
|
||||
Log.valide(self, "Testing Nginx configuration ")
|
||||
Log.wait(self, "Reloading Nginx")
|
||||
service_cmd = ('service {0} reload'.format(service_name))
|
||||
if sub.returncode == 0:
|
||||
Log.valide(self, "Testing OpenLiteSpeed configuration ")
|
||||
Log.wait(self, "Reloading OpenLiteSpeed")
|
||||
service_cmd = ('/usr/local/lsws/bin/lswsctrl restart')
|
||||
retcode = subprocess.getstatusoutput(service_cmd)
|
||||
if retcode[0] == 0:
|
||||
Log.valide(self, "Reloading Nginx")
|
||||
Log.valide(self, "Reloading OpenLiteSpeed")
|
||||
return True
|
||||
else:
|
||||
Log.failed(self, "Testing Nginx configuration ")
|
||||
Log.failed(self, "Testing OpenLiteSpeed configuration ")
|
||||
return False
|
||||
else:
|
||||
service_cmd = ('service {0} reload'.format(service_name))
|
||||
@@ -162,26 +170,27 @@ class WOService():
|
||||
def get_service_status(self, service_name):
|
||||
|
||||
try:
|
||||
is_exist = subprocess.getstatusoutput('command -v {0}'
|
||||
.format(service_name))
|
||||
if is_exist[0] == 0 or service_name in ['php7.2-fpm',
|
||||
'php7.3-fpm',
|
||||
'php7.4-fpm',
|
||||
'php8.0-fpm',
|
||||
'php8.1-fpm',
|
||||
'php8.2-fpm',
|
||||
'php8.3-fpm',
|
||||
'php8.4-fpm',
|
||||
]:
|
||||
retcode = subprocess.getstatusoutput('service {0} status'
|
||||
.format(service_name))
|
||||
if service_name in ['lsws']:
|
||||
retcode = subprocess.getstatusoutput(
|
||||
'/usr/local/lsws/bin/lswsctrl status')
|
||||
if retcode[0] == 0:
|
||||
return True
|
||||
else:
|
||||
Log.debug(self, "{0}".format(retcode[1]))
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
is_exist = subprocess.getstatusoutput('command -v {0}'
|
||||
.format(service_name))
|
||||
if is_exist[0] == 0:
|
||||
retcode = subprocess.getstatusoutput('service {0} status'
|
||||
.format(service_name))
|
||||
if retcode[0] == 0:
|
||||
return True
|
||||
else:
|
||||
Log.debug(self, "{0}".format(retcode[1]))
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
except OSError as e:
|
||||
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
|
||||
Log.error(self, "Unable to get services status of {0}"
|
||||
|
||||
Reference in New Issue
Block a user