2018-05-17 07:01:43 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-08-04 22:05:14 +00:00
|
|
|
namespace App\Console\Command;
|
2018-05-17 07:01:43 +00:00
|
|
|
|
2018-11-15 13:41:52 +00:00
|
|
|
use App\Entity;
|
2020-12-03 04:18:06 +00:00
|
|
|
use App\Environment;
|
2019-08-10 07:45:17 +00:00
|
|
|
use App\Service\AzuraCastCentral;
|
2021-12-23 01:32:40 +00:00
|
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
2018-05-17 07:01:43 +00:00
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
2018-05-29 03:17:13 +00:00
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
2018-05-17 07:01:43 +00:00
|
|
|
|
2021-12-23 01:32:40 +00:00
|
|
|
#[AsCommand(
|
|
|
|
name: 'azuracast:setup',
|
|
|
|
description: 'Run all general AzuraCast setup steps.',
|
|
|
|
)]
|
2022-07-01 06:06:29 +00:00
|
|
|
final class SetupCommand extends CommandAbstract
|
2018-05-17 07:01:43 +00:00
|
|
|
{
|
2021-12-23 01:32:40 +00:00
|
|
|
public function __construct(
|
2022-07-01 06:06:29 +00:00
|
|
|
private readonly Environment $environment,
|
|
|
|
private readonly Entity\Repository\SettingsRepository $settingsRepo,
|
|
|
|
private readonly AzuraCastCentral $acCentral,
|
2023-01-15 22:30:22 +00:00
|
|
|
private readonly Entity\Repository\StorageLocationRepository $storageLocationRepo
|
2021-12-23 01:32:40 +00:00
|
|
|
) {
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function configure(): void
|
|
|
|
{
|
|
|
|
$this->addOption('update', null, InputOption::VALUE_NONE)
|
|
|
|
->addOption('load-fixtures', null, InputOption::VALUE_NONE)
|
2023-01-15 22:30:22 +00:00
|
|
|
->addOption('release', null, InputOption::VALUE_NONE)
|
|
|
|
->addOption('init', null, InputOption::VALUE_NONE);
|
2021-12-23 01:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
|
|
{
|
|
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
|
|
|
|
$update = (bool)$input->getOption('update');
|
|
|
|
$loadFixtures = (bool)$input->getOption('load-fixtures');
|
2023-01-15 22:30:22 +00:00
|
|
|
$isInit = (bool)$input->getOption('init');
|
2021-12-23 01:32:40 +00:00
|
|
|
|
2023-01-15 22:30:22 +00:00
|
|
|
if ($isInit) {
|
|
|
|
$update = true;
|
|
|
|
$loadFixtures = false;
|
|
|
|
}
|
2018-05-29 03:17:13 +00:00
|
|
|
|
2023-01-15 22:30:22 +00:00
|
|
|
if (!$update && !$this->environment->isProduction()) {
|
|
|
|
$loadFixtures = true;
|
|
|
|
}
|
2018-05-17 07:01:43 +00:00
|
|
|
|
2023-01-15 22:30:22 +00:00
|
|
|
// Header display
|
|
|
|
if ($isInit) {
|
|
|
|
$io->title(__('AzuraCast Initializing...'));
|
|
|
|
} else {
|
|
|
|
$io->title(__('AzuraCast Setup'));
|
|
|
|
$io->writeln(
|
|
|
|
__('Welcome to AzuraCast. Please wait while some key dependencies of AzuraCast are set up...')
|
|
|
|
);
|
2018-05-29 03:17:13 +00:00
|
|
|
$io->newLine();
|
2023-01-15 22:30:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$io->section(__('Running Database Migrations'));
|
|
|
|
|
|
|
|
$this->runCommand(
|
|
|
|
$output,
|
|
|
|
'azuracast:setup:migrate'
|
|
|
|
);
|
|
|
|
|
|
|
|
$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.
|
|
|
|
$this->storageLocationRepo->createDefaultStorageLocations();
|
|
|
|
|
|
|
|
$io->newLine();
|
|
|
|
|
|
|
|
if ($loadFixtures) {
|
2019-08-21 22:33:47 +00:00
|
|
|
$io->section(__('Installing Data Fixtures'));
|
2018-05-29 03:17:13 +00:00
|
|
|
|
2018-05-17 07:01:43 +00:00
|
|
|
$this->runCommand($output, 'azuracast:setup:fixtures');
|
2023-01-15 22:30:22 +00:00
|
|
|
$io->newLine();
|
2018-05-17 07:01:43 +00:00
|
|
|
}
|
|
|
|
|
2019-09-28 02:07:33 +00:00
|
|
|
$io->section(__('Refreshing All Stations'));
|
2020-08-29 05:04:18 +00:00
|
|
|
|
2022-03-15 08:38:32 +00:00
|
|
|
$this->runCommand($output, 'azuracast:station-queues:clear');
|
|
|
|
|
2022-03-15 08:58:47 +00:00
|
|
|
$restartArgs = [];
|
2022-05-03 20:10:16 +00:00
|
|
|
if ($this->environment->isDocker()) {
|
2022-03-23 08:04:04 +00:00
|
|
|
$restartArgs['--no-supervisor-restart'] = true;
|
2022-03-15 08:58:47 +00:00
|
|
|
}
|
|
|
|
|
2022-03-15 08:38:32 +00:00
|
|
|
$this->runCommand(
|
|
|
|
$output,
|
2022-03-15 08:58:47 +00:00
|
|
|
'azuracast:radio:restart',
|
|
|
|
$restartArgs
|
2022-03-15 08:38:32 +00:00
|
|
|
);
|
2018-05-17 07:01:43 +00:00
|
|
|
|
2023-01-15 22:30:22 +00:00
|
|
|
if ($isInit) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-28 10:34:19 +00:00
|
|
|
// Update system setting logging when updates were last run.
|
2021-12-23 01:32:40 +00:00
|
|
|
$settings = $this->settingsRepo->readSettings();
|
2020-12-04 08:41:55 +00:00
|
|
|
$settings->updateUpdateLastRun();
|
2021-12-23 01:32:40 +00:00
|
|
|
$this->settingsRepo->writeSettings($settings);
|
2018-11-15 13:41:52 +00:00
|
|
|
|
2019-09-10 23:10:57 +00:00
|
|
|
if ($update) {
|
2020-12-07 11:29:35 +00:00
|
|
|
$io->success(
|
|
|
|
[
|
|
|
|
__('AzuraCast is now updated to the latest version!'),
|
|
|
|
]
|
|
|
|
);
|
2018-08-09 00:01:46 +00:00
|
|
|
} else {
|
2021-12-23 01:32:40 +00:00
|
|
|
$public_ip = $this->acCentral->getIp(false);
|
2018-08-09 00:01:46 +00:00
|
|
|
|
2021-06-10 03:22:13 +00:00
|
|
|
/** @noinspection HttpUrlsUsage */
|
2020-12-07 11:29:35 +00:00
|
|
|
$io->success(
|
|
|
|
[
|
|
|
|
__('AzuraCast installation complete!'),
|
2022-05-07 16:44:14 +00:00
|
|
|
sprintf(
|
|
|
|
__('Visit %s to complete setup.'),
|
|
|
|
'http://' . $public_ip
|
|
|
|
),
|
2020-12-07 11:29:35 +00:00
|
|
|
]
|
|
|
|
);
|
2019-08-27 12:51:33 +00:00
|
|
|
}
|
2019-08-27 12:13:50 +00:00
|
|
|
|
2018-05-17 07:01:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2018-07-31 04:07:19 +00:00
|
|
|
}
|