]> git.sesse.net Git - nms/commitdiff
Fix zyxelng.
authorEirik Nygaard <eirikn@space>
Tue, 3 Apr 2007 13:37:26 +0000 (15:37 +0200)
committerEirik Nygaard <eirikn@space>
Tue, 3 Apr 2007 13:37:26 +0000 (15:37 +0200)
clients/zyxelng.pl

index c6a0b1ef8fb0ea49f2d0bca7b3c146a14f9b7abb..c3d08fcfa505017c723ceefd606145606b3ba13d 100644 (file)
@@ -8,7 +8,7 @@ use lib '../include';
 use Data::Dumper;
 
 use nms qw(switch_connect switch_exec);
-use ios;
+#use ios;
 
 #my $t = nms::ios_connect('62.148.36.12', 'c', 'c', 'c');
 
@@ -16,12 +16,22 @@ use ios;
 
 #nms::ios_close($t);
 
+my $oldip;
+my $newip;
+if ($#ARGV < 1) {
+       die "Foo $#ARGV";
+}
+
+$oldip = $ARGV[0];
+$newip = $ARGV[1];
+
 my $one = 0;
 
 my $switchip;
 #$switchip = "87.76.250.226" if $one;
-$switchip = "192.168.2.150" if $one;
-$switchip = "192.168.1.1" unless $one;
+#$switchip = "192.168.2.150" if $one;
+#$switchip = "192.168.1.1" unless $one;
+$switchip = $oldip;
 my $switch = switch_connect($switchip);
 
 my $cmds1 = <<EOF
@@ -66,8 +76,10 @@ foreach (split(/\n+/, $cmds1)) {
 }
 
 my $cmd;
-$cmd = "ip ifconfig swif0 192.168.1.1/24" if $one;
-$cmd = "ip ifconfig swif0 192.168.2.150/24" unless $one;
+#$cmd = "ip ifconfig swif0 192.168.1.1/24" if $one;
+#$cmd = "ip ifconfig swif0 192.168.2.150/24" unless $one;
+$cmd = "ip ifconfig swif0 $newip/24";
+
 print "Sending '$cmd'\n";
 my $pid = fork();
 if ($pid == 0) {
@@ -80,30 +92,32 @@ if ($pid == 0) {
        sleep 1;
 }
 $switch->close();
-print "Reconnecting... ";
-$switchip = "192.168.1.1" if $one;
-$switchip = "192.168.2.150" unless $one;
-autoflush STDOUT 1;
-print "Connecting to: $switchip...\n";
-my $i = 1;
-while(1) {
-       $switch = switch_connect($switchip);
-       
-       #print (defined($switch)? $switch : "foo") ." <---- switch\n";
-       if (defined($switch) || $switch) {
-               last;
-       }
-       printf("Waited $i seconds...\r");
-       $i++;
-       sleep 1;
-}
-print "\n";
 
-print $switch."\n";
-$cmd = "sys sw vlan1q svlan cpu 248";
-print "Sending '$cmd'\n";
+#print "Reconnecting... ";
+##$switchip = "192.168.1.1" if $one;
+##$switchip = "192.168.2.150" unless $one;
+#$switchip = $newip;
+#autoflush STDOUT 1;
+#print "Connecting to: $switchip...\n";
+#my $i = 1;
+#while(1) {
+#      $switch = switch_connect($switchip);
+#      
+#      #print (defined($switch)? $switch : "foo") ." <---- switch\n";
+#      if (defined($switch) || $switch) {
+#              last;
+#      }
+#      printf("Waited $i seconds...\r");
+#      $i++;
+#      sleep 1;
+#}
+#print "\n";
+
+#print $switch."\n";
+#$cmd = "sys sw vlan1q svlan cpu 248";
+#print "Sending '$cmd'\n";
 #print "XXX: No we did not...";
 #print Dumper($switch->cmd("ip ifconfig"));
 #print Dumper($switch->cmd("ip route status"));
-switch_exec($cmd, $switch, 1);
-$switch->close();
+#switch_exec($cmd, $switch, 1);
+