Compare commits

..

No commits in common. "866e1dcb9bd93ddc520424a5549ae6081fef5a3f" and "ea6e99e4be35f9c7fe55036f91fc163a7e7d1fcb" have entirely different histories.

7 changed files with 32 additions and 34 deletions

View File

@ -43,12 +43,15 @@ The CLI is used to perform configuration and some checks:
![OpenAPI](https://bindapi.24unix.net/assets/bindAPI_api1.png) ![OpenAPI](https://bindapi.24unix.net/assets/bindAPI_api1.png)
The API is a RESTful API, there is a self explaining Swagger/OpenAPI available. The APi is a RESTful API, there is a self explaining Swagger/OpenAPI available.
<a name="installation"></a> <a name="installation"></a>
# 3. Installation # 3. Installation
You can install the bindAPI on either a standalone server or an existing KeyHelp Panel. However, slave zones are only managed for masters which lie on Keyhelp panels. You can install the bindAPi on either a standalone server or an existing KeyHelp Panel.
However, slave zones are only managed for masters which lie on Keyhelp panels.
## 3.1. Installation on a KeyHelp panel ## 3.1. Installation on a KeyHelp panel
@ -112,13 +115,7 @@ Remove the defaults files:
`rm *` `rm *`
Next, we'll need to fetch the bindAPI. As of now, the latest release is 1.0.1: Next, we'll need to fetch the bindAPI (currently it has no release tag, that will change later)
https://git.24unix.net/tracer/bindAPI/archive/1.0.1.tar.gz
I'd suggest checking here for the latest version:
https://git.24unix.net/tracer/bindAPI/releases
Or just use git to checkout the latest update:
``` ```
git clone https://git.24unix.net/tracer/bindAPI.git git clone https://git.24unix.net/tracer/bindAPI.git
@ -135,11 +132,11 @@ We need to pull the dependencies for composer:
`/usr/bin/keyhelp-php81 /usr/local/bin/composer update` `/usr/bin/keyhelp-php81 /usr/local/bin/composer update`
You might notice a quite strange command. We need to call php with full path, and explicitly the 8.1 version. KeyHelp You might notice a quite strange command.
relies on the default PHP installation, so the php binary will always point to 7.4 when you're on Debian Bullseye. We need to call php with full path, and explicitly the 8.1 version.
KeyHelp relies on the default PHP installation, so the php binary will always point to 7.4 when your on Debian Bullseye.
So, in bin/console the path to /usr/bin/keyhelp-php81 is hardcoded after the shebang, a step we have to remind if we So, in bin/console the path to /usr/bin/keyhelp-php81 is hardcoded after the shebang, a step we have to remind if we install the standalone version.
install the standalone version.
Now make the CLI executable: Now make the CLI executable:
@ -154,19 +151,19 @@ Should I create a new config based on config.json.sample? (y/N): n
You first have to setup the bindAPI. Bye. You first have to setup the bindAPI. Bye.
``` ```
So now we can head back to our panel and set the Document root to /home/users/tfunix/ns1.24unix.net/bindAPI/public. So now we can head back to our panel and set the Document root to
/home/users/tfunix/ns1.24unix.net/bindAPI/public.
Additionally, we have to change the open_basedir directive: Additionally, we have to change the open_basedir directive:
##DOCROOT##/www:##DOCROOT##/files:##DOCROOT##/tmp:/etc/bind:/etc/bind/local.zones
`##DOCROOT##/www:##DOCROOT##/files:##DOCROOT##/tmp:/etc/bind:/etc/bind/local.zones` TODO: Screenshot
![Php Interpreter](https://bindapi.24unix.net/assets/bindAPI_phpsetting.png)
and remove exec from disabled functions. and remove exec from disabled functions.
OK, we are finished with the installation and head over to the [4. Configuration](#4-configuration). OK, we are finished with the installation and head over to the [4. Configuration](#4-configuration).
## 3.2. Installation on a plain Debian Bullseye ## 3.2. Installation on a plain debian Bullseye
So, at first you should read and understand all steps in 3.1, as we will learn only the differences. So, at first you should read and understand all steps in 3.1, as we will learn only the differences.

View File

@ -477,6 +477,7 @@ class BindAPI
break; break;
default: default:
echo 'Server error' . PHP_EOL; echo 'Server error' . PHP_EOL;
print_r(value: $result);
exit(1); exit(1);
} }
} }
@ -777,7 +778,7 @@ class BindAPI
} }
if ($this->config['verbose']) { if ($this->config['verbose']) {
echo COLOR_YELLOW . str_pad(string: $server->getName(), length: $maxName); print(COLOR_YELLOW . str_pad(string: $server->getName(), length: $maxName));
} }
$a = $server->getA() ?? ''; $a = $server->getA() ?? '';
@ -1315,7 +1316,7 @@ class BindAPI
{ {
$nameservers = $this->nameserverRepository->findAll(); $nameservers = $this->nameserverRepository->findAll();
echo COLOR_DEFAULT . 'You need to add these lines to ' . COLOR_YELLOW . '/etc/bind/local.bindapi.options' . COLOR_DEFAULT . ' on every panel and make sure' . PHP_EOL; echo COLOR_DEFAULT . 'You need to add these lines to ' . COLOR_YELLOW . '/etc/bind/local.bindapi.options' . COLOR_DEFAULT . ' and make sure' . PHP_EOL;
echo 'that ' . COLOR_YELLOW . 'include "/etc/bind/local.bindapi.options";' . COLOR_DEFAULT . ' exists in ' . COLOR_YELLOW . '/etc/bind/named.conf.options' . COLOR_DEFAULT . '.' . PHP_EOL; echo 'that ' . COLOR_YELLOW . 'include "/etc/bind/local.bindapi.options";' . COLOR_DEFAULT . ' exists in ' . COLOR_YELLOW . '/etc/bind/named.conf.options' . COLOR_DEFAULT . '.' . PHP_EOL;
$ip = []; $ip = [];
foreach ($nameservers as $nameserver) { foreach ($nameservers as $nameserver) {
@ -1335,8 +1336,6 @@ class BindAPI
echo "\t$currentIp;" . PHP_EOL; echo "\t$currentIp;" . PHP_EOL;
echo '};' . PHP_EOL; echo '};' . PHP_EOL;
echo PHP_EOL . 'After the modification feel free to run ' . COLOR_YELLOW . 'named-checkconf' . COLOR_DEFAULT . ' to ensure there were no errors.' . PHP_EOL; echo PHP_EOL . 'After the modification feel free to run ' . COLOR_YELLOW . 'named-checkconf' . COLOR_DEFAULT . ' to ensure there were no errors.' . PHP_EOL;
echo PHP_EOL . 'Run ' . COLOR_YELLOW . 'rndc reload' . COLOR_DEFAULT . ' to activate the changes' . PHP_EOL;
} }

View File

@ -108,7 +108,7 @@ class DomainController
echo 'Checking permission:' . PHP_EOL . PHP_EOL; echo 'Checking permission:' . PHP_EOL . PHP_EOL;
$uid = posix_geteuid(); $uid = posix_geteuid();
echo "UID:\t" . COLOR_YELLOW . $uid . PHP_EOL; print("UID:\t" . COLOR_YELLOW . $uid . PHP_EOL);
$pwuid = posix_getpwuid(user_id: $uid); $pwuid = posix_getpwuid(user_id: $uid);
$name = $pwuid['name']; $name = $pwuid['name'];
@ -122,26 +122,26 @@ class DomainController
} }
echo COLOR_DEFAULT . 'Checking ' . COLOR_YELLOW . $this->localZoneFile . PHP_EOL; echo 'Checking file: ' . $this->localZoneFile . PHP_EOL;
$localZoneFilePermissions = fileperms(filename: $this->localZoneFile); $localZoneFilePermissions = fileperms(filename: $this->localZoneFile);
if ($localZoneFilePermissions & 0x0010) { if ($localZoneFilePermissions & 0x0010) {
echo COLOR_DEFAULT . "\t✅ Group has write access." . PHP_EOL; echo "\t✅ Group has write access." . PHP_EOL;
} else { } else {
echo COLOR_RED . "\t❌Group needs write permission!" . PHP_EOL; echo "\t❌Group needs write permission!" . PHP_EOL;
} }
echo 'Checking ' . COLOR_YELLOW . $this->namedConfLocalFile . PHP_EOL; echo "Checking $this->namedConfLocalFile" . PHP_EOL;
if ($namedConfLocal = file_get_contents(filename: $this->namedConfLocalFile)) { if ($namedConfLocal = file_get_contents(filename: $this->namedConfLocalFile)) {
if (!str_contains(haystack: $namedConfLocal, needle: $this->localZoneFile)) { if (!str_contains(haystack: $namedConfLocal, needle: $this->localZoneFile)) {
echo "\t$this->localZoneFile" . COLOR_RED . ' needs to be included in ' . COLOR_YELLOW . $this->namedConfLocalFile . PHP_EOL; echo "\t$this->localZoneFile needs to be included in $this->namedConfLocalFile . " . PHP_EOL;
} else { } else {
echo "\t$this->localZoneFile" . COLOR_DEFAULT . ' is included in ' . COLOR_YELLOW . $this->namedConfLocalFile . PHP_EOL; echo "\t$this->localZoneFile is included in $this->namedConfLocalFile" . PHP_EOL;
} }
} else { } else {
echo "\t❌ No access to '$this->namedConfLocalFile' . Please check permissions" . PHP_EOL; echo "\t❌ No access to '$this->namedConfLocalFile' . Please check permissions" . PHP_EOL;
} }
echo COLOR_DEFAULT . 'Checking directory: ' . COLOR_YELLOW . $this->localZonesDir . PHP_EOL; echo 'Checking directory: ' . $this->localZonesDir . PHP_EOL;
$localZoneDirPermissions = fileperms(filename: $this->localZonesDir); $localZoneDirPermissions = fileperms(filename: $this->localZonesDir);
if ($localZoneDirPermissions & 0x0010) { if ($localZoneDirPermissions & 0x0010) {
echo "\t✅ Group has write access." . PHP_EOL; echo "\t✅ Group has write access." . PHP_EOL;

View File

@ -161,7 +161,7 @@ class ApikeyRepository
return $statement->rowCount(); return $statement->rowCount();
} catch (PDOException $e) { } catch (PDOException $e) {
echo $e->getMessage(); print($e->getMessage());
return false; return false;
} }
} }

View File

@ -41,6 +41,8 @@ class DomainRepository
$statement = $this->databaseConnection->getConnection()->prepare(query: $sql); $statement = $this->databaseConnection->getConnection()->prepare(query: $sql);
$statement->execute(); $statement->execute();
while ($result = $statement->fetch(mode: PDO::FETCH_ASSOC)) { while ($result = $statement->fetch(mode: PDO::FETCH_ASSOC)) {
//print_r($result);
//die();
$domain = new Domain(name: $result['name'], panel: $result['panel'], id: $result['id']); $domain = new Domain(name: $result['name'], panel: $result['panel'], id: $result['id']);
$domains[] = $domain; $domains[] = $domain;
} }
@ -185,7 +187,7 @@ class DomainRepository
return $statement->rowCount(); return $statement->rowCount();
} catch (PDOException $e) { } catch (PDOException $e) {
echo $e->getMessage(); print($e->getMessage());
return false; return false;
} }
} }

View File

@ -178,7 +178,7 @@ class NameserverRepository
return $statement->rowCount(); return $statement->rowCount();
} catch (PDOException $e) { } catch (PDOException $e) {
echo $e->getMessage(); print($e->getMessage());
return false; return false;
} }
} }

View File

@ -166,7 +166,7 @@ class PanelRepository
return $statement->rowCount(); return $statement->rowCount();
} catch (PDOException $e) { } catch (PDOException $e) {
echo $e->getMessage(); print($e->getMessage());
return false; return false;
} }
} }