errr, no idea?
[ga4php.git] / authserver / usercmd.php
index 1d4db80..d24157e 100644 (file)
@@ -39,10 +39,37 @@ if(!isset($argv[1])) {
        echo "\tradauth: radauth <username> <pin> - for radius, only returns a code\n";
        echo "\tsynctoken: synctoken <username> <tokenone> <tokentwo> - resync's a hotp token based on two token codes\n";
        echo "\ttokentype: tokentype <username> - gets the token type for a user\n";
+       echo "\taddradclient: addradclient <client_name> <client_ip> <client_secret> \"<description>\"- adds a radius client\n";
+       echo "\trmradclient: rmradclient <client_name> - removes a radius client with the name <client_name>\n";
+       echo "\tgetradclients: getradclients - returns a list of radius clients\n";
        return 0;       
 }
 
 switch($argv[1]) {
+       case "rmradclient":
+               $msg = $myAC->deleteRadiusClient($argv[2]);
+               if($msg) {
+                       echo "Successfully deleted\n";
+               }
+               break;
+       case "getradclients":
+               $msg = $myAC->getRadiusClients();
+               foreach($msg as $client) {
+                       if($client["desc"]=="") $desc = "no description set";
+                       else $desc = $client["desc"];
+                       echo $client["name"]." is ".$client["ip"].", $desc\n";
+               }
+               break;
+       case "addradclient":
+               $msg = $myAC->addRadiusClient($argv[2], $argv[3], $argv[4], $argv[5]);
+               if($msg === true) {
+                       echo "Added successfully\n";
+               } else if ($msg == "name") {
+                       echo "Client with same name exists already\n";
+               } else if ($msg == "ip") {
+                       echo "Client with same IP already exists\n";
+               }
+               break;
        case "tokentype":
                $msg = $myAC->getUserTokenType($argv[2]);
                echo "token type: $msg\n";
@@ -80,7 +107,12 @@ switch($argv[1]) {
                break;
        case "add":
                $return = $myAC->addUser($argv[2]);
-               echo "Created user, ".$argv[2]." returned $return\n";
+               if($return) {
+                       echo "Created user, ".$argv[2]."\n";
+               } else {
+                       echo "Failed to create user, ".$argv[2]."\n";
+               }
+                
                break;
        case "delete":
                $res = $myAC->deleteUser($argv[2]);
@@ -133,5 +165,7 @@ switch($argv[1]) {
                        echo "\tHas Token?: ".$hastoken."\n\n";
                }
                break;
+       default:
+               echo "See the usage...\n";
 }
 ?>
\ No newline at end of file