This commit is contained in:
Bozhidar 2024-04-23 17:08:06 +03:00
parent fec0b9d337
commit 59756d1a0a
2 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,37 @@
<?php
namespace App\Installers\Server\Applications;
class DovecotInstaller
{
public $rubyVersions = [];
public $logFilePath = '/var/log/phyre/dovecot-installer.log';
public function setLogFilePath($path)
{
$this->logFilePath = $path;
}
public function install()
{
$commands = [];
$commands[] = 'echo "Installing dovecot..."';
$commands[] = 'apt-get install -y dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd';
$shellFileContent = '';
foreach ($commands as $command) {
$shellFileContent .= $command . PHP_EOL;
}
$shellFileContent .= 'echo "All packages installed successfully!"' . PHP_EOL;
$shellFileContent .= 'echo "DONE!"' . PHP_EOL;
$shellFileContent .= 'rm -f /tmp/dovecot-installer.sh';
file_put_contents('/tmp/dovecot-installer.sh', $shellFileContent);
shell_exec('bash /tmp/dovecot-installer.sh >> ' . $this->logFilePath . ' &');
}
}

View file

@ -3,6 +3,7 @@
namespace App\Livewire;
use App\Filament\Enums\ServerApplicationType;
use App\Installers\Server\Applications\DovecotInstaller;
use App\Installers\Server\Applications\NodeJsInstaller;
use App\Installers\Server\Applications\PHPInstaller;
use App\Installers\Server\Applications\PythonInstaller;
@ -245,6 +246,21 @@ class Installer extends Page
}),
Wizard\Step::make('Step 3')
->description('Configure your email server')
->schema([
])->afterValidation(function () {
$dovecotInstaller = new DovecotInstaller();
$dovecotInstaller->setLogFilePath(storage_path($this->install_log_file_path));
$dovecotInstaller->install();
dd(storage_path($this->install_log_file_path));
}),
Wizard\Step::make('Step 4')
->description('Finish installation')
->schema([