Git-Url:
http://git.frugalware.org/gitweb/gitweb.cgi?p=homepage-ng/.git;a=commitdiff;h=9f47c4d50f94e6ac99b59dbb962fb0d2585e55c5
commit 9f47c4d50f94e6ac99b59dbb962fb0d2585e55c5
Author: VMiklos <[EMAIL PROTECTED]>
Date: Wed Aug 8 11:19:46 2007 +0200
syncpkgd: redirect to the buildlogs page
also remove the old code
diff --git a/syncpkgd/config.php b/syncpkgd/config.php
deleted file mode 100644
index 72213ef..0000000
--- a/syncpkgd/config.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?
-$logdir="/var/log/syncpkg";
-$providers = array("factory" => "University of Debrecen",
- "helicon" => "TeleDataCast Kft.",
- "yugo" => "The Computer and Automation Research Institute, Hungarian
Academy of Sciences.");
-?>
diff --git a/syncpkgd/functions.php b/syncpkgd/functions.php
deleted file mode 100644
index de48e1a..0000000
--- a/syncpkgd/functions.php
+++ /dev/null
@@ -1,121 +0,0 @@
-<?
-function display_day($day, $param=null)
-{
- global $logdir;
-
- if($param==null)
- {
- if ($dir = @opendir($logdir . "/" . $day))
- {
- $packages = array();
- while ($file = readdir($dir))
- {
- if ($file != "." and $file != ".." and
substr($file, -4, 4) == ".log")
- {
- $pkg["date"] = date(DATE_RFC822,
filemtime("$logdir/$day/$file"));
- $pkg["url"] = "$day/$file";
- $pkg["fullname"] =
substr($file,0,strlen($file)-4);
- $pkg["exitcode"] =
!trim(file_get_contents("$logdir/$day/$file.exitcode"));
- $packages[] = $pkg;
- }
- }
- include("templates/day.php");
- }
- }
- else
- {
- // sanility checks
- if(strstr($param, "..") or strchr($param, "/"))
- die("nice try ;)");
- $log="$logdir/$day/$param";
- include("templates/log.php");
- }
-}
-
-function processtime($pid)
-{
- $fp = fopen("/proc/stat", "r");
- while(!feof($fp))
- {
- $str = fgets($fp);
- if(substr($str, 0, 5) == "btime")
- break;
- }
- fclose($fp);
- $btime = substr($str, 6);
-
- $pid = explode(" ", $pid);
- $str = file_get_contents("/proc/" . $pid[0] . "/stat");
- $ptime = explode(" ", $str);
- return($btime+$ptime[21]/100);
-}
-
-function query_hardware()
-{
- global $providers;
-
- $host = trim(`hostname`);
- $cpuinfo = file("/proc/cpuinfo");
- $cpuinfo = trim(substr($cpuinfo[4], 13));
- $provider = $providers[$host];
- $pp = popen("free", "r");
- fgets($pp);
- $meminfo = (int)(trim(substr(trim(substr(fgets($pp), 4)), 0, 10))/1000);
- pclose($pp);
- // TODO: disk space
-
- include("templates/hardware.php");
-}
-
-function list_days()
-{
- global $logdir, $providers;
-
- $host = trim(`hostname`) . "." . trim(`dnsdomainname`);
- $arch = trim(`uname -m`);
- $days = array();
- if ($dir = @opendir($logdir))
- {
- while ($file = readdir($dir))
- {
- if ($file != "." and $file != ".." and is_dir($logdir .
"/" . $file))
- {
- $days[] = $file;
- }
- }
- sort($days);
- }
- else
- {
- die('could not open $logdir, check your config.php!');
- }
- $syncpkgdpid = trim(`ps -C syncpkgd -o pid=`);
- if($syncpkgdpid!="")
- {
- $syncd = true;
- $syncddate = date(DATE_RFC822, processtime($syncpkgdpid));
- }
- else
- $syncd = false;
- $syncpkgpid = trim(`ps -C syncpkg -o pid=`);
- if($syncpkgpid!="")
- $sync = true;
- else
- $sync = false;
- if($sync)
- $syncdate = date(DATE_RFC822, processtime($syncpkgpid));
- else
- {
- $syncpkgpid = trim(`ps -C "sleep 2h" -o pid=`);
- $syncdate = date(DATE_RFC822, processtime($syncpkgpid)+7200);
- }
- $str = explode(" ", file_get_contents("/proc/loadavg"));
- $loadstat = $str[0];
- if(file_exists("/tmp/sync.pkg"))
- $buildstat = trim(file_get_contents("/tmp/sync.pkg"));
- else
- $buildstat = false;
-
- include("templates/main.php");
-}
-?>
diff --git a/syncpkgd/index.php b/syncpkgd/index.php
index 2383f43..0c91b4a 100644
--- a/syncpkgd/index.php
+++ b/syncpkgd/index.php
@@ -1,20 +1,4 @@
<?
-include("config.php");
-include("functions.php");
-
-$day = substr($_SERVER["PATH_INFO"], 1);
-if (strpos($_SERVER["PATH_INFO"], "/") !== false)
- $day = preg_replace('|^([^/]*)/.*|', '$1', $day);
-
-$param = preg_replace('|^[^/]*/([^/]*)|', '$1',
- substr($_SERVER["PATH_INFO"], 1));
-if($param==$day)
- $param=null;
-
-if ($day == "")
- list_days();
-else if($day == "hardware")
- query_hardware();
-else
- display_day($day, $param);
+$hostname = explode(".", $_SERVER['SERVER_NAME']);
+header("Location: http://frugalware.org/buildlogs/" . $hostname[0]);
?>
diff --git a/syncpkgd/templates/day.php b/syncpkgd/templates/day.php
deleted file mode 100644
index 9b04855..0000000
--- a/syncpkgd/templates/day.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html>
- <head>
- <title>Logs for <? print($day); ?></title>
- <meta http-equiv="Content-Type"
content="text/html;charset=utf-8" />
- </head>
- <body>
- <div>The following logs are available for <? print($day); ?>:<br />
- <? foreach($packages as $i)
- {
- print($i["date"] . ": <a href=\"" . $i["url"] . "\">" .
$i["fullname"] . "</a> " .
- ($i["exitcode"] ? "built" : "failed") . "<br />\n");
- } ?>
- </div>
- </body>
-</html>
diff --git a/syncpkgd/templates/hardware.php b/syncpkgd/templates/hardware.php
deleted file mode 100644
index 30557e6..0000000
--- a/syncpkgd/templates/hardware.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html>
- <head>
- <title>Hardware informations for <? print($host); ?></title>
- <meta http-equiv="Content-Type"
content="text/html;charset=utf-8" />
- </head>
- <body>
- <div>
- Network connection: <? print($provider); ?><br />
- CPU: <? print($cpuinfo); ?><br />
- Memory: <? print($meminfo); ?> MB<br />
- </div>
- </body>
-</html>
diff --git a/syncpkgd/templates/log.php b/syncpkgd/templates/log.php
deleted file mode 100644
index da883ee..0000000
--- a/syncpkgd/templates/log.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html>
- <head>
- <title>Buildlog</title>
- <meta http-equiv="Content-Type"
content="text/html;charset=utf-8" />
- </head>
- <body style="background-color: black; color: white">
- <pre>
-<?
-$search = array(
- '|\[1;1m(.*)\[1;0m|',
- '|\[1;31m(.*)\[1;0m|',
- '|\[1;32m(.*)\[1;0m|',
- '|\[1;33m(.*)\[1;0m|',
- '|\[1;34m(.*)\[1;0m|',
- '|\[1;36m(.*)\[1;0m|',
- '|&|');
-
-$replace = array(
- '<b>\1</b>',
- '<span style="color: red">\1</span>',
- '<span style="color: green">\1</span>',
- '<span style="color: yellow">\1</span>',
- '<span style="color: blue">\1</span>',
- '<span style="color: cyan">\1</span>',
- '&');
-
- $fp = fopen($log, "r");
- if($fp)
- {
- while (!feof($fp))
- {
- print(preg_replace($search, $replace, fgets($fp)));
- }
- fclose($fp);
- }
-?>
- </pre>
- </body>
-</html>
diff --git a/syncpkgd/templates/main.php b/syncpkgd/templates/main.php
deleted file mode 100644
index de62a2c..0000000
--- a/syncpkgd/templates/main.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html>
- <head>
- <title><? print("Welcome to $host!"); ?></title>
- <meta http-equiv="Content-Type"
content="text/html;charset=utf-8" />
- </head>
- <body>
- <div>Welcome to <? print("$host, the $arch"); ?> buildserver of
- <a href="http://frugalware.org">Frugalware Linux</a>.<br />
- The following buildlogs are available:<br /></div>
- <ul>
- <? foreach($days as $i)
- {
- print("<li><a href=\"$i\">$i</a></li>\n");
- } ?>
- </ul>
- <div>General statistics:<br />
- <? if($syncd)
- {
- print("The package builder daemon is running, started
on " .
- $syncddate . ".<br />\n");
- if($buildstat != false)
- print("Currently building the $buildstat
package.<br />\n");
- }
- else
- print("The package builder daemon is not running.<br
/>\n");
- if($sync)
- print("The package builder is running, started on " .
- $syncdate . ".<br />\n");
- else
- print("The package builder is sleeping, will be started
again on " .
- $syncdate . ".<br />\n");
- print("Avarage load for the past one minute: " . $loadstat .
"<br />\n");
- print("<a href=\"/hardware\">Hardware informations</a>.<br
/>\n");
- ?>
- </div>
- </body>
-</html>
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git