diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2010-12-28 23:14:06 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2010-12-28 23:14:06 +0100 |
| commit | d7d8ad1049df1955d4cedbdb88f55bad1b942a2f (patch) | |
| tree | c1e11284626f169daad058d9ee7eec90b46a8aa7 | |
| parent | 9670ba7c1328b028800895eba2151f1b29f6a077 (diff) | |
| download | linksys-wrt3g-tools-d7d8ad1049df1955d4cedbdb88f55bad1b942a2f.tar.gz linksys-wrt3g-tools-d7d8ad1049df1955d4cedbdb88f55bad1b942a2f.zip | |
load environment variables by default
| -rw-r--r-- | README | 10 | ||||
| -rw-r--r-- | Wrt3g/Config.php | 13 | ||||
| -rwxr-xr-x | scripts/munin.php | 11 |
3 files changed, 21 insertions, 13 deletions
@@ -17,17 +17,21 @@ The tools can be configured in three ways: 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 diff --git a/Wrt3g/Config.php b/Wrt3g/Config.php index a8232df..5036f7d 100644 --- a/Wrt3g/Config.php +++ b/Wrt3g/Config.php @@ -88,9 +88,20 @@ class Wrt3g_Config 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); } diff --git a/scripts/munin.php b/scripts/munin.php index dc7d050..0722035 100755 --- a/scripts/munin.php +++ b/scripts/munin.php @@ -15,16 +15,9 @@ */ 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 { @@ -81,7 +74,7 @@ TXT; try { $router = new Wrt3g(); - $router->loadConfig($options); + $router->loadConfig(); $arStatus = $router->getConnectionStatus(); |
