|
|
@@ -138,7 +138,7 @@ jQuery(document).ready(function () {
|
|
|
try {
|
|
|
$this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
$this->generateApp($appLicenceInfo->installPath, $appLicenceInfo->domains);
|
|
|
- // TODO: $this->generateConfigs($appLicenceInfo->installPath, $appLicenceInfo->domains);
|
|
|
+ // TODO: $this->configGenerate(...);
|
|
|
} catch (Exception $e) {
|
|
|
echo '</div></div>';// .container/ scroll
|
|
|
$this->_endWithException($e);
|
|
|
@@ -234,6 +234,13 @@ jQuery(document).ready(function () {
|
|
|
'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-left:20px" ], [
|
|
|
+ UI::h('a', [
|
|
|
+ 'href' => "index.php?_route=Install&_task=generateUpgradeScript&licence_id={$appLicenceInfo->ID}",
|
|
|
+ 'target' => "_blank",
|
|
|
+ 'class' => "btn btn-xs btn-warning"
|
|
|
+ ], "generuj skrypt aktualizacji"),
|
|
|
+ ]),
|
|
|
UI::h('p', [ 'style' => "margin-top:30px" ], [
|
|
|
"Test online: ",
|
|
|
UI::h('a', [
|
|
|
@@ -264,6 +271,70 @@ jQuery(document).ready(function () {
|
|
|
UI::dol();
|
|
|
}
|
|
|
|
|
|
+ public function generateUpgradeScriptAction() {
|
|
|
+ session_write_close();
|
|
|
+ $args = array();
|
|
|
+ $args['licence_id'] = V::get('licence_id', 0, $_REQUEST, 'int');
|
|
|
+ UI::gora();
|
|
|
+ UI::menu();
|
|
|
+ //$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
+ try {
|
|
|
+ $appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
+ $this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
+
|
|
|
+ UI::startContainer();
|
|
|
+ $this->generateUpgradeScript($appLicenceInfo);
|
|
|
+ UI::endContainer();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $this->_endWithException($e);
|
|
|
+ }
|
|
|
+ UI::dol();
|
|
|
+ }
|
|
|
+ public function generateUpgradeScript($appLicenceInfo) {
|
|
|
+ $cmds = [];
|
|
|
+
|
|
|
+ //
|
|
|
+ $cmds[] = "# TODO: commands from remote upgrade";
|
|
|
+ $cmds[] = "# cp -r {UPDATE_ZIP_PATH_SE} {public_html}/se.encrypted.upgrade";
|
|
|
+ $cmds[] = "# rm -rf {public_html}/se.encrypted.upgrade";
|
|
|
+ // '[ ! -d ~/se.encrypted.upgrade ] && mkdir ~/se.encrypted.upgrade || echo 1';
|
|
|
+ // 'rm -rf ~/se.encrypted.upgrade/SE';
|
|
|
+ // 'cp -r /Library/Server/Web/Data/Sites/Default/SE ~/se.encrypted.upgrade/SE';
|
|
|
+ // 'rm -rf ~/se.encrypted.upgrade/SE/config';
|
|
|
+ // rsync --archive --times --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/;
|
|
|
+ // 'cp -r /Library/Server/Web/Data/Sites/Default/SE/config ~/se.encrypted.upgrade/SE/';
|
|
|
+ // 'rm /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade'
|
|
|
+ // '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}:
|
|
|
+ // 'mv ~/.config_base_structure.php /Library/Server/Web/Data/Sites/Default/se.encrypted.upgrade/config'
|
|
|
+
|
|
|
+
|
|
|
+ // config
|
|
|
+ // $cmds[] = "TODO cp -r from {SE}/config";
|
|
|
+ $cmds[] = "rm ~/se.encrypted.upgrade/.*.inc.php";
|
|
|
+ $cmds[] = "cp -r {UPDATE_ZIP_PATH_SE}/.*.inc.php ~/se.encrypted.upgrade/";
|
|
|
+ // $domainList = INSTALL_SES_PROCESY_A::fetch_same_domains_for_install($SERVER_ADDRESS_SHORT, $SERVER_ADDRESS);// [ $SERVER_ADDRESS, localhost, 127.0.0.1, ... ]
|
|
|
+ DBG::nicePrint($appLicenceInfo, '$appLicenceInfo');
|
|
|
+ $mainDomain = $appLicenceInfo->mainServer;
|
|
|
+ $additionalDomains = array_filter($appLicenceInfo->domains, function ($domain) use ($mainDomain) {
|
|
|
+ return ($mainDomain != $domain);
|
|
|
+ });
|
|
|
+ foreach ($additionalDomains as $domain) {
|
|
|
+ if ('localhost' == $domain) continue;// skip localhost (127.0.0.1)
|
|
|
+ $cmds[] = ' test -f /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--default_db-'.$domain.'.ini.php || ln -s /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--default_db-'.$mainDomain.'.inc.php /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--default_db-'.$domain.'.inc.php';
|
|
|
+ $cmds[] = ' test -f /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--zasob_2-'.$domain.'.inc.php || ln -s /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--zasob_2-'.$mainDomain.'.inc.php /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--zasob_2-'.$domain.'.inc.php';
|
|
|
+ // $cmds[] = ' test -f /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--import_db-'.$domain.'.inc.php || ln -s /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--import_db-'.$mainDomain.'.inc.php /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--import_db-'.$domain.'.inc.php';
|
|
|
+ $cmds[] = ' test -f /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--folders-'.$domain.'.inc.php || ln -s /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--folders-'.$mainDomain.'.inc.php /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--folders-'.$domain.'.inc.php';
|
|
|
+ $cmds[] = ' test -f /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--default_ldap-'.$domain.'.inc.php || ln -s /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--default_ldap-'.$mainDomain.'.inc.php /Library/Server/Web/Data/Sites/Default/SE/config/.cnf--default_ldap-'.$domain.'.inc.php';
|
|
|
+ }
|
|
|
+
|
|
|
+ DBG::nicePrint($cmds, "\$cmds");
|
|
|
+ }
|
|
|
+
|
|
|
public function configGenerateAction() {
|
|
|
session_write_close();
|
|
|
$args = array();
|
|
|
@@ -276,7 +347,7 @@ jQuery(document).ready(function () {
|
|
|
$this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
|
|
|
UI::startContainer();
|
|
|
- $this->configGenerate($appLicenceInfo->configPath, $appLicenceInfo->mainServer, $appLicenceInfo->rootPassword
|
|
|
+ $this->configGenerate($appLicenceInfo->configPath, $appLicenceInfo->mainServer, $appLicenceInfo->domains, $appLicenceInfo->rootPassword
|
|
|
, $appLicenceInfo->ldapUser, $appLicenceInfo->ldapPass, $appLicenceInfo->ldapBaseDN
|
|
|
);
|
|
|
UI::endContainer();
|
|
|
@@ -285,10 +356,11 @@ jQuery(document).ready(function () {
|
|
|
}
|
|
|
UI::dol();
|
|
|
}
|
|
|
- public function configGenerate($configPath, $mainServer, $rootPassword, $ldapUser, $ldapPass, $ldapBaseDN) {
|
|
|
+ public function configGenerate($configPath, $mainServer, $domains, $rootPassword, $ldapUser, $ldapPass, $ldapBaseDN) {
|
|
|
if (empty($configPath)) throw new Exception("Install path not found");
|
|
|
$cmds = array();
|
|
|
- $cmds[] = "mkdir '{$configPath}'";
|
|
|
+ $cmds[] = "if [ -d {$configPath} ] ; then rm -rf '{$configPath}'; fi";
|
|
|
+ $cmds[] = "mkdir {$configPath}";
|
|
|
$REMOTE_FOLDER_ROOT = str_replace([ ".", "-" ], '_', $mainServer);
|
|
|
$cmds[] = ' echo "' . V::quoteBashEcho(
|
|
|
Config::generateDefaultDbConfigFile(
|
|
|
@@ -318,6 +390,19 @@ jQuery(document).ready(function () {
|
|
|
$outputFormat = 'inc'
|
|
|
)
|
|
|
) . '" > ' . $configPath . '/.cnf--default_ldap-' . $mainServer . '.inc.php';
|
|
|
+ // TODO: create .cnf--default_ldap-{$mainServer}.inc.php
|
|
|
+
|
|
|
+ $additionalDomains = array_filter($domains, function ($domain) use ($mainServer) {
|
|
|
+ return ($mainServer != $domain);
|
|
|
+ });
|
|
|
+ foreach ($additionalDomains as $domain) {
|
|
|
+ if ('localhost' == $domain) continue;// skip localhost (127.0.0.1)
|
|
|
+ $cmds[] = "cd {$configPath} && ln -s .cnf--default_db-{$mainServer}.inc.php .cnf--default_db-{$domain}.inc.php";
|
|
|
+ $cmds[] = "cd {$configPath} && ln -s .cnf--zasob_2-{$mainServer}.inc.php .cnf--zasob_2-{$domain}.inc.php";
|
|
|
+ // $cmds[] = "cd {$configPath} && ln -s .cnf--import_db-{$mainServer}.inc.php .cnf--import_db-{$domain}.inc.php";
|
|
|
+ // TODO: $cmds[] = "cd {$configPath} && ln -s .cnf--folders-{$mainServer}.inc.php .cnf--folders-{$domain}.inc.php";
|
|
|
+ $cmds[] = "cd {$configPath} && ln -s .cnf--default_ldap-{$mainServer}.inc.php .cnf--default_ldap-{$domain}.inc.php";
|
|
|
+ }
|
|
|
|
|
|
$hasError = false;
|
|
|
foreach ($cmds as $cmd) {
|
|
|
@@ -463,7 +548,7 @@ jQuery(document).ready(function () {
|
|
|
if (empty($freeEncodePhpFiles)) throw new Exception("No php files to encode");
|
|
|
|
|
|
$cmdTempl = "cd {$installPath}/SE && /Applications/SourceGuardian.app/Contents/MacOS/sgencoder {$phpVersionsForSgencoder} -b- ";
|
|
|
- $cmdDomainEncodeDomainsTempl = " --domain " . implode(" --domain ", array_merge($domains, ['localhost']));
|
|
|
+ $cmdDomainEncodeDomainsTempl = " --domain " . implode(" --domain ", $domains);
|
|
|
$cmdDomainEncodeFilesTempl = " " . implode(" ", $domainEncodePhpFiles);
|
|
|
$cmdFreeEncodeFilesTempl = " " . implode(" ", $freeEncodePhpFiles);
|
|
|
|
|
|
@@ -581,9 +666,6 @@ jQuery(document).ready(function () {
|
|
|
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");
|
|
|
- // 'user' => $ADMIN_USERNAME_DIRECTORY,
|
|
|
- // 'pass' => $ADMIN_USERNAME_PASSWD,
|
|
|
- // 'base_dn' => $SERVER_ADDRESS_LDAP_DC,
|
|
|
|
|
|
$appLicenceInfo->projects = []; // TODO: get from db
|
|
|
if (!empty($appLicenceInfo->projects)) {
|
|
|
@@ -639,6 +721,11 @@ jQuery(document).ready(function () {
|
|
|
}
|
|
|
|
|
|
$this->_encodeSource($installPath, $domains);
|
|
|
+
|
|
|
+ $this->configGenerate($appLicenceInfo->configPath, $appLicenceInfo->mainServer, $appLicenceInfo->domains, $appLicenceInfo->rootPassword
|
|
|
+ , $appLicenceInfo->ldapUser, $appLicenceInfo->ldapPass, $appLicenceInfo->ldapBaseDN
|
|
|
+ );
|
|
|
+ $this->_encodeConfigs($appLicenceInfo->configPath);
|
|
|
// 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
|
|
|
@@ -681,7 +768,7 @@ jQuery(document).ready(function () {
|
|
|
public function fetchDomainsByLicenceId($licenceId) {
|
|
|
$domains = array();
|
|
|
$sql = "
|
|
|
- select g.`SERVER_ADDRESS_SHORT`, g.`SERVER_ADDRESS`
|
|
|
+ select g.ID, g.`SERVER_ADDRESS_SHORT`, g.`SERVER_ADDRESS`
|
|
|
from `SES_PROCESY5_A` g
|
|
|
where g.`SERVER_ADDRESS_IP`=(select l.`SERVER_ADDRESS_IP`
|
|
|
from `SES_PROCESY5_A` l
|
|
|
@@ -691,6 +778,10 @@ jQuery(document).ready(function () {
|
|
|
-- TODO: and g.`A_STATUS` in('NORMAL','WAITING')
|
|
|
";
|
|
|
$rows = DB::getPDO()->fetchAll($sql);
|
|
|
+ $mainDomain = null;
|
|
|
+ foreach ($rows as $row) {
|
|
|
+ if ($licenceId == $row['ID']) $mainDomain = $row['SERVER_ADDRESS'];
|
|
|
+ }
|
|
|
foreach ($rows as $row) {
|
|
|
$r = (object)$row;
|
|
|
$domains[] = $r->SERVER_ADDRESS_SHORT;
|
|
|
@@ -698,6 +789,13 @@ jQuery(document).ready(function () {
|
|
|
$domains[] = $r->SERVER_ADDRESS;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if ($mainDomain && (!preg_match('/^(.*)\.procesy5\.pl$/', $mainDomain))) {
|
|
|
+ $subDomainP5 = '' . $mainDomain . '.procesy5.pl';
|
|
|
+ if (!in_array($subDomainP5, $domainList)) $domains[] = $subDomainP5;
|
|
|
+ }
|
|
|
+ $domains[] = '127.0.0.1';
|
|
|
+ $domains[] = 'localhost';
|
|
|
return $domains;
|
|
|
}
|
|
|
|