config modifications and such
[CBFWR.git] / bin / cbfwrd.php
1 <?php
2 $CMD_ROOT_FS = realpath(dirname(__FILE__));
3 $AM_DAEMON = true;
4 $MOCKUP = true;
5
6 global $CMD_ROOT_FS, $AM_DAEMON, $MOCKUP;
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 $comms = new Comms;
23
24
25 if(isset($argv[1])) {
26         // we get called here on boot.
27         if($argv[1] == "boot") {
28                 $config = new Config(false);
29                 $config->findHardware();
30                 $conf = $config->getConfig();
31                 $comms->putConfig($conf, 1);
32                 exit(0);
33         }
34 }
35
36 // now we got into daemon modes
37 $cont = true;
38
39 // setup our sem/shm stuff
40
41 // do the initial stuff
42 $config = new Config(true);
43 $config->loadConfigFile();
44 $rawconf = $config->getConfig();
45 $comms->putConfig($rawconf);
46 $config->applyConfig();
47 $runconf["status"] = "nochange";
48 $comms->putConfig($runconf, 2);
49 $res = $comms->getConfig(3);
50 if($res === false) {
51         $comms->putConfig($runconf, 3);
52 }
53
54
55 while($cont) {
56         $msg = $comms->waitForMessage();
57         
58         //echo "Got message: $msg\n";
59         if($msg == "quit") $cont = false;
60         else cbfwd_commandProcessor($msg);
61 }
62
63
64 function cbfwd_commandProcessor($command)
65 {
66         global $config;
67         $cmds = explode(" ", $command);
68         $comms = new Comms;
69         
70         $comms->lockConfigs();
71         switch($cmds[0]) {
72                 case "applyclientconfig":
73                         break;
74                         
75         }
76         $comms->unlockConfigs();
77 }
78 ?>