From e94422dfbe479216e5ddd6df3bdd83e066887a79 Mon Sep 17 00:00:00 2001 From: paulr Date: Mon, 1 Aug 2011 04:43:57 +1000 Subject: [PATCH] added some config jargon added an admin cron entry that does nothing yet --- bin/updateyumrepo.php | 10 ++++++++-- libglcas/lib.php | 14 ++++++++++++++ libglcas/web.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ plugins/admin.php | 8 ++++++++ www/index.php | 22 ++++++---------------- 5 files changed, 82 insertions(+), 18 deletions(-) diff --git a/bin/updateyumrepo.php b/bin/updateyumrepo.php index a4878fb..3cd0130 100644 --- a/bin/updateyumrepo.php +++ b/bin/updateyumrepo.php @@ -36,10 +36,11 @@ error_log("called with $url and $file"); $actionurl = "$url/repodata/repomd.xml"; $repomdxml = file_get_contents($actionurl); -file_put_contents("$file/repodata/repomd.xml", $repomdxml); +if(file_exists("$file/repodata/repomd.xml.new")) unlink("$file/repodata/repomd.xml.new"); +file_put_contents("$file/repodata/repomd.xml.new", $repomdxml); -$xml = simplexml_load_file("$file/repodata/repomd.xml"); +$xml = simplexml_load_file("$file/repodata/repomd.xml.new"); foreach($xml as $key => $var) { @@ -58,5 +59,10 @@ foreach($xml as $key => $var) { } unlink("$file/repodata/repoupdate.lock"); +if(file_exists("$file/repodata/repomd.xml")) { + unlink("$file/repodata/repomd.xml"); +} +rename("$file/repodata/repomd.xml.new", "$file/repodata/repomd.xml") +// TODO: check for outdated repodata files and delete ?> \ No newline at end of file diff --git a/libglcas/lib.php b/libglcas/lib.php index 05811a6..ef329be 100644 --- a/libglcas/lib.php +++ b/libglcas/lib.php @@ -46,4 +46,18 @@ function glcas_pluginLoader($path="") } } +function glcas_getWebConfigPath() +{ + global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL; + + // if you wish to add more places to find webconfig, add them here. + $configpath = false; + if(file_exists($WEB_ROOT_FS."/../var/glcas/webconfig")) return realpath($WEB_ROOT_FS."/../var/glcas/webconfig"); + if(file_exists("/var/lib/glcas/webconfig")) return realpath("/var/lib/glcas/webconfig"); + if(file_exists("/var/run/glcas/webconfig")) return realpath("/var/run/glcas/webconfig"); + + return $configpath; + //return false; +} + ?> \ No newline at end of file diff --git a/libglcas/web.php b/libglcas/web.php index 0bdd798..7ef4de6 100644 --- a/libglcas/web.php +++ b/libglcas/web.php @@ -118,5 +118,51 @@ function GLCASpageBuilder($bodyClass, $bodyFunction, $bodycontent=null, $title=" } +function glcas_startInstaller() +{ + global $WEB_ROOT_FS, $BASE_URL; + + $uid = posix_geteuid(); + $gid = posix_getegid(); + $uid_a = posix_getpwuid($uid); + $uid = $uid_a["name"]; + + $gid_a = posix_getgrgid($gid); + $gid = $gid_a["name"]; + error_log("user id is $uid, group id is $gid"); + +?> + +

Welcome to GLCAS

+Welcome to GLCAS, I cant find my configuration file so im assuming you installing me for the first time
+If this is not correct then we have a big problem that needs to be solved, i hope you have a backup of the old +config, cause that will make life easier.

+However, if this is the first time you have run this app, then all is good with the world. All I need right +now is a place where i can store my config. I search the following directories for the location of my +configuration (webconfig)
+
  • /var/run/glcas/ +
  • /var/lib/glcas/ +
  • /var/glcas/ +

    + +As root, you must now create one of these directories and change the ownership of the directory to the web owner. +(chown : the_path_you_choose).
    + +Now, tell me where you want me to create the webconfig file:
    +
    + + + + +
    + + + \ No newline at end of file diff --git a/plugins/admin.php b/plugins/admin.php index 4a99fb7..b746ebb 100644 --- a/plugins/admin.php +++ b/plugins/admin.php @@ -4,6 +4,8 @@ error_log("admin loaded"); global $URL_HANDLERS; $URL_HANDLERS["admin.*"] = "GLCASAdmin"; +global $CRON_CLASSES; +$CRON_CLASSES["GLCASAdmin"] = "GLCASAdmin"; class GLCASAdmin { function __construct($config) @@ -46,6 +48,12 @@ class GLCASAdmin { GLCASpageBuilder($this, "body"); } + function cron() + { + echo "ADMIN CRON: nothing to see here
    "; + // TODO: touch cronstamp file here + } + function body($url) { // for the main admin body, we hae the following components diff --git a/www/index.php b/www/index.php index aa5455c..bf3bc2c 100644 --- a/www/index.php +++ b/www/index.php @@ -22,24 +22,14 @@ glcas_pluginLoader(); $configpath = ""; // TODO: do this better -if(file_exists($WEB_ROOT_FS."/../var")) { - - // is it there? - if(file_exists($WEB_ROOT_FS."/../var/glcas/webconfig")) { - $configpath = realpath("$WEB_ROOT_FS/../var/glcas/webconfig"); - } else { - // if not, attempt to create - if(!file_exists($WEB_ROOT_FS."/../var/glcas")) { - mkdir($WEB_ROOT_FS."/../var/glcas"); - } - // success! - touch("$WEB_ROOT_FS/../var/glcas/webconfig"); - $configpath = realpath("$WEB_ROOT_FS/../var/glcas/webconfig"); - } -} - +$configpath = glcas_getWebConfigPath(); header("Accept-Ranges: bytes"); +if($configpath == false) { + glcas_startInstaller(); + return; +} + $glconfig = new GLCASConfig(); $glconfig->loadConfig($configpath); $webResponder = new GLCASWeb($glconfig); -- 1.7.0.4