Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Sep 19, 2024
1 parent 3839d5c commit daf5998
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public static function table(Table $table): Table
return $table
->columns([

Tables\Columns\TextColumn::make('id')
->label('#')
->sortable(),

Tables\Columns\TextColumn::make('domain.domain'),

// Tables\Columns\TextColumn::make('name')
Expand Down
12 changes: 9 additions & 3 deletions web/app/Models/GitRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,11 @@ public function pull()

$cloneUrl = 'git@'.$gitSSHUrl['provider'].':'.$gitSSHUrl['owner'].'/'.$gitSSHUrl['name'].'.git';

$shellFile = '/tmp/git-pull-' . $this->id . '.sh';
$shellLog = '/tmp/git-pull-' . $this->id . '.log';
$shellFile = $findDomain->domain_root . '/git/tmp/git-pull-' . $this->id . '.sh';
$shellLog = $findDomain->domain_root . '/git/tmp/git-pull-' . $this->id . '.log';

shell_exec('mkdir -p ' . dirname($shellFile));
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' -R ' . dirname(dirname($shellFile)));

$shellContent = view('actions.git.pull-repo', [
'gitProvider' => $gitSSHUrl['provider'],
Expand All @@ -158,12 +161,15 @@ public function pull()
'cloneUrl' => $cloneUrl,
'projectDir' => $projectDir,
'privateKeyFile' => $privateKeyFile,
'selfFile' => $shellFile,
])->render();

file_put_contents($shellFile, $shellContent);

shell_exec('chmod +x ' . $shellFile);
shell_exec('bash '.$shellFile.' >> ' . $shellLog . ' &');
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $shellFile);

shell_exec('su -m ' . $findHostingSubscription->system_username . ' -c "bash '.$shellFile.' >> ' . $shellLog . ' &"');

}

Expand Down
11 changes: 4 additions & 7 deletions web/resources/views/actions/git/pull-repo.blade.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
echo "Pull started at {{ date('Y-m-d H:i:s') }}"

su -m {{$systemUsername}} -c "export HOME=/home/{{$systemUsername}}"
cd {{$projectDir}}

@if($privateKeyFile)

ssh-keyscan {{$gitProvider}} >> /home/{{$systemUsername}}/.ssh/known_hosts
chmod 0600 /home/{{$systemUsername}}/.ssh/known_hosts
chown {{$systemUsername}}:{{$systemUsername}} /home/{{$systemUsername}}/.ssh/known_hosts

su -m {{$systemUsername}} -c 'cd {{$projectDir}} && git -c core.sshCommand="ssh -i {{$privateKeyFile}}" pull'
git -c core.sshCommand="ssh -i {{$privateKeyFile}}" pull

@else

su -m {{$systemUsername}} -c 'cd {{$projectDir}} && git pull'
git pull

@endif

phyre-php /usr/local/phyre/web/artisan git-repository:mark-as-pulled {{$gitRepositoryId}}


rm -rf /tmp/git-pull-{{$gitRepositoryId}}.sh
rm -rf {{$selfFile}}

0 comments on commit daf5998

Please sign in to comment.