mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Added identity file option for ssh and scp commands
This commit is contained in:
		
							parent
							
								
									a97d172a6d
								
							
						
					
					
						commit
						beb663e801
					
				@ -341,10 +341,20 @@ class Config
 | 
				
			|||||||
    public function getHostPort()
 | 
					    public function getHostPort()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $info = explode(':', $this->host);
 | 
					        $info = explode(':', $this->host);
 | 
				
			||||||
        $info[] = $this->deployment('port', '22');
 | 
					        $info[] = $this->deployment('port', '22');
 | 
				
			||||||
        return $info[1];
 | 
					        return $info[1];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Get the general Host Identity File Option
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return string
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getHostIdentityFileOption()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return $this->deployment('identity-file') ? '-i '.$this->deployment('identity-file').' ': '';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Get the current Host
 | 
					     * Get the current Host
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -405,7 +415,7 @@ class Config
 | 
				
			|||||||
    	}
 | 
					    	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    	// Global Config
 | 
					    	// Global Config
 | 
				
			||||||
        $config = $this->getEnvironmentOption('deployment', array());
 | 
					        $config = $this->getEnvironmentOption('deployment', array());
 | 
				
			||||||
        if (isset($config[$option])) {
 | 
					        if (isset($config[$option])) {
 | 
				
			||||||
            if (is_array($default) && ($config[$option] == '')) {
 | 
					            if (is_array($default) && ($config[$option] == '')) {
 | 
				
			||||||
                return $default;
 | 
					                return $default;
 | 
				
			||||||
@ -424,7 +434,7 @@ class Config
 | 
				
			|||||||
     * @param string $default
 | 
					     * @param string $default
 | 
				
			||||||
     * @return mixed
 | 
					     * @return mixed
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function release($option, $default = false)
 | 
					    public function release($option, $default = false)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    	// Host Config
 | 
					    	// Host Config
 | 
				
			||||||
    	if (is_array($this->hostConfig) && isset($this->hostConfig['releases'])) {
 | 
					    	if (is_array($this->hostConfig) && isset($this->hostConfig['releases'])) {
 | 
				
			||||||
@ -432,17 +442,17 @@ class Config
 | 
				
			|||||||
    			return $this->hostConfig['releases'][$option];
 | 
					    			return $this->hostConfig['releases'][$option];
 | 
				
			||||||
    		}
 | 
					    		}
 | 
				
			||||||
    	}
 | 
					    	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $config = $this->getEnvironmentOption('releases', array());
 | 
					        $config = $this->getEnvironmentOption('releases', array());
 | 
				
			||||||
        if (isset($config[$option])) {
 | 
					        if (isset($config[$option])) {
 | 
				
			||||||
            if (is_array($default) && ($config[$option] == '')) {
 | 
					            if (is_array($default) && ($config[$option] == '')) {
 | 
				
			||||||
                return $default;
 | 
					                return $default;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                return $config[$option];
 | 
					                return $config[$option];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            return $default;
 | 
					            return $default;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -192,7 +192,7 @@ abstract class AbstractTask
 | 
				
			|||||||
        // if general.yml includes "ssy_needs_tty: true", then add "-t" to the ssh command
 | 
					        // if general.yml includes "ssy_needs_tty: true", then add "-t" to the ssh command
 | 
				
			||||||
        $needs_tty = ($this->getConfig()->general('ssh_needs_tty',false) ? '-t' : '');
 | 
					        $needs_tty = ($this->getConfig()->general('ssh_needs_tty',false) ? '-t' : '');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $localCommand = 'ssh ' . $needs_tty . ' -p ' . $this->getConfig()->getHostPort() . ' '
 | 
					        $localCommand = 'ssh ' . $this->getConfig()->getHostIdentityFileOption() . $needs_tty . ' -p ' . $this->getConfig()->getHostPort() . ' '
 | 
				
			||||||
                      . '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '
 | 
					                      . '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '
 | 
				
			||||||
                      . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ' '
 | 
					                      . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ' '
 | 
				
			||||||
                      . '"cd ' . rtrim($this->getConfig()->deployment('to'), '/') . $releasesDirectory . ' && '
 | 
					                      . '"cd ' . rtrim($this->getConfig()->deployment('to'), '/') . $releasesDirectory . ' && '
 | 
				
			||||||
 | 
				
			|||||||
@ -94,7 +94,7 @@ class RsyncTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $command = 'rsync -avz '
 | 
					        $command = 'rsync -avz '
 | 
				
			||||||
                 . '--rsh="ssh -p' . $this->getConfig()->getHostPort() . '" '
 | 
					                 . '--rsh="ssh ' . $this->getConfig()->getHostIdentityFileOption() . '-p' . $this->getConfig()->getHostPort() . '" '
 | 
				
			||||||
                 . $this->excludes(array_merge($excludes, $userExcludes)) . ' '
 | 
					                 . $this->excludes(array_merge($excludes, $userExcludes)) . ' '
 | 
				
			||||||
                 . $this->getConfig()->deployment('from') . ' '
 | 
					                 . $this->getConfig()->deployment('from') . ' '
 | 
				
			||||||
                 . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
 | 
					                 . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
 | 
				
			||||||
 | 
				
			|||||||
@ -89,7 +89,7 @@ class TarGzTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
        $result = $this->runCommandLocal($command);
 | 
					        $result = $this->runCommandLocal($command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Copy Tar Gz  to Remote Host
 | 
					        // Copy Tar Gz  to Remote Host
 | 
				
			||||||
        $command = 'scp -P ' . $this->getConfig()->getHostPort() . ' ' . $localTarGz . '.tar.gz '
 | 
					        $command = 'scp ' . $this->getConfig()->getHostIdentityFileOption() . '-P ' . $this->getConfig()->getHostPort() . ' ' . $localTarGz . '.tar.gz '
 | 
				
			||||||
                 . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
 | 
					                 . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
 | 
				
			||||||
        $result = $this->runCommandLocal($command) && $result;
 | 
					        $result = $this->runCommandLocal($command) && $result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								bin/mage
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								bin/mage
									
									
									
									
									
								
							@ -13,7 +13,7 @@ date_default_timezone_set('UTC');
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
$baseDir = dirname(dirname(__FILE__));
 | 
					$baseDir = dirname(dirname(__FILE__));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
define('MAGALLANES_VERSION', '1.0.1');
 | 
					define('MAGALLANES_VERSION', '1.0.2');
 | 
				
			||||||
define('MAGALLANES_DIRECTORY', $baseDir);
 | 
					define('MAGALLANES_DIRECTORY', $baseDir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Preload
 | 
					// Preload
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user