Generate new apikey if there isn't already generated one.

This commit is contained in:
Abdulmhsen B. A. A
2024-04-27 15:36:20 +03:00
parent acd976d14a
commit 1677a58785
2 changed files with 3 additions and 9 deletions

View File

@@ -76,6 +76,8 @@ echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Running database maintenance tasks."
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Ensuring state table has correct indexes."
/opt/bin/console system:index
/opt/bin/console system:apikey -q
if [ 0 = "${WS_DISABLE_CRON}" ]; then
if [ -f "/tmp/job-runner.pid" ]; then
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Found pre-existing tasks scheduler pid file. Removing it."

View File

@@ -43,18 +43,10 @@ final class APIKeyCommand extends Command
protected function runCommand(iInput $input, iOutput $output): int
{
$regenerate = (bool)$input->getOption('regenerate');
if ($regenerate) {
if ($regenerate || null === ($apiKey = Config::get('api.key'))) {
return $this->regenerate($output);
}
if (null === ($apiKey = Config::get('api.key'))) {
$output->writeln('<error>API key is not set.</error>');
$output->writeln(
'<info>Use the --regenerate option to generate a new API key to enable API & WebUI.</info>'
);
return self::FAILURE;
}
$output->writeln('<info>Current API key:</info>');
$output->writeln('<comment>' . $apiKey . '</comment>');