Explorar el Código

fixed route install rsync ssh args

Piotr Labudda hace 8 años
padre
commit
d74c09d615
Se han modificado 2 ficheros con 30 adiciones y 20 borrados
  1. 29 19
      SE/se-lib/Route/Install.php
  2. 1 1
      SE/se-lib/V.php

+ 29 - 19
SE/se-lib/Route/Install.php

@@ -943,7 +943,7 @@ jQuery(document).ready(function () {
 
 		$sshHostUsr = "{$appLicenceInfo->rootLogin}@{$appLicenceInfo->mainServer}";
 		$sshArgs = (22 != $appLicenceInfo->sshPort)? "-p {$appLicenceInfo->sshPort}" : '';
-		$rsyncSshPort = (22 != $appLicenceInfo->sshPort)? "-e 'ssh -p {$appLicenceInfo->sshPort}'" : '';
+		$rsyncSshPort = (22 != $appLicenceInfo->sshPort || $this->sshArgsSkipHostKey) ? "-e 'ssh {$sshArgs} {$this->sshArgsSkipHostKey}'" : '';
 		$scpArgs = (22 != $appLicenceInfo->sshPort)? "-P {$appLicenceInfo->sshPort}" : '';
 
 		// $appLicenceInfo->sshPort
@@ -956,33 +956,43 @@ jQuery(document).ready(function () {
 		$remoteDir = $this->_fetchRemoteHomeDir($appLicenceInfo);
 		DBG::log($remoteDir, 'array', "remote home dir:");
 
-		$cmd = "
-ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} '[ ! -d ~/se.encrypted.upgrade ] && mkdir ~/se.encrypted.upgrade || echo 1';
-ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'rm -rf ~/se.encrypted.upgrade/SE';
-ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'cp -r /Library/Server/Web/Data/Sites/Default/SE ~/se.encrypted.upgrade/SE';
-ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'rm -rf ~/se.encrypted.upgrade/SE/config';
-rsync --archive --times --delete --compress --one-file-system --omit-dir-times --no-g --no-perms {$dryRunOnly} \
+		$listCmd = [];
+		$listCmd[] = " ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} '[ ! -d ~/se.encrypted.upgrade ] && mkdir ~/se.encrypted.upgrade || echo 1' ";
+		$listCmd[] = " ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'rm -rf ~/se.encrypted.upgrade/SE' ";
+		$listCmd[] = " ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'cp -p -r /Library/Server/Web/Data/Sites/Default/SE ~/se.encrypted.upgrade/SE' ";
+		$listCmd[] = " ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'rm -rf ~/se.encrypted.upgrade/SE/config' ";
+		$listCmd[] = "
+rsync --recursive --links -D --delete --compress --one-file-system --omit-dir-times --no-g --no-perms {$dryRunOnly} \
 	--verbose {$rsyncSshPort} \
 	--exclude='schema/default_db.instance.xml' \
 	--exclude='schema/default_db.instance.xml/**' \
-	'{$appLicenceInfo->installPath}/SE/' {$sshHostUsr}:~/se.encrypted.upgrade/SE/;
-ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'cp -r /Library/Server/Web/Data/Sites/Default/SE/config ~/se.encrypted.upgrade/SE/';
-ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'rm /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade'
-ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'ln -s ~/se.encrypted.upgrade/SE /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade'
-scp {$this->sshArgsSkipHostKey}  {$scpArgs} /Library/Server/Web/Data/Sites/SE-production-git/SE/config/.config_base_structure.php {$sshHostUsr}:
-ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'mv ~/.config_base_structure.php /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade/config'
-ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'cp  /Users/server/se.encrypted.upgrade/SE/stuff/SourceGuardian/Loaders/Mac\ OS\ X/ixed.5.6.dar /opt/local/lib/php56/extensions/no-debug-non-zts-20131226/'
-		"; //todo rsync ... -e \"{$this->sshArgsSkipHostKey}\" - maybe not working
+	'{$appLicenceInfo->installPath}/SE/' {$sshHostUsr}:~/se.encrypted.upgrade/SE/
+		";
+		$listCmd[] = " ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'cp -r /Library/Server/Web/Data/Sites/Default/SE/config ~/se.encrypted.upgrade/SE/' ";
+		$listCmd[] = " ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'rm /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade' ";
+		$listCmd[] = " ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'ln -s ~/se.encrypted.upgrade/SE /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade' ";
+		$listCmd[] = " scp {$this->sshArgsSkipHostKey}  {$scpArgs} /Library/Server/Web/Data/Sites/SE-production-git/SE/config/.config_base_structure.php {$sshHostUsr}: ";
+		$listCmd[] = " ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'mv ~/.config_base_structure.php /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade/config' ";
+
+		$listRootCmd = [];
+		$listRootCmd[] = " ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'cp  /Users/server/se.encrypted.upgrade/SE/stuff/SourceGuardian/Loaders/Mac\ OS\ X/ixed.5.6.dar /opt/local/lib/php56/extensions/no-debug-non-zts-20131226/' ";
+		// "; //todo rsync ... -e \"{$this->sshArgsSkipHostKey}\" - maybe not working
 		// --exclude='schema/default_db_xml_cache.public' \
 		// --exclude='stuff' \
 		// --exclude='stuff/**' \
 		//--exclude='schema/default_db_xml_cache.public/**' \
 		//TODO @2018-02-09 - check if ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} 'cp  /Applications/SourceGuardian.app/Contents/MacOS/Loaders/Mac\ OS\ X/ixed.5.6.dar /opt/local/lib/php56/extensions/no-debug-non-zts-20131226/'
 			//IS WORKING WELL!
-
-		V::exec("$cmd 2>&1", $out, $ret);
-		DBG::log([ 'cmd-remote' => $cmd, 'output' => $out ], 'array', "return: {$ret}");
-		if (0 !== $ret) throw new Exception("Cannot run remote command using rsa key! #{$ret}. cmd: {$cmd} . out: {$out}");
+		foreach ($listCmd as $idx => $cmd) {
+			V::exec("{$cmd} 2>&1", $out, $ret);
+			DBG::log([ 'cmd' => $cmd, 'output' => $out ], 'array', "cmd[{$idx}] return: {$ret}");
+			if (0 !== $ret) throw new Exception("Cannot run remote command using rsa key! #{$ret}. cmd: {$cmd} . out: " . implode("\n", $out));
+		}
+		foreach ($listRootCmd as $idx => $rootCmd) {
+			V::execRootRemote($appLicenceInfo->mainServer, $appLicenceInfo->rootLogin, $appLicenceInfo->rootPassword, "{$rootCmd} 2>&1", $out, $ret, $appLicenceInfo->sshPort);
+			DBG::log([ 'cmd' => $rootCmd, 'output' => $out ], 'array', "root cmd[{$idx}] return: {$ret}");
+			if (0 !== $ret) throw new Exception("Cannot run remote command using rsa key! #{$ret}. root cmd: {$rootCmd} . out: " . implode("\n", $out));
+		}
 	}
 
 	public function upgradeRemoteFromTestDirAction() {

+ 1 - 1
SE/se-lib/V.php

@@ -436,7 +436,7 @@ EOF';
 		$pass = $password;
 		$pass = str_replace('!', '\!', $pass);
 		$sshPort = (22 != $port)? "-p {$port}" : '';
-		$cmd = '/opt/local/bin/sshpass -p ' . $pass . ' ssh -o StrictHostKeyChecking=no -o ConnectTimeout=99999 ' . $sshPort . ' ' . $login . '@' . $host . ' -t <<EOF
+		$cmd = '/opt/local/bin/sshpass -p ' . $pass . ' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=99999 ' . $sshPort . ' ' . $login . '@' . $host . ' -t <<EOF
 sudo -n su -
 declare PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/opt/local/lib/mysql55/bin/:/Applications/Server.app/Contents/ServerRoot/usr/sbin/