|
|
@@ -95,6 +95,9 @@ jQuery(document).ready(function () {
|
|
|
<p style="margin-top:30px">
|
|
|
Test online: <a target="_blank" href="https://<?php echo $appLicenceInfo->mainServer; ?>/se.encrypted.upgrade/">https://<?php echo $appLicenceInfo->mainServer; ?>/se.encrypted.upgrade/</a>
|
|
|
</p>
|
|
|
+ <br> - <a href="index.php?_route=Install&_task=upgradeRemoteFromTestDir&licence_id=<?php echo $appLicenceInfo->ID; ?>"
|
|
|
+ target="_blank"
|
|
|
+ class="btn btn-xs btn-warning">UPGRADE Production folder from uploaded dir: ~/se.encrypted.upgrade/</a>
|
|
|
</div>
|
|
|
<?php endif; ?>
|
|
|
</div>
|
|
|
@@ -416,6 +419,67 @@ jQuery(document).ready(function () {
|
|
|
public function _sendToRemoteTestDir($appLicenceInfo) {
|
|
|
$cmd = ''; $out = ''; $ret = '';
|
|
|
|
|
|
+ $this->_assertRsaKeyExists($appLicenceInfo);
|
|
|
+
|
|
|
+ $sshHostUsr = "{$appLicenceInfo->rootLogin}@{$appLicenceInfo->mainServer}";
|
|
|
+ $cmd = "
|
|
|
+ssh {$sshHostUsr} '[ ! -d ~/se.encrypted.upgrade ] && mkdir ~/se.encrypted.upgrade || echo 1';
|
|
|
+ssh {$sshHostUsr} 'rm -rf ~/se.encrypted.upgrade/SE';
|
|
|
+rsync --archive --verbose --update --times --compress --one-file-system --omit-dir-times --no-g --no-perms \
|
|
|
+ '{$appLicenceInfo->installPath}/SE/' {$sshHostUsr}:~/se.encrypted.upgrade/SE/;
|
|
|
+ssh {$sshHostUsr} 'cp -r /Library/Server/Web/Data/Sites/Default/SE/config ~/se.encrypted.upgrade/SE/';
|
|
|
+ssh {$sshHostUsr} 'rm /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade'
|
|
|
+ssh {$sshHostUsr} 'ln -s ~/se.encrypted.upgrade/SE /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade'
|
|
|
+ ";
|
|
|
+ V::exec($cmd, $out, $ret);
|
|
|
+ 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}");
|
|
|
+ }
|
|
|
+
|
|
|
+ public function upgradeRemoteFromTestDirAction() {
|
|
|
+ $args = array();
|
|
|
+ $args['licence_id'] = V::get('licence_id', 0, $_REQUEST, 'int');
|
|
|
+ SE_Layout::gora();
|
|
|
+ //SE_Layout::menu();
|
|
|
+ //$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
+
|
|
|
+ try {
|
|
|
+ $appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
+ $this->_upgradeRemoteFromTestDir($appLicenceInfo);
|
|
|
+?>
|
|
|
+ Test online: <a target="_blank" href="https://<?php echo $appLicenceInfo->mainServer; ?>/SE/">https://<?php echo $appLicenceInfo->mainServer; ?>/SE/</a>
|
|
|
+<?php
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $this->_endWithException($e);
|
|
|
+ }
|
|
|
+
|
|
|
+ SE_Layout::dol();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _upgradeRemoteFromTestDir($appLicenceInfo) {
|
|
|
+ $cmd = ''; $out = ''; $ret = '';
|
|
|
+
|
|
|
+ $this->_assertRsaKeyExists($appLicenceInfo);
|
|
|
+
|
|
|
+ $sshHostUsr = "{$appLicenceInfo->rootLogin}@{$appLicenceInfo->mainServer}";
|
|
|
+ $dateStr = date("Y-m-d_H-i-s");
|
|
|
+ $cmd = "
|
|
|
+ssh {$sshHostUsr} 'rm -rf /Library/Server/Web/Data/Sites/Default/SE.test';
|
|
|
+ssh {$sshHostUsr} 'cp -r ~/se.encrypted.upgrade/SE /Library/Server/Web/Data/Sites/Default/SE.test';
|
|
|
+ssh {$sshHostUsr} '[ ! -d ~/bup.se.upgrade ] && mkdir ~/bup.se.upgrade || echo 1';
|
|
|
+ssh {$sshHostUsr} '[ ! -f /Library/Server/Web/Data/Sites/Default/SE.test/VERSION ] && echo \"Error: plik VERSION nie istnieje\" || echo \"check VERSION OK\"';
|
|
|
+ssh {$sshHostUsr} '[ ! -f /Library/Server/Web/Data/Sites/Default/SE.test/index.php ] && echo \"Error: plik index.php nie istnieje\" || echo \"check index.php OK\"';
|
|
|
+ssh {$sshHostUsr} '[ ! -d /Library/Server/Web/Data/Sites/Default/SE.test/se-lib ] && echo \"Error: plik se-lib nie istnieje\" || echo \"check se-lib OK\"';
|
|
|
+ssh {$sshHostUsr} 'mv /Library/Server/Web/Data/Sites/Default/SE ~/bup.se.upgrade/bup.{$dateStr}';
|
|
|
+ssh {$sshHostUsr} 'mv /Library/Server/Web/Data/Sites/Default/SE.test /Library/Server/Web/Data/Sites/Default/SE';
|
|
|
+ ";
|
|
|
+ V::exec($cmd, $out, $ret);
|
|
|
+ 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}");
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _assertRsaKeyExists($appLicenceInfo) {
|
|
|
+ $cmd = ''; $out = ''; $ret = '';
|
|
|
$cmd = "echo ~ && pwd";// /Library/WebServer
|
|
|
$cmd = "ls -1 ~/.ssh/";
|
|
|
//$cmd = "rm /tmp/id_rsa";
|
|
|
@@ -445,9 +509,9 @@ jQuery(document).ready(function () {
|
|
|
|
|
|
$cmd = 'ls -1a';
|
|
|
$cmd = "
|
|
|
- [ ! -d ~/.sshX ] && mkdir ~/.sshX || echo 'OK ~/.ssh exists';
|
|
|
- cat ~/.sshX/authorized_keys| grep '{$rsaPubKey}' && echo 'OK' || echo '{$rsaPubKey}' >> ~/.sshX/authorized_keys;
|
|
|
- chmod 600 ~/.sshX/authorized_keys;
|
|
|
+[ ! -d ~/.ssh ] && mkdir ~/.ssh || echo 'OK ~/.ssh exists';
|
|
|
+cat ~/.ssh/authorized_keys| grep '{$rsaPubKey}' && echo 'OK' || echo '{$rsaPubKey}' >> ~/.ssh/authorized_keys;
|
|
|
+chmod 600 ~/.ssh/authorized_keys;
|
|
|
";
|
|
|
V::execRemote($appLicenceInfo->mainServer, $appLicenceInfo->rootLogin, $appLicenceInfo->rootPassword, $cmd, $out, $ret);
|
|
|
DBG::_(true, true, "remote cmd: {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
@@ -458,20 +522,6 @@ jQuery(document).ready(function () {
|
|
|
V::exec($cmd, $out, $ret);
|
|
|
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}");
|
|
|
-
|
|
|
- $sshHostUsr = "{$appLicenceInfo->rootLogin}@{$appLicenceInfo->mainServer}";
|
|
|
- $cmd = "
|
|
|
- ssh {$sshHostUsr} '[ ! -d ~/se.encrypted.upgrade ] mkdir ~/se.encrypted.upgrade || echo 1';
|
|
|
- ssh {$sshHostUsr} 'rm -rf ~/se.encrypted.upgrade/SE';
|
|
|
- rsync --archive --verbose --update --times --compress --one-file-system --omit-dir-times --no-g --no-perms \
|
|
|
- '{$appLicenceInfo->installPath}/SE/' {$sshHostUsr}:~/se.encrypted.upgrade/SE/;
|
|
|
- ssh {$sshHostUsr} 'ln -s /Library/Server/Web/Data/Sites/Default/SE/config ~/se.encrypted.upgrade/SE/config';
|
|
|
- ssh {$sshHostUsr} 'rm /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade'
|
|
|
- ssh {$sshHostUsr} 'ln -s ~/se.encrypted.upgrade/SE /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade'
|
|
|
- ";
|
|
|
- V::exec($cmd, $out, $ret);
|
|
|
- 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}");
|
|
|
}
|
|
|
|
|
|
}
|