X-Git-Url: http://git.pjr.cc/?p=CBFWR.git;a=blobdiff_plain;f=libcbfwr%2Fconfig.php;h=9ca0ff9d8e1ecc5762ed51591071496017c4c613;hp=94cf1b31322af10fc4e25a28e5d02ab8202cf233;hb=175dadf56670772f8d889276df67471354a36f21;hpb=9d42ecae8d0c5139e119af983a5fe65f4b0fe149 diff --git a/libcbfwr/config.php b/libcbfwr/config.php index 94cf1b3..9ca0ff9 100644 --- a/libcbfwr/config.php +++ b/libcbfwr/config.php @@ -31,29 +31,50 @@ class Config { $this->config_file = "../var/"; } else { echo "No directory where i can create a config, bailing\n"; - exit(0); + $this->config["status"] = "unconf"; } } - if($this->config["status"] == "conf") { - - $this->loadConfig($this->config_file); + + + } + } + + function bootHardware() + { + $this->findHardware(); + + $mycomm = new Comms(); + $mycomm->putConfig($this->config, 1); + + } + + function loadConfig() + { + global $AM_DAEMON; + + if($AM_DAEMON) { + if($this->config["status"] == "conf") { + $this->loadConfigFile($this->config_file); + $this->applyConfig(); $this->findHardware(); - print_r($this->config); - $this->applyConfig(); - } else { - // we go into firstrun mode + $mycomm = new Comms(); + $mycomm->putConfig($this->config); + $this->boot_config = $mycomm->getConfig(1); } - - } else { - // config comes from shm... we'll get there - } + $mycomm = new Comms(); + $this->config = $mycomm->getConfig(0); + $this->boot_config = $mycomm->getConfig(1); + + } } function findHardware() { + + // first, network interfaces $dh = opendir("/sys/class/net/"); while(($fname = readdir($dh)) !== false) { @@ -83,6 +104,11 @@ class Config { return $this->config; } + function getBootConfig() + { + return $this->boot_config; + } + function applyConfig() { global $AM_DAEMON; @@ -92,7 +118,7 @@ class Config { return true; } - function loadConfig($file) + function loadConfigFile($file) { global $AM_DAEMON; if(!$AM_DAEMON) return true; @@ -315,7 +341,7 @@ class Config { } - function saveConfig() + function saveConfigFile($file) { global $AM_DAEMON; if(!$AM_DAEMON) return true; @@ -324,6 +350,7 @@ class Config { private $config_file; private $config; + private $boot_config; }; ?> \ No newline at end of file