database creation and shared folder creation moved to lurana-installer
This commit is contained in:
BIN
workflow/engine/bin/lurana-installer
Executable file
BIN
workflow/engine/bin/lurana-installer
Executable file
Binary file not shown.
@@ -164,8 +164,8 @@ class InstallerModule extends Controller
|
||||
'username' => $user,
|
||||
'password' => $pass,
|
||||
'unix_socket' => '',
|
||||
'charset' => 'utf8',
|
||||
'collation' => 'utf8_unicode_ci',
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_0900_ai_ci',
|
||||
'prefix' => '',
|
||||
'strict' => false,
|
||||
'engine' => 'InnoDB',
|
||||
@@ -646,20 +646,30 @@ class InstallerModule extends Controller
|
||||
$info->canRedirect = true;
|
||||
|
||||
$db_hostname = trim($_REQUEST['db_hostname']);
|
||||
|
||||
$db_port = trim($_REQUEST['db_port']);
|
||||
$db_port = $filter->validateInput($db_port);
|
||||
|
||||
$db_username = trim($_REQUEST['db_username']);
|
||||
$db_username = $filter->validateInput($db_username);
|
||||
|
||||
$db_password = urlencode(trim($_REQUEST['db_password']));
|
||||
$db_password = urldecode($filter->validateInput($db_password));
|
||||
|
||||
$wf = trim($_REQUEST['wfDatabase']);
|
||||
|
||||
$workspace = trim($_REQUEST['workspace']);
|
||||
|
||||
$pathShared = trim($_REQUEST['pathShared']);
|
||||
|
||||
$adminPassword = trim($_REQUEST['adminPassword']);
|
||||
$adminPassword = $filter->validateInput($adminPassword);
|
||||
|
||||
$adminUsername = trim($_REQUEST['adminUsername']);
|
||||
$adminUsername = $filter->validateInput($adminUsername);
|
||||
|
||||
$deleteDB = $_REQUEST['deleteDB'] === 'true';
|
||||
|
||||
$userLogged = isset($_REQUEST['userLogged']) ? $_REQUEST['userLogged'] === 'true' : false;
|
||||
$userLogged = $filter->validateInput($userLogged);
|
||||
|
||||
@@ -671,232 +681,86 @@ class InstallerModule extends Controller
|
||||
$this->installLog(G::LoadTranslation('ID_CREATING_WORKSPACE', SYS_LANG, [$workspace]));
|
||||
|
||||
try {
|
||||
self::setNewConnection(self::CONNECTION_TEST_INSTALL, $db_hostname, $db_username, $db_password, '', $db_port);
|
||||
$db_host = ($db_port != '' && $db_port != 3306) ? $db_hostname . ':' . $db_port : $db_hostname;
|
||||
|
||||
$this->installLog(G::LoadTranslation('ID_CONNECT_TO_SERVER', SYS_LANG, [$db_hostname, $db_port, $db_username]));
|
||||
$envFile = PATH_CONFIG . 'env.ini';
|
||||
|
||||
$sysConf = System::getSystemConfiguration($envFile);
|
||||
|
||||
$langUri = 'en';
|
||||
if (isset($sysConf['default_lang'])) {
|
||||
$langUri = $sysConf['default_lang'];
|
||||
}
|
||||
|
||||
$skinUri = 'lurana';
|
||||
if (isset($sysConf['default_skin'])) {
|
||||
$skinUri = $sysConf['default_skin'];
|
||||
}
|
||||
|
||||
$updatedConf['default_lang'] = $langUri;
|
||||
$updatedConf['default_skin'] = $skinUri;
|
||||
$info->uri = PATH_SEP . 'sys' . $_REQUEST['workspace'] . PATH_SEP . $langUri . PATH_SEP . $skinUri . PATH_SEP . 'login' . PATH_SEP . 'login';
|
||||
|
||||
$http = G::is_https() ? 'https' : 'http';
|
||||
$host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] !== '80' ? ':' . $_SERVER['SERVER_PORT'] : '');
|
||||
|
||||
$endpoint = sprintf(
|
||||
'%s://%s/sys%s/%s/%s/oauth2/grant',
|
||||
$http,
|
||||
$host,
|
||||
$workspace,
|
||||
$langUri,
|
||||
$skinUri
|
||||
);
|
||||
|
||||
|
||||
$pythonCliExecutablePath = PATH_HOME . 'engine/bin/lurana-installer';
|
||||
|
||||
$command = [
|
||||
escapeshellarg($pythonCliExecutablePath),
|
||||
'start',
|
||||
"--host=" . ($db_hostname . ':' . $db_port),
|
||||
"--workspace=" . $wf,
|
||||
"--user=" . $db_username,
|
||||
"--pass=" . $db_password,
|
||||
"--admin-username=" . $adminUsername,
|
||||
"--admin-password=" . $adminPassword,
|
||||
"--endpoint=" . escapeshellarg($endpoint),
|
||||
"--path-shared=" . escapeshellarg($pathShared),
|
||||
"--file-paths-installed=" . escapeshellarg(FILE_PATHS_INSTALLED),
|
||||
"--path-gulliver=" . escapeshellarg(PATH_GULLIVER),
|
||||
"--path-data=" . escapeshellarg(PATH_DATA)
|
||||
];
|
||||
|
||||
if ($deleteDB) {
|
||||
$query = sprintf('DROP DATABASE IF EXISTS %s', $wf);
|
||||
DB::connection(self::CONNECTION_TEST_INSTALL)->statement($query);
|
||||
$command[] = "--deleted-db";
|
||||
}
|
||||
|
||||
// CREATE databases wf_workflow
|
||||
DB::connection(self::CONNECTION_TEST_INSTALL)
|
||||
->statement("CREATE DATABASE IF NOT EXISTS $wf DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
|
||||
if ($userLogged) {
|
||||
$command[] = "--user-logged";
|
||||
}
|
||||
|
||||
self::setNewConnection(self::CONNECTION_INSTALL, $db_hostname, $db_username, $db_password, $wf, $db_port);
|
||||
|
||||
// CREATE users and GRANT Privileges
|
||||
$wf_workspace = $wf;
|
||||
$wfGrantUser = uniqid('wf_');
|
||||
if (!$userLogged) {
|
||||
$wfPass = G::generate_password(15);
|
||||
$this->setGrantPrivilegesMySQL($wfGrantUser, $wfPass, $wf, $db_hostname);
|
||||
$output = [];
|
||||
$return_var = 0;
|
||||
$command_string = implode(' ', $command);
|
||||
|
||||
$this->installLog("Executing Python CLI (Alembic Only):\n" . $command_string);
|
||||
exec($command_string, $output, $return_var);
|
||||
|
||||
if ($return_var !== 0) {
|
||||
$info->result = false;
|
||||
$error_message = "Python CLI for Alembic failed:\n" . implode("\n", $output);
|
||||
$info->message = $error_message;
|
||||
$this->installLog($error_message);
|
||||
} else {
|
||||
$wfPass = $db_password;
|
||||
$wf = $db_username;
|
||||
$wfGrantUser = $db_username;
|
||||
$this->installLog("Python CLI (Alembic Only) completed successfully.");
|
||||
}
|
||||
|
||||
// Generate the db.php file and folders
|
||||
$path_site = $pathShared . '/sites/' . $workspace . '/';
|
||||
|
||||
@mkdir($path_site, 0777, true);
|
||||
@mkdir($path_site . 'files/', 0777, true);
|
||||
@mkdir($path_site . 'mailTemplates/', 0777, true);
|
||||
@mkdir($path_site . 'public/', 0777, true);
|
||||
@mkdir($path_site . 'reports/', 0777, true);
|
||||
@mkdir($path_site . 'xmlForms', 0777, true);
|
||||
|
||||
$db_file = $path_site . 'db.php';
|
||||
$dbText = "<?php\n";
|
||||
$dbText .= sprintf("// Processmaker configuration\n");
|
||||
$dbText .= sprintf(" define ('DB_ADAPTER', '%s' );\n", 'mysql');
|
||||
$dbText .= sprintf(" define ('DB_HOST', '%s' );\n", $db_host);
|
||||
$dbText .= sprintf(" define ('DB_NAME', '%s' );\n", $wf_workspace);
|
||||
$dbText .= sprintf(" define ('DB_USER', '%s' );\n", $wfGrantUser);
|
||||
$dbText .= sprintf(" define ('DB_PASS', '%s' );\n", $wfPass);
|
||||
$dbText .= sprintf(" define ('DB_RBAC_HOST', '%s' );\n", $db_host);
|
||||
$dbText .= sprintf(" define ('DB_RBAC_NAME', '%s' );\n", $wf_workspace);
|
||||
$dbText .= sprintf(" define ('DB_RBAC_USER', '%s' );\n", $wfGrantUser);
|
||||
$dbText .= sprintf(" define ('DB_RBAC_PASS', '%s' );\n", $wfPass);
|
||||
$dbText .= sprintf(" define ('DB_REPORT_HOST', '%s' );\n", $db_host);
|
||||
$dbText .= sprintf(" define ('DB_REPORT_NAME', '%s' );\n", $wf_workspace);
|
||||
$dbText .= sprintf(" define ('DB_REPORT_USER', '%s' );\n", $wfGrantUser);
|
||||
$dbText .= sprintf(" define ('DB_REPORT_PASS', '%s' );\n", $wfPass);
|
||||
|
||||
$requestFlag = $_REQUEST['PARTNER_FLAG'] ?? null;
|
||||
if (defined('PARTNER_FLAG') || $requestFlag !== null) {
|
||||
$dbText .= "\n";
|
||||
$dbText .= " define ('PARTNER_FLAG', " . (defined('PARTNER_FLAG') ? PARTNER_FLAG : (isset($requestFlag) ? $requestFlag : 'false') ) . ");\n";
|
||||
if (!empty($this->systemName)) {
|
||||
$dbText .= " define ('SYSTEM_NAME', '" . $this->systemName . "');\n";
|
||||
}
|
||||
}
|
||||
|
||||
$this->installLog(G::LoadTranslation('ID_CREATING', SYS_LANG, [$db_file]));
|
||||
file_put_contents($db_file, $dbText);
|
||||
|
||||
//Generate the env.ini file
|
||||
$envIniFile = $path_site . 'env.ini';
|
||||
$content = 'system_utc_time_zone = 1' . "\n";
|
||||
|
||||
$this->installLog(G::LoadTranslation('ID_CREATING', SYS_LANG, [$envIniFile]));
|
||||
file_put_contents($envIniFile, $content);
|
||||
|
||||
//Generate the databases.php file
|
||||
$databases_file = $path_site . 'databases.php';
|
||||
$dbData = sprintf("\$dbAdapter = '%s';\n", 'mysql');
|
||||
$dbData .= sprintf("\$dbHost = '%s';\n", $db_host);
|
||||
$dbData .= sprintf("\$dbName = '%s';\n", $wf_workspace);
|
||||
$dbData .= sprintf("\$dbUser = '%s';\n", $wf);
|
||||
$dbData .= sprintf("\$dbPass = '%s';\n", $wfPass);
|
||||
$dbData .= sprintf("\$dbRbacHost = '%s';\n", $db_host);
|
||||
$dbData .= sprintf("\$dbRbacName = '%s';\n", $wf_workspace);
|
||||
$dbData .= sprintf("\$dbRbacUser = '%s';\n", $wf);
|
||||
$dbData .= sprintf("\$dbRbacPass = '%s';\n", $wfPass);
|
||||
$dbData .= sprintf("\$dbReportHost = '%s';\n", $db_host);
|
||||
$dbData .= sprintf("\$dbReportName = '%s';\n", $wf_workspace);
|
||||
$dbData .= sprintf("\$dbReportUser = '%s';\n", $wf);
|
||||
$dbData .= sprintf("\$dbReportPass = '%s';\n", $wfPass);
|
||||
$databasesText = str_replace('{dbData}', $dbData, @file_get_contents(PATH_HOME . 'engine/templates/installer/databases.tpl'));
|
||||
|
||||
$this->installLog(G::LoadTranslation('ID_CREATING', SYS_LANG, array($databases_file)));
|
||||
file_put_contents($databases_file, $databasesText);
|
||||
|
||||
$this->mysqlFileQuery(PATH_RBAC_HOME . 'engine/data/mysql/schema.sql');
|
||||
$this->mysqlFileQuery(PATH_RBAC_HOME . 'engine/data/mysql/insert.sql');
|
||||
$this->mysqlFileQuery(PATH_HOME . 'engine/data/mysql/schema.sql');
|
||||
$this->mysqlFileQuery(PATH_HOME . 'engine/data/mysql/insert.sql');
|
||||
|
||||
|
||||
if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {
|
||||
$this->setPartner();
|
||||
}
|
||||
|
||||
// Create the triggers
|
||||
if (file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql') &&
|
||||
file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql') &&
|
||||
file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql') &&
|
||||
file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql') &&
|
||||
file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerSubApplicationInsert.sql') &&
|
||||
file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql')) {
|
||||
DB::connection(self::CONNECTION_INSTALL)->unprepared(file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql'));
|
||||
DB::connection(self::CONNECTION_INSTALL)->unprepared(file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql'));
|
||||
DB::connection(self::CONNECTION_INSTALL)->unprepared(file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql'));
|
||||
DB::connection(self::CONNECTION_INSTALL)->unprepared(file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql'));
|
||||
DB::connection(self::CONNECTION_INSTALL)->unprepared(file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerSubApplicationInsert.sql'));
|
||||
DB::connection(self::CONNECTION_INSTALL)->unprepared(file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql'));
|
||||
|
||||
DB::connection(self::CONNECTION_INSTALL)
|
||||
->table('CONFIGURATION')
|
||||
->insert([
|
||||
'CFG_UID' => 'APP_CACHE_VIEW_ENGINE',
|
||||
'CFG_VALUE' => serialize(['LANG' => 'en', 'STATUS' => 'active'])
|
||||
]);
|
||||
|
||||
DB::connection(self::CONNECTION_INSTALL)
|
||||
->table('EMAIL_SERVER')
|
||||
->insert([
|
||||
'MESS_UID' => Common::generateUID(),
|
||||
'MESS_ENGINE' => 'MAIL'
|
||||
]);
|
||||
}
|
||||
|
||||
// Change admin user
|
||||
DB::connection(self::CONNECTION_INSTALL)
|
||||
->table('USERS')
|
||||
->where('USR_UID', '00000000000000000000000000000001')
|
||||
->update([
|
||||
'USR_USERNAME' => $adminUsername,
|
||||
'USR_LASTNAME' => $adminUsername,
|
||||
'USR_PASSWORD' => G::encryptHash($adminPassword)
|
||||
]);
|
||||
|
||||
DB::connection(self::CONNECTION_INSTALL)
|
||||
->table('RBAC_USERS')
|
||||
->where('USR_UID', '00000000000000000000000000000001')
|
||||
->update([
|
||||
'USR_USERNAME' => $adminUsername,
|
||||
'USR_LASTNAME' => $adminUsername,
|
||||
'USR_PASSWORD' => G::encryptHash($adminPassword)
|
||||
]);
|
||||
|
||||
// Write the paths_installed.php file (contains all the information configured so far)
|
||||
if (!file_exists(FILE_PATHS_INSTALLED)) {
|
||||
$sh = G::encryptOld(filemtime(PATH_GULLIVER . '/class.g.php'));
|
||||
$h = G::encrypt($db_host . $sh . $db_username . $sh . $db_password, $sh);
|
||||
$dbText = "<?php\n";
|
||||
$dbText .= sprintf(" define('PATH_C', '%s');\n", PATH_DATA . 'compiled/');
|
||||
$dbText .= sprintf(" define('HASH_INSTALLATION', '%s');\n", $h);
|
||||
$dbText .= sprintf(" define('SYSTEM_HASH', '%s');\n", $sh);
|
||||
$this->installLog(G::LoadTranslation('ID_CREATING', SYS_LANG, [FILE_PATHS_INSTALLED]));
|
||||
|
||||
Bootstrap::verifyPath(PATH_DATA . 'config', true);
|
||||
file_put_contents(FILE_PATHS_INSTALLED, $dbText);
|
||||
}
|
||||
|
||||
// for new env conf handling
|
||||
$envFile = PATH_CONFIG . 'env.ini';
|
||||
|
||||
// getting configuration from env.ini
|
||||
$sysConf = System::getSystemConfiguration($envFile);
|
||||
|
||||
$langUri = 'en';
|
||||
if (isset($sysConf['default_lang'])) {
|
||||
$langUri = $sysConf['default_lang'];
|
||||
}
|
||||
|
||||
$skinUri = 'lurana';
|
||||
if (isset($sysConf['default_skin'])) {
|
||||
$skinUri = $sysConf['default_skin'];
|
||||
}
|
||||
|
||||
$updatedConf['default_lang'] = $langUri;
|
||||
$updatedConf['default_skin'] = $skinUri;
|
||||
$info->uri = PATH_SEP . 'sys' . $_REQUEST['workspace'] . PATH_SEP . $langUri . PATH_SEP . $skinUri . PATH_SEP . 'login' . PATH_SEP . 'login';
|
||||
|
||||
//register PMDesigner Client
|
||||
$http = G::is_https() ? 'https' : 'http';
|
||||
$host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] !== '80' ? ':' . $_SERVER['SERVER_PORT'] : '');
|
||||
|
||||
$endpoint = sprintf(
|
||||
'%s://%s/sys%s/%s/%s/oauth2/grant',
|
||||
$http,
|
||||
$host,
|
||||
$workspace,
|
||||
$langUri,
|
||||
$skinUri
|
||||
);
|
||||
|
||||
// inserting the outh_client
|
||||
DB::connection(self::CONNECTION_INSTALL)
|
||||
->table('OAUTH_CLIENTS')
|
||||
->insert([
|
||||
'CLIENT_ID' => 'x-pm-local-client',
|
||||
'CLIENT_SECRET' => '179ad45c6ce2cb97cf1029e212046e81',
|
||||
'CLIENT_NAME' => 'PM Web Designer',
|
||||
'CLIENT_DESCRIPTION' => 'ProcessMaker Web Designer App',
|
||||
'CLIENT_WEBSITE' => 'www.processmaker.com',
|
||||
'REDIRECT_URI' => $endpoint,
|
||||
'USR_UID' => '00000000000000000000000000000001'
|
||||
]);
|
||||
|
||||
if (!empty(config('oauthClients.mobile.clientId'))) {
|
||||
DB::connection(self::CONNECTION_INSTALL)
|
||||
->table('OAUTH_CLIENTS')
|
||||
->insert([
|
||||
'CLIENT_ID' => config('oauthClients.mobile.clientId'),
|
||||
'CLIENT_SECRET' => config('oauthClients.mobile.clientSecret'),
|
||||
'CLIENT_NAME' => config('oauthClients.mobile.clientName'),
|
||||
'CLIENT_DESCRIPTION' => config('oauthClients.mobile.clientDescription'),
|
||||
'CLIENT_WEBSITE' => config('oauthClients.mobile.clientWebsite'),
|
||||
'REDIRECT_URI' => $endpoint,
|
||||
'USR_UID' => '00000000000000000000000000000001'
|
||||
]);
|
||||
}
|
||||
|
||||
$indexFileUpdated = true;
|
||||
if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {
|
||||
$this->buildParternExtras($adminUsername, $adminPassword, $_REQUEST['workspace'], $langUri, $skinUri);
|
||||
|
||||
@@ -309,7 +309,7 @@ if ($RBAC->userCanAccess('PM_SETUP') === 1) {
|
||||
$G_TMP_MENU->AddIdRawOption(
|
||||
'PM_REQUIREMENTS',
|
||||
'../setup/systemInfo',
|
||||
G::LoadTranslation('ID_PROCESSMAKER_REQUIREMENTS_CHECK'),
|
||||
G::LoadTranslation('ID_LURANASOFT_REQUIREMENTS_CHECK'),
|
||||
'',
|
||||
'',
|
||||
'settings'
|
||||
|
||||
Reference in New Issue
Block a user