refactored zone deletion
This commit is contained in:
parent
f81b0451b4
commit
cd5361c65b
|
@ -98,16 +98,30 @@ class DomainController
|
|||
'name' => $domain->getName()
|
||||
];
|
||||
if (!empty($nameserver->getAaaa())) {
|
||||
$this->checkController->sendCommand(requestType: 'DELETE', serverName: $nameserver->getName(), versionIP: 6, apiKey: $nameserver->getApikey(), command: 'delete', serverType: 'nameserver', body: $body);
|
||||
$this->checkController->sendCommand(
|
||||
requestType: 'DELETE',
|
||||
serverName: $nameserver->getName(),
|
||||
versionIP: 6,
|
||||
apiKey: $nameserver->getApikey(),
|
||||
command: 'delete',
|
||||
serverType: 'nameserver',
|
||||
body: $body);
|
||||
} else {
|
||||
$this->checkController->sendCommand(requestType: 'DELETE', serverName: $nameserver->getName(), versionIP: 4, apiKey: $nameserver->getApikey(), command: 'delete', serverType: 'nameserver', body: $body);
|
||||
$this->checkController->sendCommand(
|
||||
requestType: 'DELETE',
|
||||
serverName: $nameserver->getName(),
|
||||
versionIP: 4,
|
||||
apiKey: $nameserver->getApikey(),
|
||||
command: 'delete',
|
||||
serverType: 'nameserver',
|
||||
body: $body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param \App\Entity\Domain $domain
|
||||
* @param Domain $domain
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -230,25 +244,34 @@ class DomainController
|
|||
$domains = $this->domainRepository->findAll();
|
||||
|
||||
foreach ($domains as $domain) {
|
||||
echo COLOR_YELLOW . str_pad(string: $domain->getName(), length: $maxNameLength + 1) . COLOR_DEFAULT;
|
||||
$idString = '(' . strval(value: $domain->getId()) . ') ';
|
||||
echo COLOR_YELLOW .
|
||||
str_pad(string: $domain->getName(), length: $maxNameLength + 1)
|
||||
. COLOR_DEFAULT
|
||||
. str_pad(string: $idString, length: 7, pad_type: STR_PAD_LEFT);
|
||||
|
||||
$hasError = false;
|
||||
if ($this->isMasterZone(domain: $domain)) {
|
||||
echo 'Master Zone lies on this panel.';
|
||||
} else {
|
||||
if (!str_contains(haystack: $localZones, needle: $domain->getName())) {
|
||||
echo COLOR_RED . 'is missing in ' . COLOR_YELLOW . $this->localZoneFile . COLOR_DEFAULT;
|
||||
$hasError = true;
|
||||
} else {
|
||||
echo $domain->getName() . ' exists in ' . COLOR_YELLOW . $this->localZoneFile;
|
||||
echo COLOR_GREEN . 'OK';
|
||||
}
|
||||
|
||||
$zoneFile = $this->localZonesDir . $domain->getName();
|
||||
|
||||
if (!file_exists(filename: $zoneFile)) {
|
||||
echo "Missing zone file for $zoneFile . Update zone to create it";
|
||||
}
|
||||
echo ' Missing zone file for ' . COLOR_YELLOW . $zoneFile . COLOR_DEFAULT;
|
||||
$hasError = true;
|
||||
}
|
||||
|
||||
|
||||
if ($hasError) {
|
||||
echo " Update zone (Domain) to create it.";
|
||||
}
|
||||
}
|
||||
echo COLOR_DEFAULT . PHP_EOL;
|
||||
}
|
||||
|
||||
|
@ -256,7 +279,7 @@ class DomainController
|
|||
|
||||
|
||||
/**
|
||||
* @param \App\Entity\Domain $domain
|
||||
* @param Domain $domain
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -267,11 +290,11 @@ class DomainController
|
|||
|
||||
// check if we're a master zone
|
||||
if ($this->isMasterZone(domain: $domain)) {
|
||||
echo 'We are zone master for ' . $domainName . PHP_EOL;
|
||||
exit(1);
|
||||
//echo 'We are zone master for ' . $domainName . PHP_EOL;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($zonefile = fopen(filename: $this->localZonesDir . $domainName, mode: 'w')) {
|
||||
if ($zoneFile = fopen(filename: $this->localZonesDir . $domainName, mode: 'w')) {
|
||||
$panelName = $domain->getPanel();
|
||||
if (!$panel = $this->panelRepository->findByName(name: $panelName)) {
|
||||
echo "Error: Panel $panelName doesn't exist." . PHP_EOL;
|
||||
|
@ -279,18 +302,18 @@ class DomainController
|
|||
}
|
||||
$a = $panel->getA();
|
||||
$aaaa = $panel->getAaaa();
|
||||
fputs(stream: $zonefile, data: 'zone "' . $domainName . '"' . ' IN {' . PHP_EOL);
|
||||
fputs(stream: $zonefile, data: "\ttype slave;" . PHP_EOL);
|
||||
fputs(stream: $zonefile, data: "\tfile \"" . $this->zoneCachePath . $domainName . '.db";' . PHP_EOL);
|
||||
fputs(stream: $zonefile, data: "\tmasters {" . PHP_EOL);
|
||||
fputs(stream: $zoneFile, data: 'zone "' . $domainName . '"' . ' IN {' . PHP_EOL);
|
||||
fputs(stream: $zoneFile, data: "\ttype slave;" . PHP_EOL);
|
||||
fputs(stream: $zoneFile, data: "\tfile \"" . $this->zoneCachePath . $domainName . '.db";' . PHP_EOL);
|
||||
fputs(stream: $zoneFile, data: "\tmasters {" . PHP_EOL);
|
||||
if (!empty($a)) {
|
||||
fputs(stream: $zonefile, data: "\t\t" . $a . ';' . PHP_EOL);
|
||||
fputs(stream: $zoneFile, data: "\t\t" . $a . ';' . PHP_EOL);
|
||||
}
|
||||
if (!empty($aaaa)) {
|
||||
fputs(stream: $zonefile, data: "\t\t" . $aaaa . ';' . PHP_EOL);
|
||||
fputs(stream: $zoneFile, data: "\t\t" . $aaaa . ';' . PHP_EOL);
|
||||
}
|
||||
fputs(stream: $zonefile, data: "\t};" . PHP_EOL);
|
||||
fputs(stream: $zonefile, data: "};" . PHP_EOL);
|
||||
fputs(stream: $zoneFile, data: "\t};" . PHP_EOL);
|
||||
fputs(stream: $zoneFile, data: "};" . PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue