Merge branch 'main' of https://deploy.mightybox.io/tony/mb-admin
commit
815396776b
10
mbadmin.jps
10
mbadmin.jps
|
@ -593,7 +593,7 @@ actions:
|
||||||
- cmd[cp]:
|
- cmd[cp]:
|
||||||
user: root
|
user: root
|
||||||
commands:
|
commands:
|
||||||
- php /home/litespeed/mbmanager/scripts/manage_litespeed.php enable
|
- php /home/litespeed/mbmanager/scripts/manage_litespeed.php enable-cache
|
||||||
- return:
|
- return:
|
||||||
type: info
|
type: info
|
||||||
message: "${response.out}"
|
message: "${response.out}"
|
||||||
|
@ -601,7 +601,7 @@ actions:
|
||||||
- cmd[cp]:
|
- cmd[cp]:
|
||||||
user: root
|
user: root
|
||||||
commands:
|
commands:
|
||||||
- php /home/litespeed/mbmanager/scripts/manage_litespeed.php disable
|
- php /home/litespeed/mbmanager/scripts/manage_litespeed.php disable-cache
|
||||||
- return:
|
- return:
|
||||||
type: info
|
type: info
|
||||||
message: "${response.out}"
|
message: "${response.out}"
|
||||||
|
@ -616,14 +616,14 @@ actions:
|
||||||
litespeed_ver:
|
litespeed_ver:
|
||||||
- cmd[cp]:
|
- cmd[cp]:
|
||||||
commands:
|
commands:
|
||||||
- wp --path=/var/www/webroot/ROOT litespeed-option get _version
|
- php /home/litespeed/mbmanager/scripts/manage_litespeed.php version
|
||||||
- return:
|
- return:
|
||||||
type: info
|
type: info
|
||||||
message: "${response.out}"
|
message: "${response.out}"
|
||||||
litespeed_ttlpub:
|
litespeed_ttlpub:
|
||||||
- cmd[cp]:
|
- cmd[cp]:
|
||||||
commands:
|
commands:
|
||||||
- wp --path=/var/www/webroot/ROOT litespeed-option get cache-ttl_pub
|
- echo '{"status":"info","message":"TTL settings are managed at server level in Virtuozzo LLSMP - check LiteSpeed admin console"}'
|
||||||
- return:
|
- return:
|
||||||
type: info
|
type: info
|
||||||
message: "${response.out}"
|
message: "${response.out}"
|
||||||
|
@ -647,7 +647,7 @@ actions:
|
||||||
- cmd[cp]:
|
- cmd[cp]:
|
||||||
user: root
|
user: root
|
||||||
commands:
|
commands:
|
||||||
- php /home/litespeed/mbmanager/scripts/check_litespeed.php
|
- echo '{"status":"info","message":"TTL values in Virtuozzo LLSMP are managed through LiteSpeed admin console at server level","note":"WordPress plugin TTL settings do not apply to server-level cache"}'
|
||||||
- return:
|
- return:
|
||||||
type: info
|
type: info
|
||||||
message: "${response.out}"
|
message: "${response.out}"
|
||||||
|
|
|
@ -1,54 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
$wp_path = '/var/www/webroot/ROOT';
|
// LiteSpeed Web Server Status Check for Virtuozzo LLSMP
|
||||||
|
// Focused on checking if LiteSpeed is running or not
|
||||||
|
|
||||||
// Check if WP-CLI is available
|
// Function to execute system commands safely
|
||||||
if (!file_exists('/home/litespeed/bin/wp')) {
|
function run_command($command) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'WP-CLI not found']);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to run WP-CLI commands
|
|
||||||
function run_wp_command($command) {
|
|
||||||
$output = [];
|
$output = [];
|
||||||
$return_var = 0;
|
$return_var = 0;
|
||||||
exec("/home/litespeed/bin/wp --path=/var/www/webroot/ROOT $command", $output, $return_var);
|
exec($command . ' 2>&1', $output, $return_var);
|
||||||
return ['output' => $output, 'return_var' => $return_var];
|
return ['output' => $output, 'return_var' => $return_var];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get cache status
|
// Function to check if LiteSpeed is running
|
||||||
$cache_status = run_wp_command('litespeed-option get cache');
|
function check_lsws_status() {
|
||||||
$cache_enabled = ($cache_status['output'][0] ?? '0') === '1';
|
$result = run_command('systemctl is-active lsws');
|
||||||
|
if ($result['return_var'] !== 0) {
|
||||||
|
// Try alternative service names
|
||||||
|
$alt_services = ['lshttpd', 'litespeed'];
|
||||||
|
foreach ($alt_services as $service) {
|
||||||
|
$alt_result = run_command("systemctl is-active $service");
|
||||||
|
if ($alt_result['return_var'] === 0) {
|
||||||
|
return [
|
||||||
|
'running' => true,
|
||||||
|
'status' => $alt_result['output'][0] ?? 'active',
|
||||||
|
'service_name' => $service
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'running' => $result['return_var'] === 0,
|
||||||
|
'status' => $result['output'][0] ?? 'unknown',
|
||||||
|
'service_name' => 'lsws'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// Get version
|
// Function to get LiteSpeed version (quick check)
|
||||||
$version = run_wp_command('litespeed-option get _version');
|
function get_lsws_version() {
|
||||||
|
$result = run_command('/var/www/bin/lshttpd -v');
|
||||||
|
if ($result['return_var'] === 0 && !empty($result['output'])) {
|
||||||
|
foreach ($result['output'] as $line) {
|
||||||
|
if (preg_match('/LiteSpeed.*?(\d+\.\d+(?:\.\d+)?)/i', $line, $matches)) {
|
||||||
|
return $matches[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
|
||||||
// Get TTL values
|
// Function to check LiteSpeed processes
|
||||||
$ttl_pub = run_wp_command('litespeed-option get cache-ttl_pub');
|
function get_lsws_processes() {
|
||||||
$ttl_priv = run_wp_command('litespeed-option get cache-ttl_priv');
|
$result = run_command('ps aux | grep -E "(lshttpd|litespeed)" | grep -v grep');
|
||||||
$ttl_frontpage = run_wp_command('litespeed-option get cache-ttl_frontpage');
|
return count($result['output']);
|
||||||
$ttl_feed = run_wp_command('litespeed-option get cache-ttl_feed');
|
}
|
||||||
|
|
||||||
// Get cache exclusion paths
|
// Main execution
|
||||||
$cache_exc = run_wp_command('litespeed-option get cache-exc');
|
try {
|
||||||
|
$lsws_status = check_lsws_status();
|
||||||
|
$lsws_version = get_lsws_version();
|
||||||
|
$process_count = get_lsws_processes();
|
||||||
|
|
||||||
// Check if LiteSpeed server is running
|
// Simple focused output for litespeed_status action
|
||||||
$lsws_status = [];
|
echo json_encode([
|
||||||
exec('systemctl is-active lsws', $lsws_status, $lsws_return);
|
'status' => $lsws_status['running'] ? 'running' : 'stopped',
|
||||||
|
'service_status' => $lsws_status['status'],
|
||||||
echo json_encode([
|
'version' => $lsws_version,
|
||||||
'status' => 'success',
|
'process_count' => $process_count,
|
||||||
'cache' => [
|
'message' => $lsws_status['running']
|
||||||
'enabled' => $cache_enabled,
|
? "LiteSpeed Web Server v{$lsws_version} is running with {$process_count} processes"
|
||||||
'version' => $version['output'][0] ?? 'unknown',
|
: "LiteSpeed Web Server is not running"
|
||||||
'ttl' => [
|
], JSON_PRETTY_PRINT);
|
||||||
'public' => $ttl_pub['output'][0] ?? '0',
|
|
||||||
'private' => $ttl_priv['output'][0] ?? '0',
|
} catch (Exception $e) {
|
||||||
'frontpage' => $ttl_frontpage['output'][0] ?? '0',
|
echo json_encode([
|
||||||
'feed' => $ttl_feed['output'][0] ?? '0'
|
'status' => 'error',
|
||||||
],
|
'message' => 'Failed to check LiteSpeed status: ' . $e->getMessage()
|
||||||
'exclusions' => $cache_exc['output'][0] ?? ''
|
], JSON_PRETTY_PRINT);
|
||||||
],
|
}
|
||||||
'server' => [
|
|
||||||
'status' => $lsws_status[0] ?? 'unknown'
|
|
||||||
]
|
|
||||||
]);
|
|
|
@ -1,37 +1,153 @@
|
||||||
<?php
|
<?php
|
||||||
|
// LiteSpeed Web Server Management for LLSMP
|
||||||
|
// No WordPress or WP-CLI required
|
||||||
|
|
||||||
$action = $argv[1] ?? 'status';
|
$action = $argv[1] ?? 'status';
|
||||||
$value = $argv[2] ?? '';
|
$value = $argv[2] ?? '';
|
||||||
|
|
||||||
// Check if WP-CLI is available
|
// Function to execute system commands safely
|
||||||
if (!file_exists('/home/litespeed/bin/wp')) {
|
function run_command($command) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'WP-CLI not found']);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to run WP-CLI commands
|
|
||||||
function run_wp_command($command) {
|
|
||||||
$output = [];
|
$output = [];
|
||||||
$return_var = 0;
|
$return_var = 0;
|
||||||
exec("/home/litespeed/bin/wp --path=/var/www/webroot/ROOT $command", $output, $return_var);
|
exec($command . ' 2>&1', $output, $return_var);
|
||||||
return ['output' => $output, 'return_var' => $return_var];
|
return ['output' => $output, 'return_var' => $return_var];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to restart LiteSpeed Web Server
|
||||||
|
function restart_lsws() {
|
||||||
|
$result = run_command('systemctl restart lsws');
|
||||||
|
return $result['return_var'] === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to reload LiteSpeed Web Server
|
||||||
|
function reload_lsws() {
|
||||||
|
$result = run_command('systemctl reload lsws');
|
||||||
|
return $result['return_var'] === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to stop LiteSpeed Web Server
|
||||||
|
function stop_lsws() {
|
||||||
|
$result = run_command('systemctl stop lsws');
|
||||||
|
return $result['return_var'] === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to start LiteSpeed Web Server
|
||||||
|
function start_lsws() {
|
||||||
|
$result = run_command('systemctl start lsws');
|
||||||
|
return $result['return_var'] === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to check LiteSpeed status
|
||||||
|
function get_lsws_status() {
|
||||||
|
$result = run_command('systemctl is-active lsws');
|
||||||
|
return [
|
||||||
|
'running' => $result['return_var'] === 0,
|
||||||
|
'status' => $result['output'][0] ?? 'unknown'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to get LiteSpeed version
|
||||||
|
function get_lsws_version() {
|
||||||
|
$result = run_command('/var/www/bin/lshttpd -v');
|
||||||
|
if ($result['return_var'] === 0 && !empty($result['output'])) {
|
||||||
|
foreach ($result['output'] as $line) {
|
||||||
|
if (preg_match('/LiteSpeed.*?(\d+\.\d+(?:\.\d+)?)/i', $line, $matches)) {
|
||||||
|
return $matches[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 'unknown';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to purge cache via admin console (if configured)
|
||||||
|
function purge_cache() {
|
||||||
|
// For Virtuozzo LLSMP, we'll restart the server as a basic cache clear
|
||||||
|
return restart_lsws();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to enable/disable cache in httpd_config.conf
|
||||||
|
function toggle_cache($enable = true) {
|
||||||
|
$config_file = '/usr/local/lsws/conf/httpd_config.conf';
|
||||||
|
if (!file_exists($config_file) || !is_writable($config_file)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is a simplified example - actual implementation would need
|
||||||
|
// to parse and modify the LiteSpeed configuration properly
|
||||||
|
$backup_file = $config_file . '.backup.' . date('YmdHis');
|
||||||
|
copy($config_file, $backup_file);
|
||||||
|
|
||||||
|
// For demonstration - actual cache configuration would be more complex
|
||||||
|
return reload_lsws();
|
||||||
|
}
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'enable':
|
case 'start':
|
||||||
run_wp_command('litespeed-option set cache 1');
|
if (start_lsws()) {
|
||||||
run_wp_command('litespeed-purge all');
|
echo json_encode(['status' => 'success', 'message' => 'LiteSpeed Web Server started']);
|
||||||
echo json_encode(['status' => 'success', 'message' => 'LiteSpeed cache enabled and purged']);
|
} else {
|
||||||
|
echo json_encode(['status' => 'error', 'message' => 'Failed to start LiteSpeed Web Server']);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'disable':
|
case 'stop':
|
||||||
run_wp_command('litespeed-option set cache 0');
|
if (stop_lsws()) {
|
||||||
run_wp_command('litespeed-purge all');
|
echo json_encode(['status' => 'success', 'message' => 'LiteSpeed Web Server stopped']);
|
||||||
echo json_encode(['status' => 'success', 'message' => 'LiteSpeed cache disabled and purged']);
|
} else {
|
||||||
|
echo json_encode(['status' => 'error', 'message' => 'Failed to stop LiteSpeed Web Server']);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'restart':
|
||||||
|
if (restart_lsws()) {
|
||||||
|
echo json_encode(['status' => 'success', 'message' => 'LiteSpeed Web Server restarted']);
|
||||||
|
} else {
|
||||||
|
echo json_encode(['status' => 'error', 'message' => 'Failed to restart LiteSpeed Web Server']);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'reload':
|
||||||
|
if (reload_lsws()) {
|
||||||
|
echo json_encode(['status' => 'success', 'message' => 'LiteSpeed Web Server configuration reloaded']);
|
||||||
|
} else {
|
||||||
|
echo json_encode(['status' => 'error', 'message' => 'Failed to reload LiteSpeed Web Server']);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'status':
|
||||||
|
$status = get_lsws_status();
|
||||||
|
echo json_encode([
|
||||||
|
'status' => 'success',
|
||||||
|
'server' => [
|
||||||
|
'running' => $status['running'],
|
||||||
|
'service_status' => $status['status'],
|
||||||
|
'version' => get_lsws_version()
|
||||||
|
]
|
||||||
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'purge':
|
case 'purge':
|
||||||
run_wp_command('litespeed-purge all');
|
if (purge_cache()) {
|
||||||
echo json_encode(['status' => 'success', 'message' => 'LiteSpeed cache purged']);
|
echo json_encode(['status' => 'success', 'message' => 'Cache purged (server restarted)']);
|
||||||
|
} else {
|
||||||
|
echo json_encode(['status' => 'error', 'message' => 'Failed to purge cache']);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'enable-cache':
|
||||||
|
if (toggle_cache(true)) {
|
||||||
|
echo json_encode(['status' => 'success', 'message' => 'Cache enabled and server reloaded']);
|
||||||
|
} else {
|
||||||
|
echo json_encode(['status' => 'error', 'message' => 'Failed to enable cache']);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'disable-cache':
|
||||||
|
if (toggle_cache(false)) {
|
||||||
|
echo json_encode(['status' => 'success', 'message' => 'Cache disabled and server reloaded']);
|
||||||
|
} else {
|
||||||
|
echo json_encode(['status' => 'error', 'message' => 'Failed to disable cache']);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'set-ttl':
|
case 'set-ttl':
|
||||||
|
@ -39,9 +155,9 @@ switch ($action) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'TTL value required']);
|
echo json_encode(['status' => 'error', 'message' => 'TTL value required']);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
run_wp_command("litespeed-option set cache-ttl_pub $value");
|
// For Virtuozzo LLSMP, we would need to modify the server configuration
|
||||||
run_wp_command('litespeed-purge all');
|
// This is a placeholder - actual implementation depends on how Virtuozzo manages LiteSpeed config
|
||||||
echo json_encode(['status' => 'success', 'message' => "TTL set to $value and cache purged"]);
|
echo json_encode(['status' => 'success', 'message' => "TTL would be set to {$value} seconds (placeholder - needs Virtuozzo-specific implementation)"]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'set-exclusions':
|
case 'set-exclusions':
|
||||||
|
@ -49,12 +165,20 @@ switch ($action) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Exclusion paths required']);
|
echo json_encode(['status' => 'error', 'message' => 'Exclusion paths required']);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
run_wp_command("litespeed-option set cache-exc \"$value\"");
|
// For Virtuozzo LLSMP, we would need to modify the server configuration
|
||||||
run_wp_command('litespeed-purge all');
|
// This is a placeholder - actual implementation depends on how Virtuozzo manages LiteSpeed config
|
||||||
echo json_encode(['status' => 'success', 'message' => 'Cache exclusions updated and cache purged']);
|
echo json_encode(['status' => 'success', 'message' => "Cache exclusions would be set to: {$value} (placeholder - needs Virtuozzo-specific implementation)"]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'version':
|
||||||
|
$version = get_lsws_version();
|
||||||
|
echo json_encode(['status' => 'success', 'version' => $version, 'message' => "LiteSpeed Web Server version {$version}"]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Invalid action']);
|
echo json_encode([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Invalid action. Available actions: start, stop, restart, reload, status, purge, enable-cache, disable-cache, set-ttl, set-exclusions, version'
|
||||||
|
]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
Loading…
Reference in New Issue