changed how configs work
[CBFWR.git] / bin / cbfwrd.php
index 4bf1513..4abcbbd 100644 (file)
@@ -19,13 +19,16 @@ glcas_pluginLoader();
 
 error_log("CBFWRD starting");
 
+$comms = new Comms;
 
-$config = new Config();
 
 if(isset($argv[1])) {
+       // we get called here on boot.
        if($argv[1] == "boot") {
-               // we get called here on boot.
-               $config->bootHardware();
+               $config = new Config(false);
+               $config->findHardware();
+               $conf = $config->getConfig();
+               $comms->putConfig($conf, 1);
                exit(0);
        }
 }
@@ -35,16 +38,41 @@ $cont = true;
 
 // setup our sem/shm stuff
 
-// this stuff needs to go in comms
+// do the initial stuff
+$config = new Config(true);
+$config->loadConfigFile();
+$rawconf = $config->getConfig();
+$comms->putConfig($rawconf);
+$config->applyConfig();
+$runconf["status"] = "nochange";
+$comms->putConfig($runconf, 2);
+$res = $comms->getConfig(3);
+if($res === false) {
+       $comms->putConfig($runconf, 3);
+}
+
+
 while($cont) {
-       $comms = new Comms;
-       
-       $config->loadConfig();
-       $comms->putConfig($config->getConfig());
-       
        $msg = $comms->waitForMessage();
        
        //echo "Got message: $msg\n";
        if($msg == "quit") $cont = false;
+       else cbfwd_commandProcessor($msg);
+}
+
+
+function cbfwd_commandProcessor($command)
+{
+       global $config;
+       $cmds = explode(" ", $command);
+       $comms = new Comms;
+       
+       $comms->lockConfigs();
+       switch($cmds[0]) {
+               case "applyclientconfig":
+                       break;
+                       
+       }
+       $comms->unlockConfigs();
 }
 ?>
\ No newline at end of file