function __construct($config)
{
$this->config = $config;
- if($this->config->getConfigVar("storagelocation") == false) {
+ if($this->config->getConfig("storagelocation") == false) {
global $WEB_ROOT_FS;
$storloc = "$WEB_ROOT_FS/../var/glcas/cache/";
if(!file_exists($storloc)) mkdir($storloc);
- $this->config->setConfigVar("storagelocation", realpath($storloc));
- $this->config->saveConfig();
+ $this->config->setConfig("storagelocation", realpath($storloc));
error_log("set storage location, $storloc");
}
}
+
+ // with the move to the sqlite db, this is going to get painful
function cron()
{
//echo "<pre>";
- $uconf = unserialize($this->config->getConfigVar("repodata"));
- $repostore = $this->config->getConfigVar("storagelocation");
+ $uconf = unserialize($this->config->getConfig("repodata"));
+ $repostore = $this->config->getConfig("storagelocation");
//print_r($uconf);
//echo "</pre>";
foreach($uconf as $rkey => $repo) {
echo "Repo $rkey: ".$repo["desc"]."<br>";
+ if(isset($repo["frozen"])) {
+ error_log("repo froze set");
+ $repofrozen = $repo["frozen"];
+ } else {
+ error_log("repo froze not set");
+ $repofrozen = false;
+ }
if(!isset($repo["expiretime"])) {
echo " - Expire time not set, setting to 2 days by default<br>";
$uconf[$rkey]["expiretime"] = 2;
$repo["expiretime"] = 2;
- $this->config->setConfigVar("repodata", serialize($uconf));
+ $this->config->setConfig("repodata", serialize($uconf));
$this->config->saveConfig();
}
if(!isset($repo["repotype"])) {
echo "<font color=\"red\">Repo type not set for repo, setting to yum</font><br>";
$uconf[$rkey]["repotype"] = "YUM";
- $this->config->setConfigVar("repodata", serialize($uconf));
+ $this->config->setConfig("repodata", serialize($uconf));
$this->config->saveConfig();
} else if($repo["repotype"] == "YUM") {
- if(file_exists("$repostore/$rkey/repodata/repoupdate.lock")) {
- echo " - <font color=\"red\">Repo locked for update</font><br>";
-
- }
-
- // we still do this next bit, even if its locked because it may be a stray file
- echo " - Expire time is ".$repo["expiretime"]." days, checking repo<br>";
- error_log("checking $repostore/$rkey/repodata/repomd.xml");
- $tdiff = time() - filemtime("$repostore/$rkey/repodata/repomd.xml");
- $maxtdiff = $repo["expiretime"] * 24 * 3600;
- if($tdiff > $maxtdiff) {
- echo " - <font color=\"green\">updating repo</font><br>";
- $this->updateRepo($rkey);
+ if($repofrozen) {
+ error_log("repo frozen");
+ echo " - <font color=\"blue\">Repo Frozen</font><br>";
} else {
- echo " - not updating repo<br>";
+ if(file_exists("$repostore/$rkey/repodata/repoupdate.lock")) {
+ echo " - <font color=\"red\">Repo locked for update</font><br>";
+
+ }
+
+ // we still do this next bit, even if its locked because it may be a stray file
+ echo " - Expire time is ".$repo["expiretime"]." days, checking repo<br>";
+ error_log("checking $repostore/$rkey/repodata/repomd.xml");
+ $tdiff = time() - filemtime("$repostore/$rkey/repodata/repomd.xml");
+ $maxtdiff = $repo["expiretime"] * 24 * 3600;
+ if($tdiff > $maxtdiff) {
+ echo " - <font color=\"green\">updating repo</font><br>";
+ $this->updateRepo($rkey);
+ } else {
+ echo " - not updating repo<br>";
+ }
}
} else if($repo["repotype"] == "APT") {
- if(file_exists("$repostore/$rkey/update.lock")) {
- echo " - <font color=\"red\">Repo locaked for update</font><br>";
- }
- echo " - Expire time is ".$repo["expiretime"]." days, checking repo<br>";
- $maxtdiff = $repo["expiretime"] * 24 * 3600;
- // now we check for outdated release files
- $dh = opendir("$repostore/$rkey/dists/");
- $needsupdate = false;
- while(($fn = readdir($dh))!==false) {
- if($fn != "." && $fn != "..") {
- if(file_exists("$repostore/$rkey/dists/$fn/Release")) {
- $tdiff = time() - filemtime("$repostore/$rkey/dists/$fn/Release");
- if($tdiff > $maxtdiff) $needsupdate = true;
+ if($repofrozen) {
+ error_log("repo frozen");
+ echo " - <font color=\"blue\">Repo Frozen</font><br>";
+ } else {
+ if(file_exists("$repostore/$rkey/update.lock")) {
+ echo " - <font color=\"red\">Repo locaked for update</font><br>";
+ }
+ echo " - Expire time is ".$repo["expiretime"]." days, checking repo<br>";
+ $maxtdiff = $repo["expiretime"] * 24 * 3600;
+ // now we check for outdated release files
+ $dh = opendir("$repostore/$rkey/dists/");
+ $needsupdate = false;
+ while(($fn = readdir($dh))!==false) {
+ if($fn != "." && $fn != "..") {
+ if(file_exists("$repostore/$rkey/dists/$fn/Release")) {
+ $tdiff = time() - filemtime("$repostore/$rkey/dists/$fn/Release");
+ if($tdiff > $maxtdiff) $needsupdate = true;
+ }
}
}
- }
- if($needsupdate) {
- echo " - Spawn updater<br>";
- $this->updateRepo($rkey);
- } else {
- echo " - Up to date<br>";
+ if($needsupdate) {
+ echo " - Spawn updater<br>";
+ $this->updateRepo($rkey);
+ } else {
+ echo " - Up to date<br>";
+ }
}
}
}
$xurl = split("[/,]", $url);
// first get the config
- $uconf = unserialize($this->config->getConfigVar("repodata"));
- $repostore = $this->config->getConfigVar("storagelocation");
+ $uconf = unserialize($this->config->getConfig("repodata"));
+ $repostore = $this->config->getConfig("storagelocation");
// preset matched to -1
$matched = -1;
function serveUpFile($actualfile, $repoid)
{
- $uconf = unserialize($this->config->getConfigVar("repodata"));
- $repostore = $this->config->getConfigVar("storagelocation");
+ $uconf = unserialize($this->config->getConfig("repodata"));
+ $repostore = $this->config->getConfig("storagelocation");
// figure out the range header garbage that centos/redhat send
if(isset($_SERVER["HTTP_RANGE"])) {
clearstatcache();
// get the configurations we need
- $uconf = unserialize($this->config->getConfigVar("repodata"));
- $repostore = $this->config->getConfigVar("storagelocation");
+ $uconf = unserialize($this->config->getConfig("repodata"));
+ $repostore = $this->config->getConfig("storagelocation");
return $glt;
}
+ function freezeRepo($rkey)
+ {
+
+ $uconf = $this->config->getConfig("repodata");
+ $repostore = $this->config->getConfig("storagelocation");
+
+ if($uconf !== false) {
+ $conf = unserialize($uconf);
+ foreach($conf as $key => $vla) {
+ if($key == $rkey) {
+ if(isset($conf["$rkey"]["frozen"])) {
+ if($conf["$rkey"]["frozen"]) {
+ $conf["$rkey"]["frozen"] = false;
+ error_log("Unfreeze repo");
+ } else {
+ $conf["$rkey"]["frozen"] = true;
+ error_log("freeze repo");
+ }
+ } else {
+ $conf["$rkey"]["frozen"] = true;
+ }
+ $nconf = serialize($conf);
+ error_log("freeze repo as $rkey");
+ $this->config->setConfig("repodata", $nconf);
+ $this->config->saveConfig();
+ }
+ }
+ }
+ }
+
function deleteRepo($rkey)
{
- $uconf = $this->config->getConfigVar("repodata");
- $repostore = $this->config->getConfigVar("storagelocation");
+ $uconf = $this->config->getConfig("repodata");
+ $repostore = $this->config->getConfig("storagelocation");
if($uconf !== false) {
$conf = unserialize($uconf);
$nconf = serialize($conf);
system("rm -rf $repostore/$key");
error_log("remove repo as $rkey");
- $this->config->setConfigVar("repodata", $nconf);
+ $this->config->setConfig("repodata", $nconf);
$this->config->saveConfig();
}
}
function addRepo($desc, $os, $version, $arch, $other, $shorturl, $prefix, $repurl, $repotype, $init, $expiretime, $blocklist=null)
{
- $uconf = $this->config->getConfigVar("repodata");
+ $uconf = $this->config->getConfig("repodata");
$cs["desc"] = $desc;
$cs["os"] = $os;
$nconf = serialize($conf);
error_log("add repo as $ckey");
- $this->config->setConfigVar("repodata", $nconf);
+ $this->config->setConfig("repodata", $nconf);
$this->config->saveConfig();
// now create the base structure in the repo
- $repostore = $this->config->getConfigVar("storagelocation");
+ $repostore = $this->config->getConfig("storagelocation");
// now call update repo
{
// we only do yum yet
$repod = $this->getRepo($repokey);
+ if(isset($repod["frozen"])) if($repod["frozen"]) {
+ error_log("in update repo for frozen repo, ignore update");
+ return;
+ }
error_log("in update repo");
function updateRepoApt($repokey)
{
- $repostore = $this->config->getConfigVar("storagelocation");
+ $repostore = $this->config->getConfig("storagelocation");
$repod = $this->getRepo($repokey);
function updateRepoYum($repokey)
{
- $repostore = $this->config->getConfigVar("storagelocation");
+ $repostore = $this->config->getConfig("storagelocation");
$repod = $this->getRepo($repokey);
function getRepo($id)
{
- $uconf = $this->config->getConfigVar("repodata");
+ $uconf = $this->config->getConfig("repodata");
if($uconf !== false) {
$lconf = unserialize($uconf);
return $lconf[$id];
function getRepos()
{
- $uconf = $this->config->getConfigVar("repodata");
+ $uconf = $this->config->getConfig("repodata");
if($uconf !== false) {
return unserialize($uconf);
} else return false;