added a apt repo updater... that doesnt work
[glcas.git] / bin / updateaptrepo.php
diff --git a/bin/updateaptrepo.php b/bin/updateaptrepo.php
new file mode 100644 (file)
index 0000000..38aae68
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+$url = "";
+$file = "";
+if(isset($argv[1])) {
+       $url = $argv[1];
+}
+
+if(isset($argv[2])) {
+       $file = $argv[2];
+}
+
+if($url == "" || $file == "") {
+       echo "need a url and file\n";
+       exit(0);
+}
+
+if(file_exists("$file/update.lock")) {
+       // try get a lock
+       $lf = fopen("$file/update.lock", "r");
+       if($lf) {
+               $lockres = flock($lf, LOCK_EX|LOCK_NB);
+               if(!$lockres) {
+                       error_log("flock did fail, all is right with the world a download is in progress");
+                       exit(0);
+               }
+       } else {
+               error_log("weird problem");
+       }
+}
+fclose($lf);
+$lf = fopen("$file/update.lock", "w");
+flock($lf, LOCK_EX|LOCK_NB);
+
+
+?>
\ No newline at end of file