Restart restapi.sevice on API key save

This commit is contained in:
billz 2024-03-09 12:23:20 +01:00
parent 8d6b8174d1
commit d1be0caf54

View file

@ -26,6 +26,10 @@ function DisplayRestAPI()
$status->addMessage('Please enter a valid API key', 'danger');
} else {
$return = saveAPISettings($status, $apiKey, $dotenv);
$status->addMessage('Restarting restapi.service', 'info');
exec('sudo /bin/systemctl stop restapi.service', $return);
sleep(1);
exec('sudo /bin/systemctl start restapi.service', $return);
}
}
} elseif (isset($_POST['StartRestAPIservice'])) {
@ -75,7 +79,6 @@ function saveAPISettings($status, $apiKey, $dotenv)
{
$status->addMessage('Saving API key', 'info');
$dotenv->set('RASPAP_API_KEY', $apiKey);
return $status;
}