Skip to content

Commit

Permalink
Mysql 8.4 support and Stream log output (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedvaziry authored Dec 24, 2024
1 parent 924920e commit dfdd50b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
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

0 comments on commit dfdd50b

Please sign in to comment.