1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\Skylab\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
6
|
|
|
|
7
|
|
|
class NameserverCheckCommand extends AbstractCommand |
8
|
|
|
{ |
9
|
|
|
protected function configure() |
10
|
|
|
{ |
11
|
|
|
$this |
12
|
|
|
->addDefaults() |
13
|
|
|
->setName('nameservercheck') |
14
|
|
|
->setDescription('Get the current authoritative nameservers for all domains configured for this project') |
15
|
|
|
->addArgument('project', InputArgument::OPTIONAL, 'The name of the Skylab project') |
16
|
|
|
->setHelp(<<<EOT |
17
|
|
|
The <info>nameservercheck</info> command get the current authoritative nameservers for all domains configured for this project. |
18
|
|
|
|
19
|
|
|
<info>php skylab.phar nameservercheck testproject</info> |
20
|
|
|
EOT |
21
|
|
|
); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @throws \RuntimeException |
26
|
|
|
*/ |
27
|
|
|
protected function doExecute() |
28
|
|
|
{ |
29
|
|
|
$projectname = $this->dialogProvider->askFor("Please enter the name of the project", 'project'); |
30
|
|
|
if ($this->fileSystemProvider->projectExists($projectname)) { |
31
|
|
|
$project = $this->projectConfigProvider->loadProjectConfig($projectname); |
32
|
|
|
$domains = array_merge(array($project['url']), $project['aliases']); |
33
|
|
|
$results = array(); |
34
|
|
|
foreach ($domains as $domain) { |
35
|
|
|
$split = array_reverse(explode('.', $domain)); |
36
|
|
|
$rootDomain = $split[1] . '.' . $split[0]; |
37
|
|
|
$nameservers = $this->processProvider->executeCommand('dig +short NS ' . $rootDomain); |
38
|
|
|
$results[] = array($domain, trim($nameservers)."\n"); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$this->dialogProvider->renderTable(array('Project', 'Nameservers'), $results); |
42
|
|
|
} else { |
43
|
|
|
$this->dialogProvider->logError('Project not found'); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|