Update GitRepository.php

This commit is contained in:
Bozhidar 2024-09-19 18:59:46 +03:00
parent d1feb95eef
commit e062e53e51

View file

@ -84,24 +84,26 @@ class GitRepository extends Model
if (!is_dir($sshPath)) { if (!is_dir($sshPath)) {
shell_exec('mkdir -p ' . $sshPath); shell_exec('mkdir -p ' . $sshPath);
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' -R ' . dirname($sshPath));
shell_exec('chmod 0700 ' . dirname($sshPath));
} }
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' -R ' . dirname($sshPath));
shell_exec('chmod 0700 ' . dirname($sshPath));
if (!file_exists($privateKeyFile)) { if (!file_exists($privateKeyFile)) {
file_put_contents($privateKeyFile, $gitSSHKey->private_key); file_put_contents($privateKeyFile, $gitSSHKey->private_key);
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $privateKeyFile);
shell_exec('chmod 0400 ' . $privateKeyFile);
} }
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $privateKeyFile);
shell_exec('chmod 0400 ' . $privateKeyFile);
if (!file_exists($publicKeyFile)) { if (!file_exists($publicKeyFile)) {
file_put_contents($publicKeyFile, $gitSSHKey->public_key); file_put_contents($publicKeyFile, $gitSSHKey->public_key);
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $publicKeyFile);
shell_exec('chmod 0400 ' . $publicKeyFile);
} }
shell_exec('chown '.$findHostingSubscription->system_username.':'.$findHostingSubscription->system_username.' ' . $publicKeyFile);
shell_exec('chmod 0400 ' . $publicKeyFile);
return [ return [
'privateKeyFile' => $privateKeyFile, 'privateKeyFile' => $privateKeyFile,
'publicKeyFile' => $publicKeyFile, 'publicKeyFile' => $publicKeyFile,