Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql 8.4 support and Stream log output #407

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/Enums/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ final class Database

const MYSQL80 = 'mysql80';

const MYSQL84 = 'mysql84';

const MARIADB103 = 'mariadb103';

const MARIADB104 = 'mariadb104';
Expand Down
16 changes: 11 additions & 5 deletions app/Helpers/SSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public function connect(bool $sftp = false): void
*/
public function exec(string $command, string $log = '', ?int $siteId = null, ?bool $stream = false, ?callable $streamCallback = null): string
{
if (! $this->log && $log) {
if (! $log) {
$log = 'run-command';
}

if (! $this->log) {
$this->log = ServerLog::make($this->server, $log);
if ($siteId) {
$this->log->forSite($siteId);
Expand All @@ -117,16 +121,18 @@ public function exec(string $command, string $log = '', ?int $siteId = null, ?bo
$this->connection->setTimeout(0);
if ($stream) {
$this->connection->exec($command, function ($output) use ($streamCallback) {
$this->log?->write($output);
$this->log->write($output);

return $streamCallback($output);
});

return '';
} else {
$output = $this->connection->exec($command);

$this->log?->write($output);
$output = '';
$this->connection->exec($command, function ($out) use (&$output) {
$this->log->write($out);
$output .= $out;
});

if ($this->connection->getExitStatus() !== 0 || Str::contains($output, 'VITO_SSH_ERROR')) {
throw new SSHCommandError(
Expand Down
27 changes: 27 additions & 0 deletions app/SSH/Services/Database/scripts/mysql/install-8.4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

sudo DEBIAN_FRONTEND=noninteractive apt-get update

sudo DEBIAN_FRONTEND=noninteractive apt-get install -y lsb-release

DEBIAN_FRONTEND=noninteractive wget https://dev.mysql.com/get/mysql-apt-config_0.8.32-1_all.deb

sudo DEBIAN_FRONTEND=noninteractive dpkg -i mysql-apt-config_0.8.32-1_all.deb

sudo DEBIAN_FRONTEND=noninteractive apt-get update

sudo DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server

sudo systemctl unmask mysql.service

sudo systemctl enable mysql

sudo systemctl start mysql

if ! sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;"; then
echo 'VITO_SSH_ERROR' && exit 1
fi

if ! sudo mysql -e "FLUSH PRIVILEGES"; then
echo 'VITO_SSH_ERROR' && exit 1
fi
7 changes: 7 additions & 0 deletions config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
\App\Enums\Database::NONE,
\App\Enums\Database::MYSQL57,
\App\Enums\Database::MYSQL80,
\App\Enums\Database::MYSQL84,
\App\Enums\Database::MARIADB103,
\App\Enums\Database::MARIADB104,
\App\Enums\Database::MARIADB106,
Expand All @@ -72,6 +73,7 @@
\App\Enums\Database::NONE => 'none',
\App\Enums\Database::MYSQL57 => 'mysql',
\App\Enums\Database::MYSQL80 => 'mysql',
\App\Enums\Database::MYSQL84 => 'mysql',
\App\Enums\Database::MARIADB103 => 'mariadb',
\App\Enums\Database::MARIADB104 => 'mariadb',
\App\Enums\Database::MARIADB106 => 'mariadb',
Expand All @@ -87,6 +89,7 @@
\App\Enums\Database::NONE => '',
\App\Enums\Database::MYSQL57 => '5.7',
\App\Enums\Database::MYSQL80 => '8.0',
\App\Enums\Database::MYSQL84 => '8.4',
\App\Enums\Database::MARIADB103 => '10.3',
\App\Enums\Database::MARIADB104 => '10.4',
\App\Enums\Database::MARIADB106 => '10.6',
Expand Down Expand Up @@ -201,6 +204,7 @@
'mysql' => [
'5.7',
'8.0',
'8.4',
],
'mariadb' => [
'10.3',
Expand Down Expand Up @@ -273,14 +277,17 @@
\App\Enums\OperatingSystem::UBUNTU20 => [
'5.7' => 'mysql',
'8.0' => 'mysql',
'8.4' => 'mysql',
],
\App\Enums\OperatingSystem::UBUNTU22 => [
'5.7' => 'mysql',
'8.0' => 'mysql',
'8.4' => 'mysql',
],
\App\Enums\OperatingSystem::UBUNTU24 => [
'5.7' => 'mysql',
'8.0' => 'mysql',
'8.4' => 'mysql',
],
],
'mariadb' => [
Expand Down
Loading