This commit is contained in:
Bozhidar 2024-09-19 18:35:26 +03:00
parent daf5998568
commit 058b71631e
4 changed files with 30 additions and 4 deletions

View file

@ -166,10 +166,24 @@ class GitRepository extends Model
file_put_contents($shellFile, $shellContent);
shell_exec('chmod +x ' . $shellFile);
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $shellFile);
shell_exec('su -m ' . $findHostingSubscription->system_username . ' -c "bash '.$shellFile.' >> ' . $shellLog . ' &"');
$gitExecutorTempPath = storage_path('app/git/tmp');
shell_exec('mkdir -p ' . $gitExecutorTempPath);
$gitExecutorShellFile = $gitExecutorTempPath . '/git-pull-' . $this->id . '.sh';
$gitExecutorShellFileLog = $gitExecutorTempPath . '/git-pull-' . $this->id . '.log';
$gitExecutorContent = view('actions.git.git-executor', [
'shellFile' => $shellFile,
'systemUsername' => $findHostingSubscription->system_username,
'selfFile' => $gitExecutorShellFile,
'afterCommand' => 'phyre-php /usr/local/phyre/web/artisan git-repository:mark-as-pulled '.$this->id,
])->render();
file_put_contents($gitExecutorShellFile, $gitExecutorContent);
shell_exec('chmod +x ' . $gitExecutorShellFile);
shell_exec('bash ' . $gitExecutorShellFile . ' >> ' . $gitExecutorShellFileLog . ' &');
}
@ -234,7 +248,7 @@ class GitRepository extends Model
shell_exec('chmod +x ' . $shellFile);
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $shellFile);
shell_exec('su -m ' . $findHostingSubscription->system_username . ' -c "bash '.$shellFile.' >> ' . $shellLog . ' &"');
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.' &"');
}

View file

@ -0,0 +1,10 @@
chmod +x {{$shellFile}}
chown {{$systemUsername}}:{{$systemUsername}} {{$shellFile}}
sudo -m {{$systemUsername}} -c "bash {{$shellFile}}"
@if ($afterCommand)
{{$afterCommand}}
@endif