From 139a20a58415ebc5fcc92fee99b5c900903a56b4 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Wed, 11 Sep 2024 16:56:32 +0300 Subject: [PATCH] update --- .../Filament/Resources/CustomerResource.php | 2 +- web/app/Models/GitRepository.php | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/web/app/Filament/Resources/CustomerResource.php b/web/app/Filament/Resources/CustomerResource.php index d0bd8fb..7ec329f 100644 --- a/web/app/Filament/Resources/CustomerResource.php +++ b/web/app/Filament/Resources/CustomerResource.php @@ -136,7 +136,7 @@ class CustomerResource extends Resource Impersonate::make('impersonate') ->guard('web_customer') - ->redirectTo(route('filament.customer::admin.pages.dashboard')), + ->redirectTo(route('filament.customer::admin.resources.domains.index')), Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make(), diff --git a/web/app/Models/GitRepository.php b/web/app/Models/GitRepository.php index 8446547..c38be6c 100644 --- a/web/app/Models/GitRepository.php +++ b/web/app/Models/GitRepository.php @@ -124,29 +124,33 @@ class GitRepository extends Model $shellCommand = []; $shellCommand[] = 'echo "Cloning started at $(date)"'; - $shellCommand[] = 'export HOME=/home/'.$findHostingSubscription->system_username; -// $shellCommand[] = 'cd '.$findDomain->domain_root; + + $exportHomeCommand = 'export HOME=/home/'.$findHostingSubscription->system_username; + $shellCommand[] = 'su -m '.$findHostingSubscription->system_username.' -c "'.$exportHomeCommand.'"'; + if ($gitSSHKey) { $cloneUrl = 'git@'.$gitSSHUrl['provider'].':'.$gitSSHUrl['owner'].'/'.$gitSSHUrl['name'].'.git'; - $shellCommand[] = 'git -c core.sshCommand="ssh -i '.$privateKeyFile .'" clone '.$cloneUrl.' '.$projectDir . ' 2>&1'; + $gitCloneCommand = 'git -c core.sshCommand="ssh -i '.$privateKeyFile .'" clone '.$cloneUrl.' '.$projectDir . ' 2>&1'; } else { $gitCloneCommand = 'git clone '.$this->url.' '.$projectDir . ' 2>&1'; - $shellCommand[] = 'su -m '.$findHostingSubscription->system_username.' -c "'.$gitCloneCommand.'"'; } + $shellCommand[] = 'su -m '.$findHostingSubscription->system_username.' -c "'.$gitCloneCommand.'"'; + $shellCommand[] = 'phyre-php /usr/local/phyre/web/artisan git-repository:mark-as-cloned '.$this->id; + $shellFile = '/tmp/git-clone-' . $this->id . '.sh'; + $shellLog = '/tmp/git-clone-' . $this->id . '.log'; + + $shellCommand[] = 'rm -rf ' . $shellFile; + $shellContent = ''; foreach ($shellCommand as $command) { $shellContent .= $command . "\n"; } - $shellFile = '/tmp/git-clone-' . $this->id . '.sh'; - $shellLog = '/tmp/git-clone-' . $this->id . '.log'; - file_put_contents($shellFile, $shellContent); - file_put_contents($shellLog, 'Clone started at ' . date('Y-m-d H:i:s') . "\n"); shell_exec('chmod +x ' . $shellFile); shell_exec('bash '.$shellFile.' >> ' . $shellLog . ' &');