From 59756d1a0a3bf705eeaaff712651614f225e7278 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Tue, 23 Apr 2024 17:08:06 +0300 Subject: [PATCH] update --- .../Server/Applications/DovecotInstaller.php | 37 +++++++++++++++++++ web/app/Livewire/Installer.php | 16 ++++++++ 2 files changed, 53 insertions(+) create mode 100644 web/app/Installers/Server/Applications/DovecotInstaller.php diff --git a/web/app/Installers/Server/Applications/DovecotInstaller.php b/web/app/Installers/Server/Applications/DovecotInstaller.php new file mode 100644 index 0000000..11facdb --- /dev/null +++ b/web/app/Installers/Server/Applications/DovecotInstaller.php @@ -0,0 +1,37 @@ +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 . ' &'); + + } +} diff --git a/web/app/Livewire/Installer.php b/web/app/Livewire/Installer.php index cc5bd85..0c2b353 100644 --- a/web/app/Livewire/Installer.php +++ b/web/app/Livewire/Installer.php @@ -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([