git.cweiske.de
/
linksys-wrt3g-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix error
[linksys-wrt3g-tools.git]
/
scripts
/
linksys-wrt3g.php
diff --git
a/scripts/linksys-wrt3g.php
b/scripts/linksys-wrt3g.php
old mode 100644
(file)
new mode 100755
(executable)
index
48683e7
..
7d87cd1
--- a/
scripts/linksys-wrt3g.php
+++ b/
scripts/linksys-wrt3g.php
@@
-1,3
+1,4
@@
+#!/usr/bin/env php
<?php
/**
* Control script for Linksys WRT3g routers.
<?php
/**
* Control script for Linksys WRT3g routers.
@@
-61,16
+62,43
@@
$parser->addOption(
'default' => $GLOBALS['linksys-wrt3g-tools']['password']
)
);
'default' => $GLOBALS['linksys-wrt3g-tools']['password']
)
);
+$parser->addOption(
+ 'verbosity',
+ array(
+ 'short_name' => '-v',
+ 'long_name' => '--verbose',
+ 'description' => 'Show more details (more to see more details)',
+ 'action' => 'Counter',
+ )
+);
-$parser->addCommand(
+$
stCmd = $
parser->addCommand(
'status',
array(
'status',
array(
- 'description' => 'Show the router status'
+ 'aliases' => array('s', 'st'),
+ 'description' => 'Show the connection status'
+ )
+);
+$stCmd = $parser->addCommand(
+ 'cardstatus',
+ array(
+ 'aliases' => array('c', 'cs'),
+ 'description' => 'Show the card/SIM status'
)
);
)
);
+$stCmd = $parser->addCommand(
+ 'allstatus',
+ array(
+ 'aliases' => array('a', 'as'),
+ 'description' => 'Show all status details'
+ )
+);
+
+
$parser->addCommand(
'reboot',
array(
$parser->addCommand(
'reboot',
array(
+ 'aliases' => array('r'),
'description' => 'Reboot the router'
)
);
'description' => 'Reboot the router'
)
);
@@
-84,9
+112,12
@@
try {
try {
$router = new Wrt3g();
try {
$router = new Wrt3g();
- $router->host = $result->options['host'];
- $router->user = $result->options['user'];
- $router->password = $result->options['password'];
+ $router->verbosity = $result->options['verbosity'];
+ $router->host = $result->options['host'];
+ $router->user = $result->options['user'];
+ $router->password = $result->options['password'];
+
+ $router->log('Command: ' . $result->command_name, 2);
switch ($result->command_name) {
case 'reboot':
switch ($result->command_name) {
case 'reboot':
@@
-97,9
+128,17
@@
try {
}
break;
}
break;
+ case 'allstatus':
+ case 'cardstatus':
case 'status':
default:
case 'status':
default:
- $arStatus = $router->getStatus();
+ if ($result->command_name == 'allstatus') {
+ $arStatus = $router->getFullStatus();
+ } else if ($result->command_name == 'cardstatus') {
+ $arStatus = $router->getCardStatus();
+ } else {
+ $arStatus = $router->getConnectionStatus();
+ }
foreach ($arStatus as $key => $value) {
echo $key . ': ' . $value . "\n";
}
foreach ($arStatus as $key => $value) {
echo $key . ': ' . $value . "\n";
}