Skip to content

Commit 058b716

Browse files
update
1 parent daf5998 commit 058b716

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

web/app/Models/GitRepository.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,24 @@ public function pull()
166166

167167
file_put_contents($shellFile, $shellContent);
168168

169-
shell_exec('chmod +x ' . $shellFile);
170-
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $shellFile);
171169

172-
shell_exec('su -m ' . $findHostingSubscription->system_username . ' -c "bash '.$shellFile.' >> ' . $shellLog . ' &"');
170+
$gitExecutorTempPath = storage_path('app/git/tmp');
171+
shell_exec('mkdir -p ' . $gitExecutorTempPath);
172+
173+
$gitExecutorShellFile = $gitExecutorTempPath . '/git-pull-' . $this->id . '.sh';
174+
$gitExecutorShellFileLog = $gitExecutorTempPath . '/git-pull-' . $this->id . '.log';
175+
176+
$gitExecutorContent = view('actions.git.git-executor', [
177+
'shellFile' => $shellFile,
178+
'systemUsername' => $findHostingSubscription->system_username,
179+
'selfFile' => $gitExecutorShellFile,
180+
'afterCommand' => 'phyre-php /usr/local/phyre/web/artisan git-repository:mark-as-pulled '.$this->id,
181+
])->render();
182+
183+
file_put_contents($gitExecutorShellFile, $gitExecutorContent);
184+
185+
shell_exec('chmod +x ' . $gitExecutorShellFile);
186+
shell_exec('bash ' . $gitExecutorShellFile . ' >> ' . $gitExecutorShellFileLog . ' &');
173187

174188
}
175189

@@ -234,7 +248,7 @@ public function clone()
234248
shell_exec('chmod +x ' . $shellFile);
235249
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $shellFile);
236250

237-
shell_exec('su -m ' . $findHostingSubscription->system_username . ' -c "bash '.$shellFile.' >> ' . $shellLog . ' &"');
251+
shell_exec('su -m ' . $findHostingSubscription->system_username . ' -c "bash '.$shellFile.' >> ' . $shellLog . ' && phyre-php /usr/local/phyre/web/artisan git-repository:mark-as-cloned '.$this->id.' &"');
238252

239253
}
240254

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
chmod +x {{$shellFile}}
2+
chown {{$systemUsername}}:{{$systemUsername}} {{$shellFile}}
3+
4+
sudo -m {{$systemUsername}} -c "bash {{$shellFile}}"
5+
6+
@if ($afterCommand)
7+
8+
{{$afterCommand}}
9+
10+
@endif

web/resources/views/actions/git/pull-repo.blade.php renamed to web/resources/views/actions/git/pull-repo-user.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717
@endif
1818

1919
rm -rf {{$selfFile}}
20+
21+
curl

0 commit comments

Comments
 (0)