From 2b422a542a51adfb7a691c74ae4e9efc33370902 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 May 2024 12:35:24 +0200 Subject: [PATCH] fix: empty db conf feat: add listen_addresses to postgresql if its missing in the custom conf --- app/Actions/Database/StartKeydb.php | 4 ++-- app/Actions/Database/StartMariadb.php | 4 ++-- app/Actions/Database/StartMongodb.php | 4 ++-- app/Actions/Database/StartMysql.php | 4 ++-- app/Actions/Database/StartPostgresql.php | 12 +++++++----- app/Actions/Database/StartRedis.php | 4 ++-- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/Actions/Database/StartKeydb.php b/app/Actions/Database/StartKeydb.php index 489c74053..52768b13e 100644 --- a/app/Actions/Database/StartKeydb.php +++ b/app/Actions/Database/StartKeydb.php @@ -96,7 +96,7 @@ public function handle(StandaloneKeydb $database) if (count($volume_names) > 0) { $docker_compose['volumes'] = $volume_names; } - if (!is_null($this->database->keydb_conf)) { + if (!is_null($this->database->keydb_conf) || !empty($this->database->keydb_conf)) { $docker_compose['services'][$container_name]['volumes'][] = [ 'type' => 'bind', 'source' => $this->configuration_dir . '/keydb.conf', @@ -162,7 +162,7 @@ private function generate_environment_variables() } private function add_custom_keydb() { - if (is_null($this->database->keydb_conf)) { + if (is_null($this->database->keydb_conf) || empty($this->database->keydb_conf)) { return; } $filename = 'keydb.conf'; diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.php index e02b28b2e..b6d6c5bb3 100644 --- a/app/Actions/Database/StartMariadb.php +++ b/app/Actions/Database/StartMariadb.php @@ -90,7 +90,7 @@ public function handle(StandaloneMariadb $database) if (count($volume_names) > 0) { $docker_compose['volumes'] = $volume_names; } - if (!is_null($this->database->mariadb_conf)) { + if (!is_null($this->database->mariadb_conf) || !empty($this->database->mariadb_conf)) { $docker_compose['services'][$container_name]['volumes'][] = [ 'type' => 'bind', 'source' => $this->configuration_dir . '/custom-config.cnf', @@ -165,7 +165,7 @@ private function generate_environment_variables() } private function add_custom_mysql() { - if (is_null($this->database->mariadb_conf)) { + if (is_null($this->database->mariadb_conf) || empty($this->database->mariadb_conf)) { return; } $filename = 'custom-config.cnf'; diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.php index 7bb6cbcd0..b624c2f50 100644 --- a/app/Actions/Database/StartMongodb.php +++ b/app/Actions/Database/StartMongodb.php @@ -97,7 +97,7 @@ public function handle(StandaloneMongodb $database) if (count($volume_names) > 0) { $docker_compose['volumes'] = $volume_names; } - if (!is_null($this->database->mongo_conf)) { + if (!is_null($this->database->mongo_conf) || !empty($this->database->mongo_conf)) { $docker_compose['services'][$container_name]['volumes'][] = [ 'type' => 'bind', 'source' => $this->configuration_dir . '/mongod.conf', @@ -178,7 +178,7 @@ private function generate_environment_variables() } private function add_custom_mongo_conf() { - if (is_null($this->database->mongo_conf)) { + if (is_null($this->database->mongo_conf) || empty($this->database->mongo_conf)) { return; } $filename = 'mongod.conf'; diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.php index b3f695d72..43b7292fb 100644 --- a/app/Actions/Database/StartMysql.php +++ b/app/Actions/Database/StartMysql.php @@ -90,7 +90,7 @@ public function handle(StandaloneMysql $database) if (count($volume_names) > 0) { $docker_compose['volumes'] = $volume_names; } - if (!is_null($this->database->mysql_conf)) { + if (!is_null($this->database->mysql_conf) || !empty($this->database->mysql_conf)) { $docker_compose['services'][$container_name]['volumes'][] = [ 'type' => 'bind', 'source' => $this->configuration_dir . '/custom-config.cnf', @@ -165,7 +165,7 @@ private function generate_environment_variables() } private function add_custom_mysql() { - if (is_null($this->database->mysql_conf)) { + if (is_null($this->database->mysql_conf) || empty($this->database->mysql_conf)) { return; } $filename = 'custom-config.cnf'; diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index f19a8b036..37eb157f8 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -78,7 +78,6 @@ public function handle(StandalonePostgresql $database) data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset); } if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) { - ray('Log Drain Enabled'); $docker_compose['services'][$container_name]['logging'] = [ 'driver' => 'fluentd', 'options' => [ @@ -107,7 +106,7 @@ public function handle(StandalonePostgresql $database) ]; } } - if (!is_null($this->database->postgres_conf)) { + if (!is_null($this->database->postgres_conf) && !empty($this->database->postgres_conf)) { $docker_compose['services'][$container_name]['volumes'][] = [ 'type' => 'bind', 'source' => $this->configuration_dir . '/custom-postgres.conf', @@ -165,8 +164,6 @@ private function generate_local_persistent_volumes_only_volume_names() private function generate_environment_variables() { $environment_variables = collect(); - ray('Generate Environment Variables')->green(); - ray($this->database->runtime_environment_variables)->green(); foreach ($this->database->runtime_environment_variables as $env) { $environment_variables->push("$env->key=$env->real_value"); } @@ -203,11 +200,16 @@ private function generate_init_scripts() } private function add_custom_conf() { - if (is_null($this->database->postgres_conf)) { + if (is_null($this->database->postgres_conf) || empty($this->database->postgres_conf)) { return; } $filename = 'custom-postgres.conf'; $content = $this->database->postgres_conf; + if (!str($content)->contains('listen_addresses')) { + $content .= "\nlisten_addresses = '*'"; + $this->database->postgres_conf = $content; + $this->database->save(); + } $content_base64 = base64_encode($content); $this->commands[] = "echo '{$content_base64}' | base64 -d | tee $this->configuration_dir/{$filename} > /dev/null"; } diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php index 01e9a9bef..35b9d5c8e 100644 --- a/app/Actions/Database/StartRedis.php +++ b/app/Actions/Database/StartRedis.php @@ -100,7 +100,7 @@ public function handle(StandaloneRedis $database) if (count($volume_names) > 0) { $docker_compose['volumes'] = $volume_names; } - if (!is_null($this->database->redis_conf)) { + if (!is_null($this->database->redis_conf) || !empty($this->database->redis_conf)) { $docker_compose['services'][$container_name]['volumes'][] = [ 'type' => 'bind', 'source' => $this->configuration_dir . '/redis.conf', @@ -166,7 +166,7 @@ private function generate_environment_variables() } private function add_custom_redis() { - if (is_null($this->database->redis_conf)) { + if (is_null($this->database->redis_conf) || empty($this->database->redis_conf)) { return; } $filename = 'redis.conf';