}
+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
}
}
-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
}
+function glcas_isRemoteDir($url)
+{
+ file_get_contents($url);
+ //error_log("did file_get_contents on $url");
+ foreach($http_response_header as $key => $val) {
+ //error_log("got header of $key for $val");
+ if(preg_match("/.*Location:.*/", $val)) {
+ //error_log("in details apt got location as $val from $url");
+ $realloc = preg_replace("/.*: /", "", $val);
+ $urlwithslash = $url."/";
+ //echo "<br>in comp with<br>$urlwithslash<br>$realloc<br>";
+ if(strcasecmp($realloc,$urlwithslash)==0) {
+ //error_log("I believe $realloc is a directory redir for $url");
+ return true;
+ } else {
+ //error_log("I dont believe $realloc is a directory redir for $url");
+ }
+ }
+ }
+ return false;
+}
+
function glcas_startInstaller()
{
global $WEB_ROOT_FS, $BASE_URL;
{
echo "ADMIN CRON: nothing to see here<br>";
// TODO: touch cronstamp file here
+
+ // make a backup of the config.. but.. errr. how to tell if theres an old backup?
+ // backups will occur... weekly and be called $configpath.DDMMYYYY
+ $configpath = glcas_getWebConfigPath();
+ $basepath = dirname($configpath);
+ echo "ADMIN CRON: backing up config, $configpath, $basepath<br>";
+ $nowtime = time();
+ $oneday = 3600 * 24; // 1 hour in seconds, by 24 hours
+ for($i = 0; $i < 7; $i ++) {
+ $cdatestr = strftime("%d-%h-%Y", $nowtime - ($oneday*$i));
+ $backupfile = "$configpath.$cdatestr";
+ error_log("checking for backup of config as $backupfile");
+ if(file_exists($backupfile)) {
+ error_log("backupconfig exists as $backupfile, exit");
+ echo "ADMIN CRON: backup of config is $backupfile, created $i days ago, not creating new one<br>";
+ return;
+ }
+ }
+ $nowdatestr = strftime("%d-%h-%Y");
+ $backupfile = "$configpath.$nowdatestr";
+ copy($configpath, $backupfile);
+ echo "ADMIN CRON: createing backup of config as $backupfile<br>";
}
function body($url)
$myRep = new GLCASRepo($this->config);
$wasyum = false;
+ $wasapt = false;
if($_REQUEST["repotype"] == "yumbase") {
$glt = $myRep->getRepoDetailsYum($_REQUEST["repourl"]);
$wasyum = true;
$wasyum = true;
} else if($_REQUEST["repotype"] == "apt") {
$glt = $myRep->getRepoDetailsApt($_REQUEST["repourl"]);
+ $wasapt = true;
}
+ if($wasapt) {
+ error_log("in wasapt");
+ $repourl = $_REQUEST["repourl"];
+
+ if($glt === false) {
+ echo "Could not find any apt repository at $repourl<br>";
+ return;
+ }
+
+ $extratext = "";
+ $provides = "";
+ if($glt["nrepos"] > 0) {
+ $kos = getKnownOSList();
+ foreach($glt["knownrepo"] as $key => $val) {
+ $reponame = $kos["apt"][$val];
+ //echo "Fount a repo, $val which is $reponame<br>";
+ $provides .= "$reponame\n";
+ }
+ $extratext = " for ".$glt["distros"];
+ } else {
+ //echo "Looks like an apt repo, but I cant find any known distro's<br>";
+ }
+
+ echo "<form method=\"post\" action=\"?action=addrepoapt\">";
+ echo "<input type=\"hidden\" name=\"repourl\" value=\"$repourl\">";
+ echo "<table>";
+ echo "<tr><td>Description</td><td><input type=\"text\" name=\"desc\" value=\"APT Repo$extratext\"></td>";
+ echo "<tr><td>Provides</td><td><textarea name=\"provides\">$provides</text area></td></tr>";
+ echo "<tr><td>Short URL</td><td><input type=\"text\" name=\"shorturl\"></td></tr>";
+ echo "<tr><td>URL Prefix (blank for none)</td><td><input type=\"text\" name=\"prefix\"></td></tr>";
+ echo "<tr><td>Expire time for Meta Data</td><td><input type=\"text\" name=\"expiretime\"> days</td></tr>";
+ echo "</table>";
+ echo "</form>";
+ return true;
+ }
if($wasyum) {
$os = $glt["OS"];
echo "<tr><td><input type=\"submit\" name=\"Add\" value=\"Add\"></td></tr>";
echo "</table>";
echo "</form>";
- } else {
- // apt is much tricker cause one repo can provide multiple versions, OS's and architectures.
}
}
$kos["os"]["ubuntu"]["long"] = "Ubuntu";
$kos["os"]["centos"]["long"] = "Community Enterprise OS";
+
+ // ubuntu bit for apt
+ $kos["apt"]["hardy"] = "Hardy Heron (8.04)";
+ $kos["apt"]["hardy-backports"] = "Hardy Heron (8.04) Backports";
+ $kos["apt"]["hardy-proposed"] = "Hardy Heron (8.04) Proposed";
+ $kos["apt"]["hardy-security"] = "Hardy Heron (8.04) Security";
+ $kos["apt"]["hardy-updates"] = "Hardy Heron (8.04) Updates";
+ $kos["apt"]["karmic"] = "Karmic Koala (9.10)";
+ $kos["apt"]["karmic-backports"] = "Karmic Koala (9.10) Backports";
+ $kos["apt"]["karmic-proposed"] = "Karmic Koala (9.10) Proposed";
+ $kos["apt"]["karmic-security"] = "Karmic Koala (9.10) Security";
+ $kos["apt"]["karmic-updates"] = "Karmic Koala (9.10) Updates";
+ $kos["apt"]["lucid"] = "Lucid Lynx (10.04 LTS)";
+ $kos["apt"]["lucid-backports"] = "Lucid Lynx (10.04 LTS) Backports";
+ $kos["apt"]["lucid-proposed"] = "Lucid Lynx (10.04 LTS) Proposed";
+ $kos["apt"]["lucid-security"] = "Lucid Lynx (10.04 LTS) Security";
+ $kos["apt"]["lucid-updates"] = "Lucid Lynx (10.04 LTS) Updates";
+ $kos["apt"]["maverick"] = "Maverick Meerkat (10.10)";
+ $kos["apt"]["maverick-backports"] = "Maverick Meerkat (10.10) Backports";
+ $kos["apt"]["maverick-proposed"] = "Maverick Meerkat (10.10) Proposed";
+ $kos["apt"]["maverick-security"] = "Maverick Meerkat (10.10) Security";
+ $kos["apt"]["maverick-updates"] = "Maverick Meerkat (10.10) Updates";
+ $kos["apt"]["natty"] = "Natty Narwhal (11.04)";
+ $kos["apt"]["natty-backports"] = "Natty Narwhal (11.04) Backports";
+ $kos["apt"]["natty-proposed"] = "Natty Narwhal (11.04) Proposed";
+ $kos["apt"]["natty-security"] = "Natty Narwhal (11.04) Security";
+ $kos["apt"]["natty-updates"] = "Natty Narwhal (11.04) Updates";
+ $kos["apt"]["oneiric"] = "Oneiric Ocelot (11.10)";
+ $kos["apt"]["oneiric-backports"] = "Oneiric Ocelot (11.10) Backports";
+ $kos["apt"]["oneiric-proposed"] = "Oneiric Ocelot (11.10) Proposed";
+ $kos["apt"]["oneiric-security"] = "Oneiric Ocelot (11.10) Security";
+ $kos["apt"]["oneiric-updates"] = "Oneiric Ocelot (11.10) Updates";
+ $kos["apt"]["lenny"] = "Debian Lenny";
+ $kos["apt"]["sid"] = "Debian Sid";
+ $kos["apt"]["squeeze"] = "Debian Squeeze";
+ $kos["apt"]["wheezy"] = "Debian Wheezy";
+ $kos["apt"]["stable"] = "Debian Stable";
+ $kos["apt"]["unstable"] = "Debian Unstable";
+
+
+
+
+
// Repo types per os
$kos["os"]["Fedora"]["repotype"] = "yum";
$kos["os"]["Debian"]["repotype"] = "apt";
} else return false;
}
+
+ function getRepoDetailsApt($url)
+ {
+ $action1 = $url."/dists";
+
+ // we just want to make sure it exists really
+ error_log("in repo details apt for $url");
+ if(!glcas_isRemoteDir($action1)) {
+ //echo "I cant find any valid APT dists's at $url<br>";
+ return false;
+ }
+
+ // ok, now scan for ubuntu dists as
+ $kos = getKnownOSList();
+
+ $repos = 0;
+ $existing_repo["isrepo"] = true;
+ foreach($kos["apt"] as $key => $val) {
+ //echo "<br>$key, $val<br>";
+ //echo "now check, $action1/$key";
+ if(glcas_isRemoteDir($action1."/$key")) {
+ $existing_repos["knownrepo"][$repos] = $key;
+ $repos++;
+ //echo "Found Distro $val<br>";
+ }
+ }
+ $existing_repos["nrepos"] = $repos;
+ $existing_repos["distros"] = "Ubuntu, Debian";
+
+
+ return $existing_repos;
+
+ }
function getRepoDetailsYum($url, $ismirrorlist=false)
{