summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php48
1 files changed, 40 insertions, 8 deletions
diff --git a/index.php b/index.php
index 4e1bf17..dfb8e04 100644
--- a/index.php
+++ b/index.php
@@ -5,18 +5,36 @@ require "cidr.php";
require "config.php";
function get_templates(&$server) {
+ global $DISTRIBUTION;
+
$templates = array();
foreach (glob("{$server['templates']}/*") as $ffn) {
$fn = basename($ffn);
$templates[$fn] = file_get_contents($ffn);
}
+ $templates['distrib_base_config'] = $templates["base-$DISTRIBUTION"];
+ $templates['distrib_package_config'] = $templates["packages-$DISTRIBUTION"];
+ $templates['distrib_pre_config'] = $templates["pre-$DISTRIBUTION"];
+ $templates['distrib_post_config'] = $templates["post-$DISTRIBUTION"];
+
+ $srvid = $server['srvid'];
+ $templates['node_base_config'] = $templates["base-$srvid"];
+ $templates['node_package_config'] = $templates["packages-$srvid"];
+ $templates['node_pre_config'] = $templates["pre-$srvid"];
+ $templates['node_post_config'] = $templates["post-$srvid"];
+
+ $templates['nd_base_config'] = $templates["base-$srvid-$DISTRIBUTION"];
+ $templates['nd_package_config'] = $templates["packages-$srvid-$DISTRIBUTION"];
+ $templates['nd_pre_config'] = $templates["pre-$srvid-$DISTRIBUTION"];
+ $templates['nd_post_config'] = $templates["post-$srvid-$DISTRIBUTION"];
+
if ((isset($server["disk2"]))&&($server["raid"] !== false)) {
$raid = $server["raid"];
if (preg_match("/RAID(\d+)/i", $raid, $m)) $raid = $m[1];
- $templates['storage_config'] = $templates["raid{$raid}"];
+ $templates['storage_config'] = $templates["storage-raid{$raid}"];
} else {
- $templates['storage_config'] = $templates['hdd'];
+ $templates['storage_config'] = $templates['storage-hdd'];
}
unset($server['templates']);
@@ -25,10 +43,12 @@ function get_templates(&$server) {
}
function get_server($srvid) {
+ global $DISTRIBUTION;
global $SERVER_LIST;
global $NETMASK;
$server = $SERVER_LIST[$srvid];
+ $server['srvid'] = $srvid;
if (!isset($server["fqdn"]))
$server["fqdn"] = "{$srvid}.{$server['domain']}";
@@ -49,6 +69,12 @@ function get_server($srvid) {
}
}
+ $server["distribution"] = $DISTRIBUTION;
+ if ($server["driverdisk"])
+ $server["skip_driverdisk"] = false;
+ else
+ $server["skip_driverdisk"] = true;
+
if ($server["ip"]) {
$server["skip_ip"] = false;
} else {
@@ -88,7 +114,7 @@ function find_mac($macs, $mac_header) {
if (!is_array($macs)) $macs = array($macs);
foreach ($macs as $mac) {
- if (preg_match("/$mac/", $mac_header))
+ if (preg_match("/$mac/i", $mac_header))
return true;
}
return false;
@@ -108,7 +134,7 @@ function find_server_by_header($http_header, $value) {
global $SERVER_LIST;
foreach ($SERVER_LIST as $srvid => $server) {
- if ((is_array($server["headers"]))&&(isset($server["headers"][$http_header]))) {
+ if ((array_key_exists("headers", $server))&&(is_array($server["headers"]))&&(array_key_exists($http_header, $server["headers"]))) {
$expected = $server["headers"][$http_header];
if (!is_array($expected)) $expected = array($expected);
foreach ($expected as $re) {
@@ -150,14 +176,20 @@ function find_server() {
$server = find_server();
-$f = fopen("/srv/www/htdocs/ands/logs/kickstart.log", "a+");
+$f = fopen("../logs/kickstart.log", "a+");
if ($f) {
- fprintf($f, "%s %s at %s\n", $_SERVER["REMOTE_ADDR"], ($server?$server["fqdn"]:"-"), date(DATE_ISO8601));
+ if (isset($_SERVER["HTTP_ANDS_REAL_IP"])) $remote = $_SERVER["HTTP_ANDS_REAL_IP"];
+ elseif (isset($_SERVER["HTTP_ANDS_FORWARDED_FOR"])) $remote = $_SERVER["HTTP_ANDS_FORWARDED_FOR"];
+ elseif (isset($_SERVER["HTTP_X_REAL_IP"])) $remote = $_SERVER["HTTP_X_REAL_IP"];
+ elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) $remote = $_SERVER["HTTP_X_FORWARDED_FOR"];
+ else $remote = $_SERVER["REMOTE_ADDR"];
+
+ fprintf($f, "%s %s at %s\n", $remote, ($server?$server["fqdn"]:"-"), date(DATE_ISO8601));
fclose($f);
}
if (!$server) {
- $f = fopen("/srv/www/htdocs/ands/logs/kickstart-new.log", "a+");
+ $f = fopen("../logs/kickstart-new.log", "a+");
if ($f) {
fwrite($f, "%s\n", date(DATE_ISO8601));
fwrite($f, print_r($_SERVER, true));
@@ -208,7 +240,7 @@ foreach ($DISTRIBUTIONS as $distrib) {
$ks = preg_replace($patterns, $values, $ks);
if ($VERBOSE) {
- $f = fopen("/srv/www/htdocs/ands/logs/kickstart-verbose.log", "a+");
+ $f = fopen("../logs/kickstart-verbose.log", "a+");
if ($f) {
fwrite($f, "-----------------------------------------------------\n");
fwrite($f, "%s\n", date(DATE_ISO8601));