config.php"); $continue = false; } else { $cwd = getcwd(); $config = str_replace("%privatePhpDirectory%", addslashes(realpath($cwd . "/" . $_POST["privatePhpDirectory"])), $config); $config = str_replace("%publicPhpDirectory%", addslashes(realpath($cwd)), $config); $config = str_replace("%nelSqlHostname%", addslashes($_POST["nelSqlHostname"]), $config); $config = str_replace("%nelSqlUsername%", addslashes($_POST["nelSqlUsername"]), $config); $config = str_replace("%nelSqlPassword%", addslashes($_POST["nelSqlPassword"]), $config); $config = str_replace("%nelDatabase%", addslashes($_POST["nelDatabase"]), $config); $config = str_replace("%toolDatabase%", addslashes($_POST["toolDatabase"]), $config); $config = str_replace("%amsSqlHostname%", addslashes($_POST["amsSqlHostname"]), $config); $config = str_replace("%amsSqlUsername%", addslashes($_POST["amsSqlUsername"]), $config); $config = str_replace("%amsSqlPassword%", addslashes($_POST["amsSqlPassword"]), $config); $config = str_replace("%amsDatabase%", addslashes($_POST["amsDatabase"]), $config); $config = str_replace("%amsLibDatabase%", addslashes($_POST["amsLibDatabase"]), $config); $config = str_replace("%nelSetupPassword%", addslashes($_POST["nelSetupPassword"]), $config); $config = str_replace("%domainDatabase%", addslashes($_POST["domainDatabase"]), $config); $config = str_replace("%nelDomainName%", addslashes($_POST["nelDomainName"]), $config); $config = str_replace("%nelSetupVersion%", addslashes($NEL_SETUP_VERSION), $config); $cryptKeyLength = 16; $cryptKey = str_replace("=", "", base64_encode(mcrypt_create_iv(ceil(0.75 * $cryptKeyLength), MCRYPT_DEV_URANDOM))); $cryptKeyIMAP = str_replace("=", "", base64_encode(mcrypt_create_iv(ceil(0.75 * $cryptKeyLength), MCRYPT_DEV_URANDOM))); $config = str_replace("%cryptKey%", addslashes($cryptKey), $config); $config = str_replace("%cryptKeyIMAP%", addslashes($cryptKeyIMAP), $config); if (file_put_contents("config.php", $config)) { printalert("success", "Generated config.php"); } else { printalert("danger", "Cannot write to config.php"); $continue = false; } } } if ($continue) { $configUser = file_get_contents($_POST["privatePhpDirectory"] . "/setup/config/config_user.php"); if (!$configUser) { printalert("danger", "Cannot read config_user.php"); $continue = false; } else { if (file_put_contents("config_user.php", $configUser)) { printalert("success", "Copied config_user.php"); } else { printalert("danger", "Cannot write to config.php"); $continue = false; } } } // Load config if ($continue) { try { require_once('config.php'); } catch (Exception $e) { printalert("danger", "Failed to include config.php"); $continue = false; } } require_once('database.php'); if ($roleSupport) { $continue = upgrade_support_databases($continue); } if ($roleService) { $continue = upgrade_service_databases($continue); } if ($roleDomain) { $continue = upgrade_domain_databases($continue); } if ($roleService) { // Create the default shard admin user if (!chdir("admin/")) { printalert("danger", "Cannot change to admin tools directory"); $continue = false; } if ($continue) { try { require_once('common.php'); } catch (Exception $e) { printalert("danger", "Failed to include NeL admin/common.php"); $continue = false; } } if ($continue) { try { require_once('functions_tool_administration.php'); } catch (Exception $e) { printalert("danger", "Failed to include NeL admin/functions_tool_administration.php"); $continue = false; } } if ($continue) { $adminGroup = 1; $result = tool_admin_users_add($_POST["toolsAdminUsername"], $_POST["toolsAdminPassword"], (string)$adminGroup, (string)1); if ($result == "") { printalert("success", "Added shard admin to NeL tools database"); } else { printalert("danger", "Failed to add shard admin to NeL tools database
" . htmlentities($result)); $continue = false; } } if (!chdir("../")) { printalert("danger", "Cannot change to public PHP root directory"); $continue = false; } } if ($roleSupport) { // Load AMS Library if ($continue) { try { require_once($AMS_LIB . '/libinclude.php'); } catch (Exception $e) { printalert("danger", "Failed to include AMS libinclude.php"); $continue = false; } } // Create AMS Admin user if ($continue) { $hashpass = crypt($_POST["amsAdminPassword"], Users::generateSALT()); $params = array( 'Login' => $_POST["amsAdminUsername"], 'Password' => $hashpass, 'Email' => "localhost@localhost", // TODO ); try { $user_id = WebUsers::createWebuser($params['Login'], $params['Password'],$params['Email']); $result = Webusers::createUser($params, $user_id); Users::createPermissions(array($params['Login'])); $dbl = new DBLayer("lib"); $dbl->execute("UPDATE ticket_user SET Permission = 3 WHERE TUserId = :user_id",array('user_id' => $user_id)); printalert("success", "AMS Admin account " . htmlentities($_POST["amsAdminUsername"]) . " created"); } catch (PDOException $e) { printalert("danger", "Failed to create AMS Admin account"); $continue = false; } } } if ($roleDomain) { // TODO: Register the domain with the nel database etc } if ($continue && $roleService) { if (file_put_contents("role_service", "1")) { printalert("success", "Service role successfully installed"); } else { printalert("danger", "Failed to flag installation success"); $continue = false; } } if ($continue && $roleSupport) { if (file_put_contents("role_support", "1")) { printalert("success", "Support role successfully installed"); } else { printalert("danger", "Failed to flag installation success"); $continue = false; } } if ($continue && $roleDomain) { if (file_put_contents("role_domain", "1")) { printalert("success", "Domain role successfully installed"); } else { printalert("danger", "Failed to flag installation success"); $continue = false; } } ?>

Continue

Roles

Basics (Paths relative to the public root directory)

Service Database (Used for NeL login, admin tools and domain databases)

Shard Admin

AMS (Account Management System)

Domain (Multiple domains require separate installations, as they may run different versions)

Database Only

The setup script is intended only for installation and upgrade of the domain specific database.

This will only configure the database for a single domain. It will not register the domain in the domain configuration.

The domain must be manually configured in the databases according to the procedure for configuring your server park with patchman, as it depends on several values defined within the patchman configuration.

It is required to use separate virtual hosts for multiple domains, in order to allow domain-specific script to run at different versions.

It is recommended, when planning to use multiple domains, to use a separate virtual host for each web service role.

There can be multiple instances of the domain role, there can only be one support and one service role setup.