diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2010-12-28 20:23:02 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2010-12-28 20:23:02 +0100 |
| commit | 0b819c19fd42dea09b9ef638ebdba8c592ecddb8 (patch) | |
| tree | 803c6deb3b6fd4f36c22e831e3bac25401ac4aa2 /scripts | |
| parent | 1d238ad9a92378132c926442b9749cd7161a54d0 (diff) | |
| download | linksys-wrt3g-tools-0b819c19fd42dea09b9ef638ebdba8c592ecddb8.tar.gz linksys-wrt3g-tools-0b819c19fd42dea09b9ef638ebdba8c592ecddb8.zip | |
use pear config package to read config file
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/linksys-wrt3g.php | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/scripts/linksys-wrt3g.php b/scripts/linksys-wrt3g.php index 219e081..f53d76a 100755 --- a/scripts/linksys-wrt3g.php +++ b/scripts/linksys-wrt3g.php @@ -14,18 +14,6 @@ require_once 'Wrt3g.php'; require_once 'Console/CommandLine.php'; -//default config options -$GLOBALS['linksys-wrt3g-tools'] = array( - 'host' => null, - 'user' => 'admin', - 'password' => null, -); - -$configFile = dirname(__FILE__) . '/../config.php'; -if (file_exists($configFile)) { - require_once $configFile; -} - $parser = new Console_CommandLine(); $parser->description = "Tool to control Linksys WRT3g routers"; $parser->version = '0.0.1';//FIXME: dynamic @@ -37,7 +25,7 @@ $parser->addOption( 'description' => 'IP/Hostname to connect to', 'help_name' => 'HOST', 'action' => 'StoreString', - 'default' => $GLOBALS['linksys-wrt3g-tools']['host'] + 'default' => null ) ); $parser->addOption( @@ -48,7 +36,7 @@ $parser->addOption( 'description' => 'Admin user name', 'help_name' => 'USER', 'action' => 'StoreString', - 'default' => $GLOBALS['linksys-wrt3g-tools']['user'] + 'default' => 'admin' ) ); $parser->addOption( @@ -59,7 +47,7 @@ $parser->addOption( 'description' => 'Password for admin user', 'help_name' => 'PASS', 'action' => 'StoreString', - 'default' => $GLOBALS['linksys-wrt3g-tools']['password'] + 'default' => null ) ); $parser->addOption( @@ -111,6 +99,12 @@ $parser->addCommand( 'description' => 'Reboot the router' ) ); +$stCmd = $parser->addCommand( + 'saveConfig', + array( + 'description' => 'Saves the router configuration into the config file' + ) +); try { $result = $parser->parse(); @@ -122,9 +116,7 @@ try { try { $router = new Wrt3g(); $router->verbosity = $result->options['verbosity']; - $router->host = $result->options['host']; - $router->user = $result->options['user']; - $router->password = $result->options['password']; + $router->loadConfig($result->options); if ($result->options['dummy']) { require_once 'Wrt3g/DummyRequest.php'; @@ -143,6 +135,10 @@ try { } break; + case 'saveConfig': + $router->config->save($router->config->getConfigFilePath()); + break; + case 'all': case 'card': case 'status': |
