mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-06-26 09:10:05 +02:00
[Nostromo] If user is not defined, get current running user
This commit is contained in:
parent
886b7edcf6
commit
92d63f3814
|
@ -446,4 +446,15 @@ class Runtime
|
||||||
{
|
{
|
||||||
return tempnam(sys_get_temp_dir(), 'mage');
|
return tempnam(sys_get_temp_dir(), 'mage');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current user
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCurrentUser()
|
||||||
|
{
|
||||||
|
$userData = posix_getpwuid(posix_geteuid());
|
||||||
|
return $userData['name'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class RsyncTask extends AbstractTask
|
||||||
{
|
{
|
||||||
$flags = $this->runtime->getConfigOptions('rsync', '-avz');
|
$flags = $this->runtime->getConfigOptions('rsync', '-avz');
|
||||||
$sshConfig = $this->runtime->getSSHConfig();
|
$sshConfig = $this->runtime->getSSHConfig();
|
||||||
$user = $this->runtime->getEnvironmentConfig('user');
|
$user = $this->runtime->getEnvironmentConfig('user', $this->runtime->getCurrentUser());
|
||||||
$host = $this->runtime->getWorkingHost();
|
$host = $this->runtime->getWorkingHost();
|
||||||
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
||||||
$targetDir = rtrim($hostPath, '/');
|
$targetDir = rtrim($hostPath, '/');
|
||||||
|
|
|
@ -37,7 +37,7 @@ class CopyTask extends AbstractTask
|
||||||
throw new DeploymentException('This task is only available with releases enabled', 40);
|
throw new DeploymentException('This task is only available with releases enabled', 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->runtime->getEnvironmentConfig('user');
|
$user = $this->runtime->getEnvironmentConfig('user', $this->runtime->getCurrentUser());
|
||||||
$host = $this->runtime->getWorkingHost();
|
$host = $this->runtime->getWorkingHost();
|
||||||
$sshConfig = $sshConfig = $this->runtime->getSSHConfig();
|
$sshConfig = $sshConfig = $this->runtime->getSSHConfig();
|
||||||
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
$hostPath = rtrim($this->runtime->getEnvironmentConfig('host_path'), '/');
|
||||||
|
|
|
@ -154,4 +154,14 @@ class RuntimeTest extends TestCase
|
||||||
$process = $runtime->runLocalCommand('false');
|
$process = $runtime->runLocalCommand('false');
|
||||||
$this->assertFalse($process->isSuccessful());
|
$this->assertFalse($process->isSuccessful());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCurrentUser()
|
||||||
|
{
|
||||||
|
$runtime = new Runtime();
|
||||||
|
$userData = posix_getpwuid(posix_geteuid());
|
||||||
|
|
||||||
|
$this->assertTrue(is_array($userData));
|
||||||
|
$this->assertArrayHasKey('name', $userData);
|
||||||
|
$this->assertEquals($userData['name'], $runtime->getCurrentUser());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue