|
|
@@ -138,6 +138,7 @@ jQuery(document).ready(function () {
|
|
|
try {
|
|
|
$this->validateAppLicenceInfo($appLicenceInfo);
|
|
|
$this->generateApp($appLicenceInfo->installPath, $appLicenceInfo->domains);
|
|
|
+ // TODO: $this->generateConfigs($appLicenceInfo->installPath, $appLicenceInfo->domains);
|
|
|
} catch (Exception $e) {
|
|
|
echo '</div></div>';// .container/ scroll
|
|
|
$this->_endWithException($e);
|
|
|
@@ -209,7 +210,15 @@ jQuery(document).ready(function () {
|
|
|
'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)"),
|
|
|
+ ], "aktualizuj werjsę"),
|
|
|
+ " (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=configGenerate&licence_id={$appLicenceInfo->ID}",
|
|
|
+ 'target' => "_blank",
|
|
|
+ 'class' => "btn btn-xs btn-default"
|
|
|
+ ], "generuj pliki konfiguracyjne"),
|
|
|
]),
|
|
|
UI::h('p', [ 'style' => "margin-left:20px" ], [
|
|
|
UI::h('a', [
|
|
|
@@ -255,6 +264,74 @@ jQuery(document).ready(function () {
|
|
|
UI::dol();
|
|
|
}
|
|
|
|
|
|
+ public function configGenerateAction() {
|
|
|
+ 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->configGenerate($appLicenceInfo->configPath, $appLicenceInfo->mainServer, $appLicenceInfo->rootPassword
|
|
|
+ , $appLicenceInfo->ldapUser, $appLicenceInfo->ldapPass, $appLicenceInfo->ldapBaseDN
|
|
|
+ );
|
|
|
+ UI::endContainer();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $this->_endWithException($e);
|
|
|
+ }
|
|
|
+ UI::dol();
|
|
|
+ }
|
|
|
+ public function configGenerate($configPath, $mainServer, $rootPassword, $ldapUser, $ldapPass, $ldapBaseDN) {
|
|
|
+ if (empty($configPath)) throw new Exception("Install path not found");
|
|
|
+ $cmds = array();
|
|
|
+ $cmds[] = "mkdir '{$configPath}'";
|
|
|
+ $REMOTE_FOLDER_ROOT = str_replace([ ".", "-" ], '_', $mainServer);
|
|
|
+ $cmds[] = ' echo "' . V::quoteBashEcho(
|
|
|
+ Config::generateDefaultDbConfigFile(
|
|
|
+ [
|
|
|
+ 'database' => $REMOTE_FOLDER_ROOT,
|
|
|
+ 'password' => $rootPassword,
|
|
|
+ ],
|
|
|
+ $outputFormat = 'inc'
|
|
|
+ )
|
|
|
+ ) . '" > ' . $configPath . '/.cnf--default_db-' . $mainServer . '.inc.php';
|
|
|
+ $cmds[] = ' echo "' . V::quoteBashEcho(
|
|
|
+ Config::generateDefaultDbConfigFile(
|
|
|
+ [
|
|
|
+ 'database' => $REMOTE_FOLDER_ROOT,
|
|
|
+ 'password' => $rootPassword,
|
|
|
+ ],
|
|
|
+ $outputFormat = 'inc'
|
|
|
+ )
|
|
|
+ ) . '" > ' . $configPath . '/.cnf--zasob_2-' . $mainServer . '.inc.php';
|
|
|
+ $cmds[] = ' echo "' . V::quoteBashEcho(
|
|
|
+ Config::generateDefaultLdapConfigFile(
|
|
|
+ [
|
|
|
+ 'user' => $ldapUser,
|
|
|
+ 'pass' => $ldapPass,
|
|
|
+ 'base_dn' => $ldapBaseDN,
|
|
|
+ ],
|
|
|
+ $outputFormat = 'inc'
|
|
|
+ )
|
|
|
+ ) . '" > ' . $configPath . '/.cnf--default_ldap-' . $mainServer . '.inc.php';
|
|
|
+
|
|
|
+ $hasError = false;
|
|
|
+ foreach ($cmds as $cmd) {
|
|
|
+ V::exec($cmd, $out, $ret);
|
|
|
+ if (0 !== $ret) $hasError = true;
|
|
|
+ DBG::nicePrint($out, "cmd: `{$cmd}` (return:{$ret})");
|
|
|
+ }
|
|
|
+ if (!$hasError) {
|
|
|
+ UI::alert('success', "OK");
|
|
|
+ } else {
|
|
|
+ UI::alert('danger', "errors");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function gitResetHardAction() {
|
|
|
session_write_close();
|
|
|
$args = array();
|
|
|
@@ -440,11 +517,16 @@ jQuery(document).ready(function () {
|
|
|
$appLicenceInfo->domains = $this->fetchDomainsByLicenceId($idLicence);
|
|
|
$installRootPath = '/Library/Server/Web/Data/Sites/Default/PLIKI/SES_PROCESY5_A';
|
|
|
$appLicenceInfo->installFolderName = "{$idLicence}_upgrade_SE_source_encrypted";
|
|
|
+ $appLicenceInfo->configFolderName = "{$idLicence}_upgrade_SE_config_encrypted";
|
|
|
$appLicenceInfo->installPath = "{$installRootPath}/{$appLicenceInfo->installFolderName}";
|
|
|
+ $appLicenceInfo->configPath = "{$installRootPath}/{$appLicenceInfo->configFolderName}";
|
|
|
//DBG::_(true, true, 'appLicenceInfo', $appLicenceInfo, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
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)) {
|
|
|
@@ -580,6 +662,9 @@ jQuery(document).ready(function () {
|
|
|
, g.ADMIN_USERNAME_PASSWD as rootPassword
|
|
|
, g.SSH_PORT as sshPort
|
|
|
, g.VERSION_GIT as project
|
|
|
+ , g.ADMIN_USERNAME_DIRECTORY as ldapUser
|
|
|
+ , g.ADMIN_USERNAME_PASSWD as ldapPass
|
|
|
+ , g.SERVER_ADDRESS_LDAP_DC as ldapBaseDN
|
|
|
from SES_PROCESY5_A g
|
|
|
where g.`ID`=:id_licence
|
|
|
-- TODO: and g.A_STATUS in('NORMAL','WAITING')
|