set(Services::SESSION_STORAGE, $sessionStorage); $session = new Session($sessionStorage); $session->start(); ServiceContainer::getContainer()->set(Services::SESSION, $session); $cliConfig = Yaml::parseFile(realpath(__DIR__ . '/cli_install_config.yaml')); if ($cliConfig['license']['agree'] != 'y') { $licenseFilePath = realpath(__DIR__ . '/../LICENSE'); echo "For continue installation need to accept OrangeHRM license agreement. It is available in '$licenseFilePath'."; die; } echo "Agreed to license from config file\n"; $dbType = $cliConfig['database']['isExistingDatabase'] == 'n' ? AppSetupUtility::INSTALLATION_DB_TYPE_NEW : AppSetupUtility::INSTALLATION_DB_TYPE_EXISTING; $dbHost = $cliConfig['database']['hostName']; $dbPort = $cliConfig['database']['hostPort']; $dbUser = $cliConfig['database']['privilegedDatabaseUser']; $dbPassword = $cliConfig['database']['privilegedDatabasePassword']; $dbName = $cliConfig['database']['databaseName']; $useSameDbUserForOrangeHRM = $cliConfig['database']['useSameDbUserForOrangeHRM'] == 'y'; $enableDataEncryption = $cliConfig['database']['enableDataEncryption'] == 'y'; $organizationName = $cliConfig['organization']['name']; $countryCode = $cliConfig['organization']['country']; $adminUsername = $cliConfig['admin']['adminUserName']; $adminPassword = $cliConfig['admin']['adminPassword']; $firstName = $cliConfig['admin']['adminEmployeeFirstName']; $lastName = $cliConfig['admin']['adminEmployeeLastName']; $email = $cliConfig['admin']['workEmail']; $contact = $cliConfig['admin']['contactNumber']; if ($dbType === AppSetupUtility::INSTALLATION_DB_TYPE_NEW) { $ohrmDbUser = $dbUser; $ohrmDbPassword = $dbPassword; if (!$useSameDbUserForOrangeHRM) { $ohrmDbUser = $cliConfig['database']['orangehrmDatabaseUser']; $ohrmDbPassword = $cliConfig['database']['orangehrmDatabasePassword']; } StateContainer::getInstance()->storeDbInfo( $dbHost, $dbPort, new UserCredential($dbUser, $dbPassword), $dbName, new UserCredential($ohrmDbUser, $ohrmDbPassword) ); StateContainer::getInstance()->setDbType(AppSetupUtility::INSTALLATION_DB_TYPE_NEW); } else { // `existing` database StateContainer::getInstance()->storeDbInfo( $dbHost, $dbPort, new UserCredential($dbUser, $dbPassword), $dbName ); StateContainer::getInstance()->setDbType(AppSetupUtility::INSTALLATION_DB_TYPE_EXISTING); } // Instance data StateContainer::getInstance()->storeInstanceData($organizationName, $countryCode, null, null); // Admin user StateContainer::getInstance()->storeAdminUserData( $firstName, $lastName, $email, new UserCredential($adminUsername, $adminPassword), $contact ); StateContainer::getInstance()->storeRegConsent($cliConfig['admin']['registrationConsent']); $appSetupUtility = new AppSetupUtility(); echo "Database creation\n"; $appSetupUtility->createDatabase(); echo "Applying database changes\n"; $appSetupUtility->runMigrations('3.3.3', Config::PRODUCT_VERSION); echo "Instance creation & Admin user creation\n"; $appSetupUtility->insertSystemConfiguration(); echo "Create OrangeHRM database user\n"; $appSetupUtility->createDBUser(); echo "Creating configuration files\n"; $appSetupUtility->writeConfFile(); if ($enableDataEncryption) { $appSetupUtility->writeKeyFile(); } echo "Done\n";