4bf1513629d802470f6148af049edc205568ee14
[CBFWR.git] / bin / cbfwrd.php
1 <?php
2 $CMD_ROOT_FS = realpath(dirname(__FILE__));
3 $AM_DAEMON = true;
4
5 global $CMD_ROOT_FS;
6 global $AM_DAEMON;
7
8 // add libglcas as if it were a path in ../libglcas
9 if(file_exists("../libcbfwr")) {
10         $path = realpath($CMD_ROOT_FS."/../");
11         error_log("added cbfwr path as $path");
12         set_include_path(get_include_path().PATH_SEPARATOR.$path);
13 }
14
15 // include the based library
16 require_once("libcbfwr/lib.php");
17
18 glcas_pluginLoader();
19
20 error_log("CBFWRD starting");
21
22
23 $config = new Config();
24
25 if(isset($argv[1])) {
26         if($argv[1] == "boot") {
27                 // we get called here on boot.
28                 $config->bootHardware();
29                 exit(0);
30         }
31 }
32
33 // now we got into daemon modes
34 $cont = true;
35
36 // setup our sem/shm stuff
37
38 // this stuff needs to go in comms
39 while($cont) {
40         $comms = new Comms;
41         
42         $config->loadConfig();
43         $comms->putConfig($config->getConfig());
44         
45         $msg = $comms->waitForMessage();
46         
47         //echo "Got message: $msg\n";
48         if($msg == "quit") $cont = false;
49 }
50 ?>