2021-06-28 12:34:19 +02:00
|
|
|
<?php
|
|
|
|
|
2021-07-19 07:53:45 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-06-28 12:34:19 +02:00
|
|
|
namespace App\Console\Command;
|
|
|
|
|
|
|
|
use App\Entity;
|
|
|
|
use App\Environment;
|
2022-06-09 09:27:19 +02:00
|
|
|
use App\Service\Acme;
|
2021-12-23 02:32:40 +01:00
|
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
2021-06-28 12:34:19 +02:00
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
|
2021-12-23 02:32:40 +01:00
|
|
|
#[AsCommand(
|
|
|
|
name: 'azuracast:setup:initialize',
|
|
|
|
description: 'Ensure key settings are initialized within AzuraCast.',
|
|
|
|
)]
|
2021-06-28 12:34:19 +02:00
|
|
|
class InitializeCommand extends CommandAbstract
|
|
|
|
{
|
2021-12-23 02:32:40 +01:00
|
|
|
public function __construct(
|
|
|
|
protected Environment $environment,
|
|
|
|
protected Entity\Repository\StorageLocationRepository $storageLocationRepo,
|
2022-06-09 09:27:19 +02:00
|
|
|
protected Acme $acme,
|
2021-12-23 02:32:40 +01:00
|
|
|
) {
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
|
|
{
|
|
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
|
2021-06-28 12:34:19 +02:00
|
|
|
$io->title(__('Initialize AzuraCast'));
|
|
|
|
$io->writeln(__('Initializing essential settings...'));
|
|
|
|
|
|
|
|
$io->listing(
|
|
|
|
[
|
2022-05-07 18:44:14 +02:00
|
|
|
sprintf(
|
|
|
|
__('Environment: %s'),
|
|
|
|
$this->environment->getAppEnvironmentEnum()->getName()
|
|
|
|
),
|
|
|
|
sprintf(
|
|
|
|
__('Installation Method: %s'),
|
|
|
|
$this->environment->isDocker() ? 'Docker' : 'Ansible'
|
|
|
|
),
|
2021-06-28 12:34:19 +02:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$io->newLine();
|
|
|
|
$io->section(__('Running Database Migrations'));
|
|
|
|
|
|
|
|
$this->runCommand(
|
|
|
|
$output,
|
|
|
|
'migrations:migrate',
|
|
|
|
[
|
|
|
|
'--allow-no-migration' => true,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$io->newLine();
|
|
|
|
$io->section(__('Generating Database Proxy Classes'));
|
|
|
|
|
|
|
|
$this->runCommand($output, 'orm:generate-proxies');
|
|
|
|
|
|
|
|
$io->newLine();
|
|
|
|
$io->section(__('Reload System Data'));
|
|
|
|
|
|
|
|
$this->runCommand($output, 'cache:clear');
|
|
|
|
|
|
|
|
// Ensure default storage locations exist.
|
2021-12-23 02:32:40 +01:00
|
|
|
$this->storageLocationRepo->createDefaultStorageLocations();
|
2021-06-28 12:34:19 +02:00
|
|
|
|
2022-06-09 09:27:19 +02:00
|
|
|
// Pull Acme certificates if necessary.
|
|
|
|
try {
|
|
|
|
$this->acme->getCertificate();
|
|
|
|
} catch (\Exception) {
|
|
|
|
// Noop
|
|
|
|
}
|
|
|
|
|
2021-06-28 12:34:19 +02:00
|
|
|
$io->newLine();
|
|
|
|
$io->success(
|
|
|
|
[
|
|
|
|
__('AzuraCast is now initialized.'),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|