added a apt repo updater... that doesnt work
[glcas.git] / bin / updateaptrepo.php
1 <?php
2
3 $url = "";
4 $file = "";
5 if(isset($argv[1])) {
6         $url = $argv[1];
7 }
8
9 if(isset($argv[2])) {
10         $file = $argv[2];
11 }
12
13 if($url == "" || $file == "") {
14         echo "need a url and file\n";
15         exit(0);
16 }
17
18 if(file_exists("$file/update.lock")) {
19         // try get a lock
20         $lf = fopen("$file/update.lock", "r");
21         if($lf) {
22                 $lockres = flock($lf, LOCK_EX|LOCK_NB);
23                 if(!$lockres) {
24                         error_log("flock did fail, all is right with the world a download is in progress");
25                         exit(0);
26                 }
27         } else {
28                 error_log("weird problem");
29         }
30 }
31 fclose($lf);
32 $lf = fopen("$file/update.lock", "w");
33 flock($lf, LOCK_EX|LOCK_NB);
34
35
36 ?>