2018-05-17 07:01:43 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2018-08-04 22:05:14 +00:00
|
|
|
namespace App\Console\Command;
|
2018-05-17 07:01:43 +00:00
|
|
|
|
2020-12-03 04:18:06 +00:00
|
|
|
use App\Environment;
|
2019-08-10 07:45:17 +00:00
|
|
|
use App\Service\AzuraCastCentral;
|
2019-09-29 21:26:46 +00:00
|
|
|
use Psr\Container\ContainerInterface;
|
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
|
|
|
|
2019-09-10 23:10:57 +00:00
|
|
|
class SetupCommand extends CommandAbstract
|
2018-05-17 07:01:43 +00:00
|
|
|
{
|
2019-09-10 23:10:57 +00:00
|
|
|
public function __invoke(
|
|
|
|
SymfonyStyle $io,
|
|
|
|
OutputInterface $output,
|
2020-12-03 04:18:06 +00:00
|
|
|
Environment $environment,
|
2019-09-29 21:26:46 +00:00
|
|
|
ContainerInterface $di,
|
2019-09-29 23:48:24 +00:00
|
|
|
AzuraCastCentral $acCentral,
|
2019-09-10 23:10:57 +00:00
|
|
|
bool $update = false,
|
|
|
|
bool $loadFixtures = false
|
2020-10-14 22:19:31 +00:00
|
|
|
): int {
|
2019-08-21 22:33:47 +00:00
|
|
|
$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
|
|
|
|
2021-06-22 12:36:58 +00:00
|
|
|
$this->runCommand($output, 'azuracast:setup:initialize');
|
2018-05-17 07:01:43 +00:00
|
|
|
|
2020-12-03 04:18:06 +00:00
|
|
|
if ($loadFixtures || (!$environment->isProduction() && !$update)) {
|
2018-05-29 03:17:13 +00:00
|
|
|
$io->newLine();
|
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');
|
|
|
|
}
|
|
|
|
|
2019-09-28 02:07:33 +00:00
|
|
|
$io->newLine();
|
|
|
|
$io->section(__('Refreshing All Stations'));
|
2020-08-29 05:04:18 +00:00
|
|
|
|
2018-05-17 07:01:43 +00:00
|
|
|
$this->runCommand($output, 'azuracast:radio:restart');
|
|
|
|
|
2018-05-29 03:17:13 +00:00
|
|
|
$io->newLine();
|
2018-08-09 00:01:46 +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 {
|
2019-09-10 23:10:57 +00:00
|
|
|
$public_ip = $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!'),
|
|
|
|
__('Visit %s to complete setup.', 'http://' . $public_ip),
|
|
|
|
]
|
|
|
|
);
|
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
|
|
|
}
|