/etc/postgresql/' . $pgVersion . '/main/pg_hba.conf"' . "\n"; echo 'sudo systemctl restart postgresql' . "\n"; echo 'sudo -u postgres psql -c "CREATE DATABASE ' . $db_name . ';"' . "\n"; echo 'sudo -u postgres psql -c "CREATE USER ' . $db_user . ' WITH PASSWORD \'' . $password . '\';"' . "\n"; echo 'sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE ' . $db_name . ' TO ' . $db_user . ';"' . "\n"; echo 'sudo -u postgres psql -c "GRANT USAGE, CREATE ON SCHEMA public TO ' . $db_user . ';"' . "\n"; echo 'sudo systemctl restart postgresql' . "\n"; // If config already existed, don't overwrite it if (file_exists($configPath)) { echo "Config file already exists at {$configPath}, not overwriting.\n"; return; } // Ensure /opt/DragonCore exists if (!is_dir($dir)) { if (!mkdir($dir, 0755, true) && !is_dir($dir)) { fwrite(STDERR, "Failed to create directory: $dir\n"); return; } } // Create config.php with variables (no return) $config = <<