Skip to content

Commit 825fd7d

Browse files
update
1 parent 1f29b62 commit 825fd7d

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

web/app/Models/GitRepository.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,11 @@ public function clone()
207207

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

210-
$shellFile = '/tmp/git-clone-' . $this->id . '.sh';
211-
$shellLog = '/tmp/git-clone-' . $this->id . '.log';
210+
$shellFile = $findDomain->domain_root . '/git/tmp/git-clone-' . $this->id . '.sh';
211+
$shellLog = $findDomain->domain_root . '/git/tmp/git-clone-' . $this->id . '.log';
212+
213+
shell_exec('mkdir -p ' . dirname($shellFile));
214+
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' -R ' . dirname(dirname($shellFile)));
212215

213216
$shellContent = view('actions.git.clone-repo', [
214217
'gitProvider' => $gitSSHUrl['provider'],
@@ -217,12 +220,15 @@ public function clone()
217220
'cloneUrl' => $cloneUrl,
218221
'projectDir' => $projectDir,
219222
'privateKeyFile' => $privateKeyFile,
223+
'selfFile' => $shellFile,
220224
])->render();
221225

222226
file_put_contents($shellFile, $shellContent);
223227

224228
shell_exec('chmod +x ' . $shellFile);
225-
shell_exec('bash '.$shellFile.' >> ' . $shellLog . ' &');
229+
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $shellFile);
230+
231+
shell_exec('su -m ' . $findHostingSubscription->system_username . ' -c "bash '.$shellFile.' >> ' . $shellLog . ' &"');
226232

227233
}
228234

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
echo "Cloning started at {{ date('Y-m-d H:i:s') }}"
22

3-
su -m {{$systemUsername}} -c "export HOME=/home/{{$systemUsername}}"
43

54
@if($privateKeyFile)
65

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

11-
su -m {{$systemUsername}} -c 'git -c core.sshCommand="ssh -i {{$privateKeyFile}}" clone {{$cloneUrl}} {{$projectDir}}'
10+
git -c core.sshCommand="ssh -i {{$privateKeyFile}}" clone {{$cloneUrl}} {{$projectDir}}
1211

1312
@else
1413

15-
su -m {{$systemUsername}} -c 'git clone {{$cloneUrl}} {{$projectDir}}'
14+
git clone {{$cloneUrl}} {{$projectDir}}
1615

1716
@endif
1817

19-
phyre-php /usr/local/phyre/web/artisan git-repository:mark-as-cloned {{$gitRepositoryId}}
20-
21-
rm -rf /tmp/git-clone-{{$gitRepositoryId}}.sh
18+
rm -rf {{$selfFile}}

0 commit comments

Comments
 (0)