Commit 8df8b297 authored by Mac Newbold's avatar Mac Newbold

Fixed some bugs. Can now run using "su1 ifc_<...> ..." from plastic.

parent 80bffc81
#!/usr/bin/perl
my $rsh = "ssh";
if ( $#ARGV < 0) {
die("Usage: ifc_all <ifc_file>\n");
}
......@@ -40,7 +43,7 @@ while (<IN>) {
do { } until ( <PING> =~ /transmitted, (\d*) packets received/ );
print "Got $1 ping packet(s) back from $IP.\n";
if ( $1 > 0 ) {
open(UNAME,"rsh $IP uname -a 2>&1 |");
open(UNAME,"$rsh $IP uname -a 2>&1 |");
$_ = <UNAME>;
#print $_;
if ($_ ) { @temp = split(" ",$_); $OS = $temp[$0]; }
......@@ -61,7 +64,7 @@ while (<IN>) {
}
print "Setting $IP $ifstr$IF to $newIP...\n";
open(IFC,
"rsh $IP /sbin/ifconfig $ifstr$IF inet $newIP ".
"$rsh $IP /sbin/ifconfig $ifstr$IF inet $newIP ".
"netmask 255.255.255.0 2>&1 |"
);
while ( <IFC> ) {
......
#!/usr/bin/perl
my $rsh = "ssh";
my $rcp = "scp";
if ( $#ARGV < 0) {
die("Usage: ifc_boot <ifc_file>\n".
"(Sets network configurations for booting)\n");
......@@ -41,7 +45,7 @@ while (<IN>) {
do { } until ( <PING> =~ /transmitted, (\d*) packets received/ );
print "Got $1 ping packet(s) back from $IP.\n";
if ( $1 > 0 ) {
open(UNAME,"rsh $IP uname -a 2>&1 |");
open(UNAME,"$rsh $IP uname -a 2>&1 |");
$_ = <UNAME>;
#print $_;
if ($_ ) { @temp = split(" ",$_); $OS = $temp[$0]; }
......@@ -81,8 +85,8 @@ while (<IN>) {
my $host = `uname -n`;
$host =~ s/\n//;
open(IFC,
"rsh $IP rcp $host:/tmp/ifc_boot_file ".
"/etc/sysconfig/network-scripts/ifcfg-$ifstr$IF |"
"$rcp /tmp/ifc_boot_file ".
"$IP:/etc/sysconfig/network-scripts/ifcfg-$ifstr$IF |"
);
while ( <IFC> ) {
print ">> $_";
......
......@@ -3,6 +3,8 @@
# Takes input IR file on STDIN, and dumps IFC file to STDOUT.
#
my $d = 0; #debug
my $go=0;
my $ipsection=0;
my %ips = ();
......@@ -11,29 +13,41 @@ my %nodeips = ();
my %ifs = ();
while ( <> ) {
if ( /^start ip/i ) { $ipsection=1; }
if ( /^start ip/i ) {
$ipsection=1;
print STDERR "Found IP section...\t" if $d;
}
elsif ( /^end ip/i ) { $ipsection=0; }
elsif ( /^start mac/i ) { $go=1; }
elsif ( /^start mac/i ) {
$go=1;
print STDERR "Found MAC section:\n" if $d;
}
elsif ( /^end mac/i ) { $go=0; }
elsif ( $go ) {
my ($mac,$ip) = split();
print STDERR "Read: $mac <==> $ip\n" if $d;
$ips{$mac} = $ip;
}
}
print STDERR "Input done.\n" if $d;
my $path="";
if ( -x "/usr/testbed/bin/mac2if" ) { $path="/usr/testbed/bin/" }
elsif ( -x "mac2if" ) { $path=""; }
elsif ( -x "./mac2if" ) { $path="./"; }
elsif ( -x "/home/newbold/db/mac2if" ) { $path="/home/newbold/db/"; }
open(MAC2IF,"$path"."mac2if ".join(" ",keys %ips)." |");
my $cmd = "$path"."mac2if ".join(" ",keys %ips)." |";
print STDERR "Calling $cmd\n" if $d;
open(MAC2IF,$cmd);
while ( <MAC2IF> ) {
if (! /^\|/ ) {next;}
if ( /^\|node_id/ ) {next;}
s/ *|\t*//g;
s/^\|//;
my ($node,$ifc,$mac) = split(/\|/,$_);
print STDERR "Read $node:$ifc <==> $mac\n" if $d;
$nodes{$mac} = $node;
$ifs{$mac} = $ifc;
}
......@@ -43,7 +57,9 @@ elsif ( -x "nodeip" ) { $path=""; }
elsif ( -x "./nodeip" ) { $path="./"; }
elsif ( -x "/home/newbold/db/nodeip" ) { $path="/home/newbold/db/"; }
open(NODEIP,"$path"."nodeip ".join(" ",values %nodes)." |");
$cmd = "$path"."nodeip ".join(" ",values %nodes)." |";
print STDERR "Calling $cmd\n" if $d;
open(NODEIP,$cmd);
while ( <NODEIP> ) {
if (! /^\|/ ) {next;}
if ( /^\|node_id/ ) {next;}
......@@ -52,6 +68,7 @@ while ( <NODEIP> ) {
my ($node,$ifc,$ip) = split(/\|/,$_);
if ($node =~ /^tbpc/) { if ($ifc==4) { $nodeip{$node} = $ip; } }
else { if ($ifc==1) { $nodeip{$node} = $ip; } }
print STDERR "Read $node <==> $nodeip{$node}\n" if $d;
}
print "# This ifc file generated by ir2ifc\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment