2018-05-17 07:01:43 +00:00
|
|
|
<?php
|
|
|
|
namespace AzuraCast\Console\Command;
|
|
|
|
|
|
|
|
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
|
|
|
|
use Doctrine\Common\DataFixtures\Loader;
|
|
|
|
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
|
|
|
|
use Doctrine\ORM\EntityManager;
|
|
|
|
use Symfony\Component\Console\Input\ArrayInput;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
|
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
|
|
|
|
|
|
|
class Setup extends \App\Console\Command\CommandAbstract
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
protected function configure()
|
|
|
|
{
|
|
|
|
$this->setName('azuracast:setup')
|
|
|
|
->setDescription('Run all general AzuraCast setup steps.')
|
2018-05-29 04:16:49 +00:00
|
|
|
->addOption('update', null, InputOption::VALUE_NONE, 'Only update the existing installation.')
|
|
|
|
->addOption('load-fixtures', null, InputOption::VALUE_NONE, 'Load predefined fixtures (for development purposes).');
|
2018-05-17 07:01:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
|
|
|
$update_only = (bool)$input->getOption('update');
|
2018-05-29 04:16:49 +00:00
|
|
|
$load_fixtures = (bool)$input->getOption('load-fixtures');
|
2018-05-17 07:01:43 +00:00
|
|
|
|
2018-05-29 03:17:13 +00:00
|
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
$io->title('AzuraCast Setup');
|
|
|
|
$io->writeln('Welcome to AzuraCast. Please wait while some key dependencies of AzuraCast are set up...');
|
|
|
|
|
|
|
|
$io->listing([
|
|
|
|
'Environment: '.ucfirst(APP_APPLICATION_ENV),
|
|
|
|
'Installation Method: '.((APP_INSIDE_DOCKER) ? 'Docker' : 'Traditional'),
|
|
|
|
]);
|
|
|
|
|
|
|
|
if ($update_only) {
|
|
|
|
$io->note('Running in update mode.');
|
2018-05-29 03:39:19 +00:00
|
|
|
|
|
|
|
if (!APP_INSIDE_DOCKER) {
|
|
|
|
$io->section('Migrating Legacy Configuration');
|
|
|
|
$this->runCommand($output, 'azuracast:config:migrate');
|
|
|
|
$io->newLine();
|
|
|
|
}
|
2018-05-29 03:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$io->section('Setting Up InfluxDB');
|
|
|
|
|
2018-05-29 03:39:19 +00:00
|
|
|
$this->runCommand($output, 'azuracast:setup:influx');
|
2018-05-17 07:01:43 +00:00
|
|
|
$this->runCommand($output, 'cache:clear');
|
2018-05-29 03:17:13 +00:00
|
|
|
|
|
|
|
$io->newLine();
|
|
|
|
$io->section('Running Database Migrations');
|
|
|
|
|
2018-05-17 07:01:43 +00:00
|
|
|
$this->runCommand($output, 'migrations:migrate', [
|
|
|
|
'--allow-no-migration' => true,
|
|
|
|
]);
|
|
|
|
|
2018-05-29 03:17:13 +00:00
|
|
|
$io->newLine();
|
|
|
|
$io->section('Generating Database Proxy Classes');
|
|
|
|
|
2018-05-17 07:01:43 +00:00
|
|
|
$this->runCommand($output, 'orm:generate-proxies');
|
|
|
|
|
2018-05-29 04:16:49 +00:00
|
|
|
if ($load_fixtures || (!APP_IN_PRODUCTION && !$update_only)) {
|
2018-05-29 03:17:13 +00:00
|
|
|
$io->newLine();
|
|
|
|
$io->section('Installing Data Fixtures');
|
|
|
|
|
2018-05-17 07:01:43 +00:00
|
|
|
$this->runCommand($output, 'azuracast:setup:fixtures');
|
|
|
|
}
|
|
|
|
|
2018-05-29 03:17:13 +00:00
|
|
|
$io->newLine();
|
|
|
|
$io->section('Refreshing All Stations');
|
|
|
|
|
2018-05-17 07:01:43 +00:00
|
|
|
$this->runCommand($output, 'cache:clear');
|
|
|
|
$this->runCommand($output, 'azuracast:radio:restart');
|
|
|
|
|
2018-07-31 04:07:19 +00:00
|
|
|
$local_ip = getHostByName(getHostName()) ?? 'localhost';
|
|
|
|
|
2018-05-29 03:17:13 +00:00
|
|
|
$io->newLine();
|
2018-07-31 04:07:19 +00:00
|
|
|
$io->success([
|
|
|
|
'AzuraCast installation complete!',
|
|
|
|
'Visit http://'.$local_ip.' to complete setup.',
|
|
|
|
]);
|
2018-05-17 07:01:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function runCommand(OutputInterface $output, $command_name, $command_args = [])
|
|
|
|
{
|
|
|
|
$command = $this->getApplication()->find($command_name);
|
|
|
|
|
|
|
|
$input = new ArrayInput(['command' => $command_name] + $command_args);
|
|
|
|
$input->setInteractive(false);
|
|
|
|
|
|
|
|
$command->run($input, $output);
|
|
|
|
}
|
2018-07-31 04:07:19 +00:00
|
|
|
}
|