fix: Use absolute paths and update sudoers for systemctl/lsscsi
This commit is contained in:
30
dist/adastra-vtl-installer/web-ui/api.php
vendored
30
dist/adastra-vtl-installer/web-ui/api.php
vendored
@@ -566,23 +566,15 @@ function loadConfig() {
|
||||
}
|
||||
|
||||
function restartService() {
|
||||
// Check if user has sudo privileges
|
||||
$output = [];
|
||||
$returnCode = 0;
|
||||
// Run systemctl restart in background to prevent PHP timeout/hanging
|
||||
// We strictly redirect output to /dev/null to ensure exec returns immediately
|
||||
|
||||
exec("sudo /usr/bin/systemctl restart mhvtl > /dev/null 2>&1 &");
|
||||
|
||||
exec('sudo systemctl restart mhvtl 2>&1', $output, $returnCode);
|
||||
|
||||
if ($returnCode === 0) {
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => 'Service restarted successfully'
|
||||
]);
|
||||
} else {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'error' => 'Failed to restart service: ' . implode("\n", $output)
|
||||
]);
|
||||
}
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => 'Service restart initiated. Changes will take effect in a few seconds.'
|
||||
]);
|
||||
}
|
||||
|
||||
function listTapes() {
|
||||
@@ -869,7 +861,7 @@ function restartAppliance() {
|
||||
// Create a script to restart after a delay
|
||||
$script = '#!/bin/bash
|
||||
sleep 2
|
||||
systemctl reboot
|
||||
/usr/bin/systemctl reboot
|
||||
';
|
||||
|
||||
$scriptPath = '/tmp/restart-appliance.sh';
|
||||
@@ -889,7 +881,7 @@ function shutdownAppliance() {
|
||||
// Create a script to shutdown after a delay
|
||||
$script = '#!/bin/bash
|
||||
sleep 2
|
||||
systemctl poweroff
|
||||
/usr/bin/systemctl poweroff
|
||||
';
|
||||
|
||||
$scriptPath = '/tmp/shutdown-appliance.sh';
|
||||
@@ -908,7 +900,7 @@ systemctl poweroff
|
||||
function getDeviceMapping() {
|
||||
$output = [];
|
||||
// Get all SCSI devices with generic device names (sg)
|
||||
exec("lsscsi -g 2>&1", $output);
|
||||
exec("sudo /usr/bin/lsscsi -g 2>&1", $output);
|
||||
|
||||
// Filter for interesting devices (mediumx and tape)
|
||||
$devices = [];
|
||||
|
||||
Reference in New Issue
Block a user