1. Commandline options
Use --help to get an overview
-2. User configuration file
+2. Environment variables
+
+3. User configuration file
~/.config/linksys-wrt3g-tools
-3. System configuration file
+4. System configuration file
/etc/linksys-wrt3g-tools
The configuration files are normal ini-style files with key=value
-lines. Supported configuration options in the files are
+lines.
+Supported configuration options in the files, and environment variables, are
- host
- user
- password
+(lowercase)
Dependencies
if ($file) {
$this->loadFromFile($file);
}
+ //environment variables: we use lowercase options, which should
+ // not collide with the uppercase env variables like USER
+ $this->loadOptions($_SERVER);
+ //commandline options
$this->loadOptions($options);
- //commandline options
+ $this->logger->log(
+ sprintf(
+ "Configuration: %s:%s@%s",
+ $this->user, $this->password, $this->host
+ ),
+ 2
+ );
+
if (isset($options['save'])) {
$this->save($file);
}
*/
require_once 'Wrt3g.php';
-$options = array();
-foreach (array('host', 'user', 'password') as $variable) {
- if (isset($_SERVER[$variable])) {
- $options[$variable] = $_SERVER[$variable];
- }
-}
-
if (isset($argv[1]) && $argv[1] == 'autoconf') {
$router = new Wrt3g();
- $router->loadConfig($options);
+ $router->loadConfig();
if ($router->config->host === null) {
echo "no (no host configured)\n";
} else {
try {
$router = new Wrt3g();
- $router->loadConfig($options);
+ $router->loadConfig();
$arStatus = $router->getConnectionStatus();