|
@@ -7,6 +7,11 @@ Lib::loadClass('UI');
|
|
|
|
|
|
|
|
class Route_Install extends RouteBase {
|
|
class Route_Install extends RouteBase {
|
|
|
|
|
|
|
|
|
|
+ public function __construct() {
|
|
|
|
|
+ $this->sshArgsSkipHostKey = ' -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public function handleAuth() {
|
|
public function handleAuth() {
|
|
|
if (!User::logged()) {
|
|
if (!User::logged()) {
|
|
|
throw new HttpException('Unauthorized', 401);
|
|
throw new HttpException('Unauthorized', 401);
|
|
@@ -631,7 +636,9 @@ jQuery(document).ready(function () {
|
|
|
$sshHostUsr = "{$appLicenceInfo->rootLogin}@{$appLicenceInfo->mainServer}";
|
|
$sshHostUsr = "{$appLicenceInfo->rootLogin}@{$appLicenceInfo->mainServer}";
|
|
|
$sshArgs = (22 != $appLicenceInfo->sshPort)? "-p {$appLicenceInfo->sshPort}" : '';
|
|
$sshArgs = (22 != $appLicenceInfo->sshPort)? "-p {$appLicenceInfo->sshPort}" : '';
|
|
|
$rsyncSshPort = (22 != $appLicenceInfo->sshPort)? "-e 'ssh -p {$appLicenceInfo->sshPort}'" : '';
|
|
$rsyncSshPort = (22 != $appLicenceInfo->sshPort)? "-e 'ssh -p {$appLicenceInfo->sshPort}'" : '';
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (V::get('DBG_REMOTE', '', $_GET)) {// DBG
|
|
if (V::get('DBG_REMOTE', '', $_GET)) {// DBG
|
|
|
$cmd = "echo ~";
|
|
$cmd = "echo ~";
|
|
|
V::exec("ssh {$sshArgs} {$sshHostUsr} '{$cmd}'", $out, $ret);
|
|
V::exec("ssh {$sshArgs} {$sshHostUsr} '{$cmd}'", $out, $ret);
|
|
@@ -643,7 +650,7 @@ jQuery(document).ready(function () {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$cmd = "echo ~";
|
|
$cmd = "echo ~";
|
|
|
- V::exec("ssh {$sshArgs} {$sshHostUsr} '{$cmd}'", $out, $ret);
|
|
|
|
|
|
|
+ V::exec("ssh {$sshArgs} {$this->sshArgsSkipHostKey} {$sshHostUsr} '{$cmd}'", $out, $ret);
|
|
|
DBG::log([ 'cmd-remote' => $cmd, 'output' => $out ], 'array', "return: {$ret}");
|
|
DBG::log([ 'cmd-remote' => $cmd, 'output' => $out ], 'array', "return: {$ret}");
|
|
|
if (empty($out) || empty($out[0])) throw new Exception("Cannot fetch remote home dir");
|
|
if (empty($out) || empty($out[0])) throw new Exception("Cannot fetch remote home dir");
|
|
|
return $out[0];
|
|
return $out[0];
|
|
@@ -669,11 +676,11 @@ jQuery(document).ready(function () {
|
|
|
DBG::log($remoteDir, 'array', "remote home dir:");
|
|
DBG::log($remoteDir, 'array', "remote home dir:");
|
|
|
|
|
|
|
|
$cmd = "
|
|
$cmd = "
|
|
|
-ssh {$sshArgs} {$sshHostUsr} '[ ! -d ~/se.encrypted.upgrade ] && mkdir ~/se.encrypted.upgrade || echo 1';
|
|
|
|
|
-ssh {$sshArgs} {$sshHostUsr} 'rm -rf ~/se.encrypted.upgrade/SE';
|
|
|
|
|
-ssh {$sshArgs} {$sshHostUsr} 'cp -r /Library/Server/Web/Data/Sites/Default/SE ~/se.encrypted.upgrade/SE';
|
|
|
|
|
-ssh {$sshArgs} {$sshHostUsr} 'rm -rf ~/se.encrypted.upgrade/SE/config';
|
|
|
|
|
-rsync --archive --times --delete --compress --one-file-system --omit-dir-times --no-g --no-perms {$dryRunOnly} \
|
|
|
|
|
|
|
+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 -e \"{$this->sshArgsSkipHostKey}\" --archive --times --delete --compress --one-file-system --omit-dir-times --no-g --no-perms {$dryRunOnly} \
|
|
|
--verbose {$rsyncSshPort} \
|
|
--verbose {$rsyncSshPort} \
|
|
|
--exclude='stuff' \
|
|
--exclude='stuff' \
|
|
|
--exclude='stuff/**' \
|
|
--exclude='stuff/**' \
|
|
@@ -682,13 +689,13 @@ rsync --archive --times --delete --compress --one-file-system --omit-dir-times -
|
|
|
--exclude='schema/default_db.instance.xml/**' \
|
|
--exclude='schema/default_db.instance.xml/**' \
|
|
|
--exclude='schema/default_db_xml_cache.public/**' \
|
|
--exclude='schema/default_db_xml_cache.public/**' \
|
|
|
'{$appLicenceInfo->installPath}/SE/' {$sshHostUsr}:~/se.encrypted.upgrade/SE/;
|
|
'{$appLicenceInfo->installPath}/SE/' {$sshHostUsr}:~/se.encrypted.upgrade/SE/;
|
|
|
-ssh {$sshArgs} {$sshHostUsr} 'cp -r /Library/Server/Web/Data/Sites/Default/SE/config ~/se.encrypted.upgrade/SE/';
|
|
|
|
|
-ssh {$sshArgs} {$sshHostUsr} 'rm /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade'
|
|
|
|
|
-ssh {$sshArgs} {$sshHostUsr} 'ln -s ~/se.encrypted.upgrade/SE /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade'
|
|
|
|
|
|
|
+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'
|
|
|
";
|
|
";
|
|
|
- V::exec($cmd, $out, $ret);
|
|
|
|
|
|
|
+ V::exec("$cmd 2>&1", $out, $ret);
|
|
|
DBG::log([ 'cmd-remote' => $cmd, 'output' => $out ], 'array', "return: {$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} ");
|
|
|
|
|
|
|
+ if (0 !== $ret) throw new Exception("Cannot run remote command using rsa key! #{$ret}. cmd: {$cmd} . out: {$out}");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function upgradeRemoteFromTestDirAction() {
|
|
public function upgradeRemoteFromTestDirAction() {
|
|
@@ -793,10 +800,14 @@ chmod 600 ~/.ssh/authorized_keys;
|
|
|
//$cmd = "ssh server@{$appLicenceInfo->mainServer} 'ls -1 .ssh/'";
|
|
//$cmd = "ssh server@{$appLicenceInfo->mainServer} 'ls -1 .ssh/'";
|
|
|
//$cmd = "ssh -i ~/.ssh/id_rsa server@{$appLicenceInfo->mainServer} 'ls -1'";
|
|
//$cmd = "ssh -i ~/.ssh/id_rsa server@{$appLicenceInfo->mainServer} 'ls -1'";
|
|
|
$sshPort = (22 != $appLicenceInfo->sshPort)? "-p {$appLicenceInfo->sshPort}" : '';
|
|
$sshPort = (22 != $appLicenceInfo->sshPort)? "-p {$appLicenceInfo->sshPort}" : '';
|
|
|
- $cmd = "ssh {$sshPort} {$appLicenceInfo->rootLogin}@{$appLicenceInfo->mainServer} 'ls -1'";
|
|
|
|
|
- V::exec($cmd, $out, $ret);
|
|
|
|
|
|
|
+ $cmd = "ssh {$sshPort} {$this->sshArgsSkipHostKey} {$appLicenceInfo->rootLogin}@{$appLicenceInfo->mainServer} 'ls -1'";
|
|
|
|
|
+ V::exec("$cmd 2>&1", $out, $ret); // http://php.net/manual/pl/function.exec.php says I saw the exec, system, shell_exec and passthru functions,
|
|
|
|
|
+ //and deduced that the solution was to
|
|
|
|
|
+ //redirect the standard error (stderr) to the standard output (stdout). It's not very clean, since it mixes stderr with stdout, and I only wanted to log the stderr.
|
|
|
|
|
+ //But it seems to be the only solution (suggestions are welcome).
|
|
|
|
|
+
|
|
|
DBG::_(true, true, "cmd: {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
|
|
DBG::_(true, true, "cmd: {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
- if (0 !== $ret) throw new Exception("Cannot run remote command using rsa key! #{$ret}. Cmd: {$cmd}");
|
|
|
|
|
|
|
+ if (0 !== $ret) throw new Exception("Cannot run remote command using rsa key! #{$ret}; Out: ".implode($out)."; Cmd: {$cmd};");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|