diff --git a/code/web/public_php/ams/index.php b/code/web/public_php/ams/index.php
index 1ab707e79..de2e93235 100644
--- a/code/web/public_php/ams/index.php
+++ b/code/web/public_php/ams/index.php
@@ -18,7 +18,7 @@ ini_set( 'display_errors', 'on' );
class SystemExit extends Exception {}
try {
-if (!file_exists( '../config.php')) {
+if (!file_exists('../role_support')) {
header("Cache-Control: max-age=1");
header('Location: ../setup', true, 303);
throw new SystemExit();
diff --git a/code/web/public_php/setup/database.php b/code/web/public_php/setup/database.php
new file mode 100644
index 000000000..421efa301
--- /dev/null
+++ b/code/web/public_php/setup/database.php
@@ -0,0 +1,108 @@
+" . $name . " SQL server: " . mysqli_connect_error());
+ $con = null;
+ } else {
+ printalert("success", "Connected to the " . $name . " SQL server");
+ }
+ }
+
+ return $con;
+}
+
+function disconnect_database($con, $name) {
+ if ($con) {
+ mysqli_close($con);
+ printalert("info", "Disconnected from the " . $name . " SQL server");
+ }
+}
+
+function upgrade_service_databases($continue_r) {
+ $continue = $continue_r;
+
+ $con = null;
+ $con = connect_database($continue, "shard");
+ $continue = ($con != null);
+ if ($continue && get_db_version("shard") < 1) {
+ $continue = update_database_structure($continue, $con, "nel_00001.sql");
+ $continue = set_db_version($continue, "shard", 1);
+ }
+ disconnect_database($con, "shard");
+
+ $con = null;
+ $con = connect_database($continue, "tool");
+ $continue = ($con != null);
+ if ($continue && get_db_version("tool") < 1) {
+ $continue = update_database_structure($continue, $con, "nel_tool_00001.sql");
+ $continue = set_db_version($continue, "tool", 1);
+ }
+ disconnect_database($con, "tool");
+
+ return $continue;
+}
+
+function upgrade_support_databases($continue_r) {
+ $continue = $continue_r;
+
+ $con = null;
+ $con = connect_database($continue, "web");
+ $continue = ($con != null);
+ if ($continue && get_db_version("web") < 1) {
+ $continue = update_database_structure($continue, $con, "nel_ams_00001.sql");
+ $continue = set_db_version($continue, "web", 1);
+ }
+ disconnect_database($con, "web");
+
+ $con = null;
+ $con = connect_database($continue, "lib");
+ $continue = ($con != null);
+ if ($continue && get_db_version("lib") < 1) {
+ $continue = update_database_structure($continue, $con, "nel_ams_lib_00001.sql");
+ $continue = set_db_version($continue, "lib", 1);
+ }
+ if ($continue && get_db_version("lib") < 2) {
+ $continue = update_database_structure($continue, $con, "nel_ams_lib_00002.sql");
+ $continue = set_db_version($continue, "lib", 2);
+ }
+ disconnect_database($con, "lib");
+
+ return $continue;
+}
+
+function upgrade_domain_databases($continue_r) {
+ $continue = $continue_r;
+
+ return $continue;
+}
+
+?>
diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php
index 8fdade460..cc98b9432 100644
--- a/code/web/public_php/setup/install.php
+++ b/code/web/public_php/setup/install.php
@@ -75,11 +75,9 @@ include('header.php');
if ($roleService) {
// Create NeL database
$continue = create_use_database($continue, $con, $_POST["nelDatabase"]);
- $continue = update_database_structure($continue, $con, "nel_00001.sql");
// Create NeL Tools database
$continue = create_use_database($continue, $con, $_POST["toolDatabase"]);
- $continue = update_database_structure($continue, $con, "nel_tool_00001.sql");
}
if ($con) {
@@ -101,12 +99,9 @@ include('header.php');
// Create AMS database
$continue = create_use_database($continue, $con, $_POST["amsDatabase"]);
- $continue = update_database_structure($continue, $con, "nel_ams_00001.sql");
// Create AMS Library database
$continue = create_use_database($continue, $con, $_POST["amsLibDatabase"]);
- $continue = update_database_structure($continue, $con, "nel_ams_lib_00001.sql");
- $continue = update_database_structure($continue, $con, "nel_ams_lib_00002.sql");
if ($con) {
mysqli_close($con);
@@ -158,6 +153,20 @@ include('header.php');
}
}
+ 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 ($roleSupport) {
// Load AMS Library
if ($continue) {
@@ -191,7 +200,7 @@ include('header.php');
}
}
- if ($continue && $roleSupport) {
+ if ($continue && $roleService) {
if (file_put_contents("role_service", "1")) {
printalert("success", "Service role successfully installed");
} else {