misc(installer): Some minor improvements (#1824)

This commit is contained in:
Roman Kelesidis 2025-02-22 14:46:35 +07:00 committed by GitHub
commit f3714f02f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -288,7 +288,7 @@ if (is_file(BB_ROOT . '.env.example') && !is_file(BB_ROOT . '.env')) {
}
// Editing ENV file
$DB_HOST = '';
$DB_HOST = 'localhost';
$DB_PORT = 3306;
$DB_DATABASE = '';
$DB_USERNAME = '';
@ -309,20 +309,17 @@ if (is_file(BB_ROOT . '.env')) {
if (trim($line) !== '' && !str_starts_with($line, '#')) {
$parts = explode('=', $line, 2);
$key = trim($parts[0]);
$value = (isset($parts[1]) && $key !== 'DB_PASSWORD') ? trim($parts[1]) : '';
// Database default values
if (in_array($key, ['DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD'])) {
$$key = $value;
}
$value = (!empty($parts[1]) && $key !== 'DB_PASSWORD') ? trim($parts[1]) : '';
out("\nCurrent value of $key: $value", 'debug');
echo "Enter a new value for $key (or leave empty to not change): ";
$newValue = readline();
$newValue = trim(readline());
if (!empty($newValue) || $key === 'DB_PASSWORD') {
if (!empty($newValue)) {
$line = "$key=$newValue";
$$key = $newValue;
} else {
$$key = $value;
}
}