|
@@ -20,6 +20,7 @@ class Route_Install extends RouteBase {
|
|
|
UI::gora();
|
|
|
UI::menu();
|
|
|
$this->menu();
|
|
|
+ UI::setTitleJsTag("Install");
|
|
|
UI::dol();
|
|
|
}
|
|
|
|
|
@@ -113,76 +114,140 @@ jQuery(document).ready(function () {
|
|
|
|
|
|
UI::gora();
|
|
|
UI::menu();
|
|
|
+ UI::setTitleJsTag("Install");
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
|
|
|
try {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
+ $this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
} catch (Exception $e) {
|
|
|
$this->_endWithException($e);
|
|
|
}
|
|
|
- //$this->generateApp($args['licence_id']);
|
|
|
+ // $this->generateApp($appLicenceInfo->installPath, $appLicenceInfo->domains);
|
|
|
//DBG::_(true, true, "appLicenceInfo", $appLicenceInfo, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
-?>
|
|
|
-<div class="jumbotron">
|
|
|
- <div class="container">
|
|
|
- <h3>Generowanie aplikacji dla licencji <?php echo $appLicenceInfo->ID; ?></h3>
|
|
|
- <p>Licencja dla domen: <?php echo implode(', ', $appLicenceInfo->domains); ?></p>
|
|
|
- <p>Katalog z zakodowanymi plikami: <?php echo $appLicenceInfo->installFolderName; ?></p>
|
|
|
- <form class="form-inline" method="POST">
|
|
|
- <input type="hidden" name="_task" value="createApp" />
|
|
|
- <input type="hidden" name="licence_id" value="<?php echo $appLicenceInfo->ID; ?>" />
|
|
|
- <input type="hidden" name="_generateEncryptedSource" value="1" />
|
|
|
- <button type="submit" id="fldSbmtBtn" class="btn btn-primary" autocomplete="off">
|
|
|
- Generuj
|
|
|
- </button>
|
|
|
- </form>
|
|
|
- <?php if ($appLicenceInfo->installFolderGitExists) : ?>
|
|
|
- <br>
|
|
|
- <div class="alert alert-info">
|
|
|
- Katalog istnieje i zawiera już repozytorium git:
|
|
|
- <br> - <a href="index.php?_route=Install&_task=gitResetHard&licence_id=<?php echo $appLicenceInfo->ID; ?>"
|
|
|
- target="_blank"
|
|
|
- class="btn btn-xs btn-default">aktualizuj werjsę</a> (git reset --hard, git pull, set SE/VERSION - tak samo co 'rm -rf; git clone', ale szybciej)
|
|
|
- <br> - <a href="index.php?_route=Install&_task=encodeSource&licence_id=<?php echo $appLicenceInfo->ID; ?>"
|
|
|
- target="_blank"
|
|
|
- class="btn btn-xs btn-default">encode files</a>
|
|
|
- <br> - <a href="index.php?_route=Install&_task=sendToRemoteTestDir&licence_id=<?php echo $appLicenceInfo->ID; ?>"
|
|
|
- target="_blank"
|
|
|
- class="btn btn-xs btn-default">send encoded files to remote server test folder (generates ssh key if not set)</a>
|
|
|
- <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; ?>"
|
|
|
- onclick="return confirm('Uruchomić aktualizację SE na https://<?php echo $appLicenceInfo->mainServer; ?>/SE/?')"
|
|
|
- target="_blank"
|
|
|
- class="btn btn-xs btn-warning">UPGRADE Production folder from uploaded dir: ~/se.encrypted.upgrade/</a>
|
|
|
- </div>
|
|
|
- <?php endif; ?>
|
|
|
- </div>
|
|
|
-</div>
|
|
|
-<script type="text/javascript">
|
|
|
-jQuery(document).ready(function () {
|
|
|
- jQuery('#fldSbmtBtn').on('click', function () {
|
|
|
- jQuery(this).text(jQuery(this).text() + '...').attr('disabled', 'disabled');
|
|
|
- jQuery(this).parent().submit();
|
|
|
- })
|
|
|
-});
|
|
|
-</script>
|
|
|
-<?php
|
|
|
- $generateEncryptedSource = (1 == V::get('_generateEncryptedSource', 0, $_REQUEST, 'int'));
|
|
|
- if ($generateEncryptedSource) {
|
|
|
+
|
|
|
+ if ('_generateEncryptedSource' === V::get('_postTask', '', $_POST)) {
|
|
|
echo '<div class="container">';
|
|
|
echo '<h4>' . "Generowanie..." . '</h4>';
|
|
|
echo '<div style="border:1px solid silver; max-height:400px; overflow-y:scroll">';
|
|
|
try {
|
|
|
- $this->generateApp($appLicenceInfo);
|
|
|
+ $this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
+ $this->generateApp($appLicenceInfo->installPath, $appLicenceInfo->domains);
|
|
|
} catch (Exception $e) {
|
|
|
echo '</div></div>';// .container/ scroll
|
|
|
$this->_endWithException($e);
|
|
|
}
|
|
|
echo '</div>';// .container
|
|
|
UI::alert('success', "<strong>Gotowe</strong> Aplikacja znajduje się w katalogu {$appLicenceInfo->installFolderName}");
|
|
|
+ $appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
}
|
|
|
+ if ('newGenerateApp' === V::get('_postTask', '', $_POST)) {
|
|
|
+ $this->newGenerateApp($appLicenceInfo);
|
|
|
+ }
|
|
|
+ if ('updateAndSendToRemoteTestDir' === V::get('_postTask', '', $_POST)) {
|
|
|
+ echo '<details><summary style="cursor:pointer">aktualizuj werjsę, szyfruj i wyślij do testowego katalogu na serwerze</summary>';
|
|
|
+ try {
|
|
|
+ $idLicence = V::get('licence_id', 0, $_POST, 'int');
|
|
|
+ $appLicenceInfo = $this->getAppLicenceInfo($idLicence);
|
|
|
+ $this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
+ $projects = [ 'bravecare' ]; // TODO: fetch from $appLicenceInfo->projects = [ ... ]
|
|
|
+ $this->gitResetHard($appLicenceInfo->installPath, $projects);
|
|
|
+ flush();
|
|
|
+ $this->_encodeSource($appLicenceInfo->installPath, $appLicenceInfo->domains);
|
|
|
+ flush();
|
|
|
+ $this->_sendToRemoteTestDir($appLicenceInfo);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ DBG::log($e);
|
|
|
+ UI::alert('danger', $e->getMessage());
|
|
|
+ }
|
|
|
+ echo '</details>';
|
|
|
+ $testDirUrl = "https://{$appLicenceInfo->mainServer}/se.encrypted.upgrade/";
|
|
|
+ UI::alert('info', UI::h('p', [], [
|
|
|
+ "testowy katalog zaktualizowany - ",
|
|
|
+ UI::h('a', [ 'href' => $testDirUrl, 'target' => "_blank" ], $testDirUrl),
|
|
|
+ ]));
|
|
|
+ flush();
|
|
|
+ }
|
|
|
+ // echo UI::hButtonPost("TODO: Generuj z p5.git", [
|
|
|
+ // 'class' => "btn btn-md btn-primary",
|
|
|
+ // 'data' => [
|
|
|
+ // '_postTask' => "newGenerateApp",
|
|
|
+ // 'licence_id' => $appLicenceInfo->ID,
|
|
|
+ // ],
|
|
|
+ // ]);
|
|
|
+ echo UI::h('div', [ 'class' => "jumbotron" ], [
|
|
|
+ UI::h('div', [ 'class' => "container" ], [
|
|
|
+ UI::h('h3', [], "Generowanie aplikacji dla licencji {$appLicenceInfo->ID}"),
|
|
|
+ UI::h('p', [], "Licencja dla domen: " . implode(', ', $appLicenceInfo->domains)),
|
|
|
+ UI::h('p', [], "Katalog z zakodowanymi plikami: {$appLicenceInfo->installFolderName}"),
|
|
|
+ UI::hButtonPost("Generuj", [
|
|
|
+ 'class' => "btn btn-primary",
|
|
|
+ 'data' => [
|
|
|
+ '_postTask' => '_generateEncryptedSource',
|
|
|
+ 'licence_id' => $appLicenceInfo->ID,
|
|
|
+ ]
|
|
|
+ ]),
|
|
|
+ (!$appLicenceInfo->installFolderGitExists)
|
|
|
+ ? UI::h('div', [ 'class' => "alert alert-info" ], "Katalog nie istnieje - wygeneruj aplikację")
|
|
|
+ : UI::h('div', [ 'class' => "alert alert-info", 'style' => "margin-top:10px" ], [
|
|
|
+ UI::h('p', [], "Katalog istnieje i zawiera już repozytorium git: "),
|
|
|
+ UI::h('p', [], [
|
|
|
+ UI::hButtonPost("aktualizuj werjsę, szyfruj i wyślij do testowego katalogu na serwerze", [
|
|
|
+ 'class' => "btn btn-xs btn-primary",
|
|
|
+ 'data' => [
|
|
|
+ '_postTask' => "updateAndSendToRemoteTestDir",
|
|
|
+ 'licence_id' => $appLicenceInfo->ID,
|
|
|
+ ],
|
|
|
+ ]),
|
|
|
+ ]),
|
|
|
+ UI::h('p', [ 'style' => "margin-left:20px" ], [
|
|
|
+ UI::h('a', [
|
|
|
+ 'href' => "index.php?_route=Install&_task=gitResetHard&licence_id={$appLicenceInfo->ID}",
|
|
|
+ 'target' => "_blank",
|
|
|
+ 'class' => "btn btn-xs btn-default"
|
|
|
+ ], "aktualizuj werjsę</a> (git reset --hard, git pull, set SE/VERSION - tak samo co 'rm -rf; git clone', ale szybciej)"),
|
|
|
+ ]),
|
|
|
+ UI::h('p', [ 'style' => "margin-left:20px" ], [
|
|
|
+ UI::h('a', [
|
|
|
+ 'href' => "index.php?_route=Install&_task=encodeSource&licence_id={$appLicenceInfo->ID}",
|
|
|
+ 'target' => "_blank",
|
|
|
+ 'class' => "btn btn-xs btn-default"
|
|
|
+ ], "encode files"),
|
|
|
+ ]),
|
|
|
+ UI::h('p', [ 'style' => "margin-left:20px" ], [
|
|
|
+ UI::h('a', [
|
|
|
+ 'href' => "index.php?_route=Install&_task=sendToRemoteTestDir&licence_id={$appLicenceInfo->ID}",
|
|
|
+ 'target' => "_blank",
|
|
|
+ 'class' => "btn btn-xs btn-default"
|
|
|
+ ], "send encoded files to remote server test folder (generates ssh key if not set)"),
|
|
|
+ ]),
|
|
|
+ UI::h('p', [ 'style' => "margin-top:30px" ], [
|
|
|
+ "Test online: ",
|
|
|
+ UI::h('a', [
|
|
|
+ 'target' => "_blank",
|
|
|
+ 'href' => "https://{$appLicenceInfo->mainServer}/se.encrypted.upgrade/"
|
|
|
+ ], "https://{$appLicenceInfo->mainServer}/se.encrypted.upgrade/"),
|
|
|
+ ]),
|
|
|
+ "<br> - ",
|
|
|
+ UI::h('a', [
|
|
|
+ 'href' => "index.php?_route=Install&_task=upgradeRemoteFromTestDir&licence_id={$appLicenceInfo->ID}",
|
|
|
+ 'onclick' => "return confirm('Uruchomić aktualizację SE na https://{$appLicenceInfo->mainServer}/SE/?')",
|
|
|
+ 'target' => "_blank",
|
|
|
+ 'class' => "btn btn-xs btn-warning"
|
|
|
+ ], "UPGRADE Production folder from uploaded dir: ~/se.encrypted.upgrade/"),
|
|
|
+ ]),
|
|
|
+ ]),
|
|
|
+ ]);
|
|
|
+?>
|
|
|
+<script type="text/javascript">
|
|
|
+jQuery(document).ready(function () {
|
|
|
+ jQuery('#fldSbmtBtn').on('click', function () {
|
|
|
+ jQuery(this).text(jQuery(this).text() + '...').attr('disabled', 'disabled');
|
|
|
+ jQuery(this).parent().submit();
|
|
|
+ })
|
|
|
+});
|
|
|
+</script>
|
|
|
+<?php
|
|
|
UI::dol();
|
|
|
}
|
|
|
|
|
@@ -195,11 +260,11 @@ jQuery(document).ready(function () {
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
try {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
- if (empty($appLicenceInfo->ID)) throw new Exception("Nie wybrano serwera/licencji.");
|
|
|
- if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found");
|
|
|
- if (empty($appLicenceInfo->installPath)) throw new Exception("Install path not found");
|
|
|
+ $this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
+
|
|
|
UI::startContainer();
|
|
|
- $this->gitResetHard($appLicenceInfo->installPath);
|
|
|
+ $projects = [ 'bravecare' ]; // TODO: fetch from $appLicenceInfo->projects = [ ... ]
|
|
|
+ $this->gitResetHard($appLicenceInfo->installPath, $projects);
|
|
|
UI::endContainer();
|
|
|
} catch (Exception $e) {
|
|
|
$this->_endWithException($e);
|
|
@@ -207,7 +272,7 @@ jQuery(document).ready(function () {
|
|
|
UI::dol();
|
|
|
}
|
|
|
|
|
|
- public function gitResetHard($installPath) {
|
|
|
+ public function gitResetHard($installPath, $projects = []) {
|
|
|
if (empty($installPath)) throw new Exception("Install path not found");
|
|
|
$cmds = array();
|
|
|
$cmds[] = "git reset --hard";
|
|
@@ -220,6 +285,20 @@ jQuery(document).ready(function () {
|
|
|
if (0 !== $ret) $hasError = true;
|
|
|
DBG::nicePrint($out, "cmd: `{$cmd}` (return:{$ret})");
|
|
|
}
|
|
|
+ foreach ($projects as $projectName) {
|
|
|
+ $cmd = "ls -l SE/projects/{$projectName} | wc -l";
|
|
|
+ V::exec("cd {$installPath} && {$cmd}", $out, $ret);
|
|
|
+ DBG::nicePrint([ 'cmd' => $cmd, 'output' => $out ], "return: {$ret}");
|
|
|
+ if (!empty($out) && '0' !== trim($out[0])) {
|
|
|
+ // $cmd = "git submodule update SE/projects/{$projectName}";
|
|
|
+ $cmd = "cd SE/projects/{$projectName} && git reset --hard"; // revert encode source - checkout to last commit (need update)
|
|
|
+ V::exec("cd {$installPath} && {$cmd}", $out, $ret);
|
|
|
+ DBG::nicePrint([ 'cmd' => $cmd, 'output' => $out ], "return: {$ret}");
|
|
|
+ }
|
|
|
+ $cmd = "git submodule update --init SE/projects/{$projectName}"; // checkout to current commit
|
|
|
+ V::exec("cd {$installPath} && {$cmd}", $out, $ret);
|
|
|
+ DBG::nicePrint([ 'cmd' => $cmd, 'output' => $out ], "return: {$ret}");
|
|
|
+ }
|
|
|
if (!$hasError) {
|
|
|
UI::alert('success', "OK");
|
|
|
} else {
|
|
@@ -236,19 +315,17 @@ jQuery(document).ready(function () {
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
try {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
- $this->_encodeSource($appLicenceInfo);
|
|
|
+ $this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
+ $this->_encodeSource($appLicenceInfo->installPath, $appLicenceInfo->domains);
|
|
|
} catch (Exception $e) {
|
|
|
$this->_endWithException($e);
|
|
|
}
|
|
|
UI::dol();
|
|
|
}
|
|
|
|
|
|
- public function _encodeSource($appLicenceInfo) {
|
|
|
- if (empty($appLicenceInfo->ID)) throw new Exception("Nie wybrano serwera/licencji.");
|
|
|
- if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found");
|
|
|
- if (empty($appLicenceInfo->installPath)) throw new Exception("Install path not found");
|
|
|
+ public function _encodeSource($installPath, $domains) {
|
|
|
UI::startContainer();
|
|
|
- $this->encodeSourceFiles($appLicenceInfo->installPath, $appLicenceInfo->domains, $dbg = true);
|
|
|
+ $this->encodeSourceFiles($installPath, $domains, $dbg = true);
|
|
|
// try {
|
|
|
// $this->encodeSourceFiles($appLicenceInfo->installPath, $appLicenceInfo->domains, $dbg = false);
|
|
|
// UI::alert('success', "OK");
|
|
@@ -363,47 +440,62 @@ jQuery(document).ready(function () {
|
|
|
$appLicenceInfo->installFolderName = "{$idLicence}_upgrade_SE_source_encrypted";
|
|
|
$appLicenceInfo->installPath = "{$installRootPath}/{$appLicenceInfo->installFolderName}";
|
|
|
//DBG::_(true, true, 'appLicenceInfo', $appLicenceInfo, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
- if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found.");
|
|
|
+ if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found."); // TODO: mv to validate
|
|
|
$appLicenceInfo->installFolderExists = file_exists("{$appLicenceInfo->installPath}/SE");
|
|
|
$appLicenceInfo->installFolderGitExists = file_exists("{$appLicenceInfo->installPath}/.git");
|
|
|
return $appLicenceInfo;
|
|
|
}
|
|
|
|
|
|
- public function generateApp($appLicenceInfo) {
|
|
|
+ public function validateAppLicenceInfo($appLicenceInfo) {
|
|
|
if (empty($appLicenceInfo->ID)) throw new Exception("Nie wybrano serwera/licencji.");
|
|
|
if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found");
|
|
|
- $installPath = $appLicenceInfo->installPath;
|
|
|
- if (empty($installPath)) throw new Exception("Install path not found");
|
|
|
+ if (empty($appLicenceInfo->installPath)) throw new Exception("Install path not found");
|
|
|
+ }
|
|
|
|
|
|
+ public function generateApp($installPath, $domains, $projects = []) {
|
|
|
$cmds = array();
|
|
|
$cmds[] = "if [ -d {$installPath} ] ; then rm -rf '{$installPath}'; fi";
|
|
|
$cmds[] = "mkdir {$installPath}";
|
|
|
- $cmds[] = "cd {$installPath} && git clone ssh://git@biuro.biall-net.pl:2222/plabudda/se.git .";
|
|
|
+ $cmds[] = "cd {$installPath} && git clone --depth 1 ssh://git@biuro.biall-net.pl:2222/plabudda/se.git .";
|
|
|
$cmds[] = "cd {$installPath} && echo `git show-ref --head|head -1|head -c 8` > SE/VERSION ";
|
|
|
- //echo'<pre>cmds: ';print_r($cmds);echo'</pre>';
|
|
|
foreach ($cmds as $cmd) {
|
|
|
- $out = ''; $ret = '';
|
|
|
- exec($cmd, $out, $ret);
|
|
|
- echo'<pre>cmd: '. $cmd . ': (return:'.$ret.')'."\n";print_r($out);echo'</pre>';
|
|
|
+ V::exec($cmd, $out, $ret);
|
|
|
+ DBG::nicePrint([ 'cmd' => $cmd, 'output' => $out ], "return: {$ret}");
|
|
|
}
|
|
|
- $this->_encodeSource($appLicenceInfo);
|
|
|
-// 1763: $exec='cd '.$installer_dir.' && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder -b-
|
|
|
-// '.INSTALL_SES_PROCESY_A::get_same_domains_for_install($h->SERVER_ADDRESS_SHORT).'
|
|
|
-// -r *.php
|
|
|
-// -x superedit-DB_PROCEDURES_CREATE.php
|
|
|
-// -x INI.php
|
|
|
-// -x .config_base_structure.php
|
|
|
-// ';
|
|
|
-//
|
|
|
-// INSTALL_SES_PROCESY_A::get_same_domains_for_install($h->SERVER_ADDRESS_SHORT):
|
|
|
-// $res2=DB::query("select SERVER_ADDRESS_SHORT from SES_PROCESY5_A where SERVER_ADDRESS_IP='".$h->SERVER_ADDRESS_IP."'");
|
|
|
-// while($h2=DB::fetch($res2)) {
|
|
|
-// $domain[]=' --domain '.$h2->SERVER_ADDRESS_SHORT;
|
|
|
-// ssh server@biuro.galeriaprzymorze.eu: PHP 5.5.20
|
|
|
-// ssh server@biuro.biall-net.pl
|
|
|
-// cd /Users/plabudda/procesy5-install-galeriaprzymorze.eu/
|
|
|
-// sudo chown -R server:admin SE/
|
|
|
-// /Applications/SourceGuardian.app/Contents/MacOS/sgencoder --phpversion 5.5 -b- --domain galeriaprzymorze.eu -r SE/*.php SE/se-lib/*.php SE/se-lib/*/*.php SE/se-lib/*/*/*.php SE/procesy/*.php SE/odt2xhtml/*.php -x superedit-DB_PROCEDURES_CREATE.php -x INI.php -x .config_base_structure.php
|
|
|
+
|
|
|
+ foreach ($projects as $projectName) {
|
|
|
+ $cmd = "ls -l SE/projects/{$projectName} | wc -l";
|
|
|
+ V::exec("cd {$installPath} && {$cmd}", $out, $ret);
|
|
|
+ DBG::nicePrint([ 'cmd' => $cmd, 'output' => $out ], "return: {$ret}");
|
|
|
+ if (!empty($out) && '0' !== trim($out[0])) {
|
|
|
+ // $cmd = "git submodule update SE/projects/{$projectName}";
|
|
|
+ $cmd = "cd SE/projects/{$projectName} && git reset --hard"; // revert encode source - checkout to last commit (need update)
|
|
|
+ V::exec("cd {$installPath} && {$cmd}", $out, $ret);
|
|
|
+ DBG::nicePrint([ 'cmd' => $cmd, 'output' => $out ], "return: {$ret}");
|
|
|
+ }
|
|
|
+ $cmd = "git submodule update --init SE/projects/{$projectName}"; // checkout to current commit
|
|
|
+ V::exec("cd {$installPath} && {$cmd}", $out, $ret);
|
|
|
+ DBG::nicePrint([ 'cmd' => $cmd, 'output' => $out ], "return: {$ret}");
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->_encodeSource($installPath, $domains);
|
|
|
+ // 1763: $exec='cd '.$installer_dir.' && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder -b-
|
|
|
+ // '.INSTALL_SES_PROCESY_A::get_same_domains_for_install($h->SERVER_ADDRESS_SHORT).'
|
|
|
+ // -r *.php
|
|
|
+ // -x superedit-DB_PROCEDURES_CREATE.php
|
|
|
+ // -x INI.php
|
|
|
+ // -x .config_base_structure.php
|
|
|
+ // ';
|
|
|
+ //
|
|
|
+ // INSTALL_SES_PROCESY_A::get_same_domains_for_install($h->SERVER_ADDRESS_SHORT):
|
|
|
+ // $res2=DB::query("select SERVER_ADDRESS_SHORT from SES_PROCESY5_A where SERVER_ADDRESS_IP='".$h->SERVER_ADDRESS_IP."'");
|
|
|
+ // while($h2=DB::fetch($res2)) {
|
|
|
+ // $domain[]=' --domain '.$h2->SERVER_ADDRESS_SHORT;
|
|
|
+ // ssh server@biuro.galeriaprzymorze.eu: PHP 5.5.20
|
|
|
+ // ssh server@biuro.biall-net.pl
|
|
|
+ // cd /Users/plabudda/procesy5-install-galeriaprzymorze.eu/
|
|
|
+ // sudo chown -R server:admin SE/
|
|
|
+ // /Applications/SourceGuardian.app/Contents/MacOS/sgencoder --phpversion 5.5 -b- --domain galeriaprzymorze.eu -r SE/*.php SE/se-lib/*.php SE/se-lib/*/*.php SE/se-lib/*/*/*.php SE/procesy/*.php SE/odt2xhtml/*.php -x superedit-DB_PROCEDURES_CREATE.php -x INI.php -x .config_base_structure.php
|
|
|
}
|
|
|
|
|
|
public function fetchActiveLicences() {
|
|
@@ -498,6 +590,7 @@ jQuery(document).ready(function () {
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
try {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
+ $this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
|
|
|
// TODO: if (59 ) => baratosz.sledz - na lokalnym kompie
|
|
|
// bn:~/$ scp -r SE server@192.168.61.153:~/se.encrypted.upgrade
|
|
@@ -525,22 +618,23 @@ jQuery(document).ready(function () {
|
|
|
if (V::get('DBG_REMOTE', '', $_GET)) {// DBG
|
|
|
$cmd = "echo ~";
|
|
|
V::exec("ssh {$sshArgs} {$sshHostUsr} '{$cmd}'", $out, $ret);
|
|
|
- DBG::_(true, true, "exec(ssh ... 'cmd'): {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ DBG::log([ 'cmd-remote' => $cmd, 'output' => $out ], 'array', "return: {$ret}");
|
|
|
V::execRemote($appLicenceInfo->mainServer, $appLicenceInfo->rootLogin, $appLicenceInfo->rootPassword, $cmd, $out, $ret, $appLicenceInfo->sshPort);
|
|
|
- DBG::_(true, true, "execRemote(cmd): {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ DBG::log([ 'cmd-remote' => $cmd, 'output' => $out ], 'array', "return: {$ret}");
|
|
|
V::execRootRemote($appLicenceInfo->mainServer, $appLicenceInfo->rootLogin, $appLicenceInfo->rootPassword, $cmd, $out, $ret, $appLicenceInfo->sshPort);
|
|
|
- DBG::_(true, true, "execRootRemote(cmd): {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ DBG::log([ 'cmd-remote' => $cmd, 'output' => $out ], 'array', "return: {$ret}");
|
|
|
}
|
|
|
|
|
|
$cmd = "echo ~";
|
|
|
V::exec("ssh {$sshArgs} {$sshHostUsr} '{$cmd}'", $out, $ret);
|
|
|
- DBG::_(true, true, "exec(ssh ... '{$cmd}') (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ DBG::log([ 'cmd-remote' => $cmd, 'output' => $out ], 'array', "return: {$ret}");
|
|
|
if (empty($out) || empty($out[0])) throw new Exception("Cannot fetch remote home dir");
|
|
|
return $out[0];
|
|
|
}
|
|
|
|
|
|
public function _sendToRemoteTestDir($appLicenceInfo) {
|
|
|
$cmd = ''; $out = ''; $ret = '';
|
|
|
+ $dryRunOnly = (V::get('dry-run', '', $_REQUEST)) ? "--dry-run" : "";
|
|
|
|
|
|
$this->_assertRsaKeyExists($appLicenceInfo);
|
|
|
|
|
@@ -554,23 +648,18 @@ jQuery(document).ready(function () {
|
|
|
-t, --times preserve times
|
|
|
--delete delete extraneous files from dest dirs
|
|
|
*/
|
|
|
- DBG::_(true, true, "remote home dir:", $this->_fetchRemoteHomeDir($appLicenceInfo), __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ $remoteDir = $this->_fetchRemoteHomeDir($appLicenceInfo);
|
|
|
+ DBG::log($remoteDir, 'array', "remote home dir:");
|
|
|
|
|
|
$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 \
|
|
|
+rsync --archive --times --delete --compress --one-file-system --omit-dir-times --no-g --no-perms {$dryRunOnly} \
|
|
|
--verbose {$rsyncSshPort} \
|
|
|
- --exclude='stuff/qgis__kyngchaos.com' \
|
|
|
- --exclude='stuff/qgis__kyngchaos.com/QGIS-2.14.3-1.dmg' \
|
|
|
- --exclude='stuff/postgis' \
|
|
|
- --exclude='stuff/postgis2' \
|
|
|
- --exclude='stuff/KindleGen_Mac_i386_v2_9' \
|
|
|
- --exclude='stuff/jdk-8u121-macosx-x64.dmg' \
|
|
|
- --exclude='stuff/jre-8u112-macosx-x64.tar.gz' \
|
|
|
- --exclude='stuff/jre-8u121-macosx-x64.dmg' \
|
|
|
+ --exclude='stuff' \
|
|
|
+ --exclude='stuff/**' \
|
|
|
--exclude='schema/default_db.instance.xml' \
|
|
|
--exclude='schema/default_db_xml_cache.public' \
|
|
|
--exclude='schema/default_db.instance.xml/**' \
|
|
@@ -580,9 +669,8 @@ ssh {$sshArgs} {$sshHostUsr} 'cp -r /Library/Server/Web/Data/Sites/Default/SE/co
|
|
|
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'
|
|
|
";
|
|
|
- // --dry-run \
|
|
|
V::exec($cmd, $out, $ret);
|
|
|
- DBG::_(true, true, "cmd: {$cmd} (return: {$ret})", $out, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ DBG::log([ 'cmd-remote' => $cmd, 'output' => $out ], 'array', "return: {$ret}");
|
|
|
if (0 !== $ret) throw new Exception("Cannot run remote command using rsa key! #{$ret}");
|
|
|
}
|
|
|
|
|
@@ -595,6 +683,7 @@ ssh {$sshArgs} {$sshHostUsr} 'ln -s ~/se.encrypted.upgrade/SE /Library/Server/We
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
try {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
+ $this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
$this->_upgradeRemoteFromTestDir($appLicenceInfo);
|
|
|
echo "Test online: ";
|
|
|
echo UI::h('a', ['target'=>"_blank", 'href'=>"https://{$appLicenceInfo->mainServer}/SE/"], "https://{$appLicenceInfo->mainServer}/SE/");
|
|
@@ -693,4 +782,31 @@ chmod 600 ~/.ssh/authorized_keys;
|
|
|
if (0 !== $ret) throw new Exception("Cannot run remote command using rsa key! #{$ret}");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public function newGenerateApp($appLicenceInfo) {
|
|
|
+ if (empty($appLicenceInfo->ID)) throw new Exception("Nie wybrano serwera/licencji.");
|
|
|
+ if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found");
|
|
|
+ $installPath = $appLicenceInfo->installPath;
|
|
|
+ if (empty($installPath)) throw new Exception("Install path not found");
|
|
|
+ $installPath .= '-p5';
|
|
|
+
|
|
|
+ $cmds = array();
|
|
|
+ $cmds[] = "if [ -d {$installPath} ] ; then rm -rf '{$installPath}'; fi";
|
|
|
+ $cmds[] = "mkdir {$installPath}";
|
|
|
+ $cmds[] = "cd {$installPath} && git clone --depth 1 ssh://git@biuro.biall-net.pl:2222/p5/p5.git .";
|
|
|
+ $cmds[] = "cd {$installPath} && echo `git show-ref --head|head -1|head -c 8` > SE/VERSION ";
|
|
|
+ // TODO: fetch from DB
|
|
|
+ {
|
|
|
+ $projectName = "bravecare";
|
|
|
+ $cmds[] = "cd {$installPath} && git submodule update --init SE/projects/{$projectName}";
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($cmds as $cmd) {
|
|
|
+ $out = ''; $ret = '';
|
|
|
+ exec($cmd, $out, $ret);
|
|
|
+ DBG::nicePrint([ 'cmd' => $cmd, 'output' => $out ], "return: {$ret}");
|
|
|
+ }
|
|
|
+ // $this->_encodeSource($appLicenceInfo->installPath, $appLicenceInfo->domains);
|
|
|
+ }
|
|
|
+
|
|
|
}
|