Changeset f8fa72b
- Timestamp:
- Mar 5, 2010 3:26:09 AM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 444790d
- Parents:
- c119839
- Location:
- fedkit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
fedkit/active_config.pl
rc119839 rf8fa72b 17 17 my $iface_file = "/var/emulab/boot/ifmap"; 18 18 my $ssh = "/usr/bin/ssh"; 19 my $ use_file;19 my $ssh_port = 22; 20 20 21 21 my %opts = ( … … 28 28 'interfaces=s' => \$iface_file, 29 29 'ssh=s' => \$ssh, 30 'ssh_port=s' => \$ssh_port, 30 31 'use_file' => \$use_file, 31 32 ); … … 33 34 exit(20) unless GetOptions(%opts); 34 35 35 gateway_lib::read_config(gateway_lib:: emulab_config_filename(), \%opts)36 gateway_lib::read_config(gateway_lib::config_filename(), \%opts) 36 37 if $use_file; 37 38 … … 56 57 my ($iface, $addr) = ($1, $2); 57 58 58 my $cmd = "$ssh -w $ifnum:$ifnum - o \"Tunnel ethernet\"" .59 "-o \" StrictHostKeyChecking no\" -i $ssh_privkey" .60 " $peer perl -I$fedkit_dir/lib $fedkit_dir/bin/setup_bridge.pl ".61 " --tapno=$ifnum --dest=$addr &";59 my $cmd = "$ssh -w $ifnum:$ifnum -p $ssh_port " . 60 "-o \"Tunnel ethernet\" -o \"StrictHostKeyChecking no\" " . 61 "-i $ssh_privkey $peer perl -I$fedkit_dir/lib ". 62 "$fedkit_dir/bin/setup_bridge.pl --tapno=$ifnum --dest=$addr &"; 62 63 system($cmd); 63 64 die if $?; -
fedkit/combo.pl
rc119839 rf8fa72b 18 18 my $iface_file = "/var/emulab/boot/ifmap"; 19 19 my $ssh = "/usr/bin/ssh"; 20 my $ssh_port = 22; 20 21 my @ports; 21 22 my $use_file; … … 32 33 'port=s' => \@ports, 33 34 'active' => \$active, 35 'ssh_port=s' => \$ssh_port, 34 36 'use_file' => \$use_file, 35 37 ); … … 37 39 exit(20) unless GetOptions(%opts); 38 40 39 gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts) 40 if $use_file; 41 if ($use_file) { 42 gateway_lib::read_config(gateway_lib::config_filename(), \%opts) 43 } 41 44 42 45 my $tunnelparam = $tunnelip ? '--tunnelip' : ''; … … 50 53 "--peer=$peer --ssh_pubkey=$ssh_pubkey --ssh_privkey=$ssh_privkey " . 51 54 " $tunnelparam --fedkit=$fedkit_dir --perl=$perl " . 52 "--ssh =$ssh --interfaces=$iface_file");55 "--ssh_port=$ssh_port --ssh=$ssh --interfaces=$iface_file"); 53 56 exit(20) if $?; 54 57 -
fedkit/federate.pl
rc119839 rf8fa72b 3 3 4 4 use strict; 5 6 use Getopt::Long; 5 7 6 8 use IO::File; … … 29 31 my $exp; 30 32 my $proj; 33 my $install_smb; 31 34 chomp (my $uname = `uname`); 32 35 my $smbmount = "smbmount.$uname.pl"; 36 37 GetOptions("install_samba" => \$install_smb); 33 38 34 39 # find perl … … 41 46 $perl = "perl" unless $perl; 42 47 48 if ($install_smb) { 49 # fix yum.conf 50 copy("/etc/yum.conf", "/etc/yum.conf.bak"); 51 my $from = new IO::File("/etc/yum.conf.bak"); 52 my $to = new IO::File(">/etc/yum.conf"); 53 while (<$from>) { 54 s/download.fedoralegacy.org/fedoralegacy.lsu.edu/g; 55 print $to $_; 56 } 57 $from->close(); 58 $to->close(); 59 # Now, bridging 60 system('/usr/bin/yum -y install samba-client'); 61 } 43 62 44 $tmcc_p->reader("$TMCC -b status"); 45 while (<$tmcc_p>) { 46 /ALLOCATED=([^\/]+)\/(\S+)/ && do { 47 ($proj, $exp) = ($1, $2); 48 $shared_config_dir = "/proj/$proj/exp/$exp/tmp"; 49 last; 50 }; 51 } 52 $tmcc_p->close(); 63 if (!-e "$local_config_dir/client.conf" ) { 64 $tmcc_p->reader("$TMCC -b status"); 65 while (<$tmcc_p>) { 66 /ALLOCATED=([^\/]+)\/(\S+)/ && do { 67 ($proj, $exp) = ($1, $2); 68 $shared_config_dir = "/proj/$proj/exp/$exp/tmp"; 69 last; 70 }; 71 } 72 $tmcc_p->close(); 53 73 54 mkdir($local_config_dir);74 mkdir($local_config_dir); 55 75 56 foreach my $fn ("seer.conf", "client.conf", "userconf") { 57 copy("$shared_config_dir/$fn", $local_config_dir ) 58 if -e "$shared_config_dir/$fn"; 76 foreach my $fn ("seer.conf", "client.conf", "userconf", "hosts") { 77 copy("$shared_config_dir/$fn", $local_config_dir ) 78 if -e "$shared_config_dir/$fn"; 79 } 59 80 } 60 81 … … 72 93 my $hosts = new IO::File("/etc/hosts") || die "Can't open /etc/hosts:$!\n"; 73 94 my $new_hosts = new IO::File(">/tmp/hosts") || die "Can't open /tmp/hosts:$!\n"; 74 my $config_hosts = new IO::File("$ shared_config_dir/hosts") ||75 die "Can't open $ shared_config_dir/hosts: $!\n";95 my $config_hosts = new IO::File("$local_config_dir/hosts") || 96 die "Can't open $local_config_dir/hosts: $!\n"; 76 97 my $has_control = 0; 77 98 … … 112 133 113 134 if ($services{'userconfig'}) { 114 $tmcc_p = new IO::Pipe() || die "Can't open pipe for accounts:$!\n"; 115 my $old_accounts = new IO::File(">$local_config_dir/old_accts") || 116 die "Can't open $local_config_dir/old_accts: $!\n"; 135 if (!-e "$local_config_dir/old_accts") { 136 $tmcc_p = new IO::Pipe() || die "Can't open pipe for accounts:$!\n"; 137 my $old_accounts = new IO::File(">$local_config_dir/old_accts") || 138 die "Can't open $local_config_dir/old_accts: $!\n"; 117 139 118 $tmcc_p->reader("$TMCC -b accounts"); 119 while (<$tmcc_p>) { 120 print $old_accounts $_; 140 $tmcc_p->reader("$TMCC -b accounts"); 141 while (<$tmcc_p>) { 142 print $old_accounts $_; 143 } 144 $tmcc_p->close(); 145 $old_accounts->close(); 121 146 } 122 $tmcc_p->close();123 $old_accounts->close();124 147 print("Updating accounts"); 125 148 system("/usr/local/federation/bin/rc.fedaccounts"); -
fedkit/gateway_lib.pm
rc119839 rf8fa72b 27 27 my $FINDIF = "/usr/local/etc/emulab/findif"; 28 28 my $TMCC = "/usr/local/etc/emulab/tmcc"; 29 30 # Linux choices 31 my $BRCTL = "/usr/sbin/brctl"; 32 my $IPROUTE = "/sbin/ip route "; 29 33 30 34 # Takes an ssh config file and a reference to a hash of keys whose values must … … 176 180 } 177 181 178 system("ifconfig $bridge create"); 179 warn "Cannot create bridge: $?\n" if $?; 180 foreach my $a (@addr) { 181 system("ifconfig $iface delete $a"); 182 warn "Cannot delete address $a: $?\n" if $?; 183 } 184 system("ifconfig $bridge addm $iface up"); 185 warn "Cannot add intefrace $iface to bridge: $?\n" if $?; 186 system("ifconfig $bridge addm $tap"); 187 warn "Cannot add intefrace $tap to bridge: $?\n" if $?; 188 return $?; 182 my $uname = `uname`; 183 chomp $uname; 184 185 if ($uname =~ /FreeBSD/) { 186 system("ifconfig $bridge create"); 187 warn "Cannot create bridge: $?\n" if $?; 188 foreach my $a (@addr) { 189 system("ifconfig $iface delete $a"); 190 warn "Cannot delete address $a: $?\n" if $?; 191 } 192 system("ifconfig $bridge addm $iface up"); 193 warn "Cannot add intefrace $iface to bridge: $?\n" if $?; 194 system("ifconfig $bridge addm $tap"); 195 warn "Cannot add intefrace $tap to bridge: $?\n" if $?; 196 return $?; 197 } 198 elsif ($uname =~ /Linux/) { 199 system("$IFCONFIG $iface 0.0.0.0 down"); 200 system("$BRCTL addbr $bridge"); 201 warn "Cannot create bridge: $?\n" if $?; 202 system("$BRCTL addif $bridge $tap"); 203 system("$BRCTL addif $bridge $iface"); 204 system("$BRCTL stp $bridge off"); 205 system("$IFCONFIG $bridge up"); 206 system("$IFCONFIG $tap up"); 207 system("$IFCONFIG $iface up"); 208 return $?; 209 } 189 210 } 190 211 … … 194 215 my $ipipe = new IO::Pipe() || die "Can't create pipe for ifconfig: $!\n"; 195 216 my @addr; 217 my $uname = `uname`; 218 my $ipre = "inet\\s+([0-9\\.]+)"; 219 chomp $uname; 220 221 if ($uname =~ /Linux/) { 222 $ipre = "inet\\s+addr:\\s*([0-9\\.]+)"; 223 } 196 224 197 225 $ipipe->reader("$IFCONFIG $iface"); 198 226 while(<$ipipe>) { 199 / inet\s+([0-9\.]+)/ && push(@addr, $1);227 /$ipre/ && push(@addr, $1); 200 228 } 201 229 $ipipe->close(); … … 207 235 my($dest) =@_; 208 236 my $rpipe = new IO::Pipe() || die "Can't create pipe for route: $!\n"; 209 210 $rpipe->reader("$ROUTE get $dest"); 237 my $uname = `uname`; 238 chomp $uname; 239 my $route; 240 my $dev_re; 241 242 if ($uname =~ /Linux/) { 243 $route = $IPROUTE; 244 $dev_re = "\\s+dev\\s+(\\S+)"; 245 } 246 elsif ($uname =~ /FreeBSD/) { 247 $route = $ROUTE; 248 $dev_re = 'interface:\\s*([[:alnum:]]+)'; 249 } 250 251 252 print "$route get $dest\n"; 253 $rpipe->reader("$route get $dest"); 211 254 while (<$rpipe>) { 212 / interface:\s*([[:alnum:]]+)/ && do {255 /$dev_re/ && do { 213 256 my $iface = $1; 214 257 $rpipe->close(); 258 print "matched: $iface\n"; 215 259 return $iface; 216 260 }; … … 290 334 291 335 292 sub emulab_config_filename { 293 # Find the configuration file in the usual place, which depends on what 294 # experiment and project we're in. 336 sub config_filename { 337 # Find the configuration file in the usual places, if there is one in 338 # /usr/local/federation/etc, use it, otherwise look in the emulab standard 339 # filesystems which depends on what experiment and project we're in. 295 340 my $pid; 296 341 my $eid; 297 342 my $filename; 343 my $fed_dir = "/usr/local/federation/etc/"; 344 my $hn = `hostname`; 345 chomp $hn; 346 $hn =~ s/\..*//; 347 348 return "$fed_dir/$hn.gw.conf" if -r "$fed_dir/$hn.gw.conf"; 349 298 350 my $tmcd = new IO::Pipe() || die "Can't create pipe: $!\n"; 299 351 … … 308 360 } 309 361 $tmcd->close(); 310 my $hn = `hostname`;311 chomp $hn;312 $hn =~ s/\..*//;313 362 $filename = "/proj/$pid/exp/$eid/tmp/$hn.gw.conf" 314 363 if $pid and $eid; … … 316 365 return $filename; 317 366 } 367 318 368 319 369 sub wait_for_port { -
fedkit/prep_gateway.pl
rc119839 rf8fa72b 6 6 7 7 use Getopt::Long; 8 use File::Copy; 9 use IO::File; 8 10 9 11 my $ssh_pubkey; … … 20 22 exit(20) unless GetOptions(%opts); 21 23 22 gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts) 23 if $use_file; 24 if ($use_file) { 25 gateway_lib::read_config(gateway_lib::config_filename(), \%opts) 26 } 24 27 25 gateway_lib::set_sshd_params( 26 { 'GatewayPorts' => 'yes', 'PermitTunnel' => 'yes' } ); 27 system("/etc/rc.d/sshd restart"); 28 my $uname = `uname`; 29 chomp $uname; 28 30 29 gateway_lib::import_key($ssh_pubkey,'/root/.ssh/authorized_keys') 30 if $ssh_pubkey; 31 if ($uname =~ /Linux/) { 32 # Right now the only gateway nodes that are Linux nodes are ProtoGENI 33 # nodes. They need a bunch of custom updates to get into the 21st century, 34 # but they are on the network. 35 if ( -x '/usr/local/federation/bin/sshd' && 36 -e '/usr/local/federation/etc/sshd_config') { 37 # Start our modern sshd if one is there 38 system("/usr/local/federation/bin/sshd -p 20200 -f " . 39 "/usr/local/federation/etc/sshd_config"); 40 } 41 # fix yum.conf 42 copy("/etc/yum.conf", "/etc/yum.conf.bak"); 43 my $from = new IO::File("/etc/yum.conf.bak"); 44 my $to = new IO::File(">/etc/yum.conf"); 45 while (<$from>) { 46 s/download.fedoralegacy.org/fedoralegacy.lsu.edu/g; 47 print $to $_; 48 } 49 $from->close(); 50 $to->close(); 51 # Now, bridging 52 system('/usr/bin/yum -y install bridge-utils'); 53 #and keys 54 gateway_lib::import_key($ssh_pubkey,'/root/.ssh/authorized_keys') 55 if $ssh_pubkey; 56 } 57 elsif ($uname =~ /FreeBSD/ ){ 58 gateway_lib::set_sshd_params( 59 { 'GatewayPorts' => 'yes', 'PermitTunnel' => 'yes' } ); 60 system("/etc/rc.d/sshd restart"); 31 61 32 # Need these to make the Ethernet tap and bridge work. 33 system("kldload /boot/kernel/bridgestp.ko") 34 if -r "/boot/kernel/bridgestp.ko"; 35 system("kldload /boot/kernel/if_bridge.ko"); 36 system("kldload /boot/kernel/if_tap.ko"); 62 gateway_lib::import_key($ssh_pubkey,'/root/.ssh/authorized_keys') 63 if $ssh_pubkey; 64 65 # Need these to make the Ethernet tap and bridge work. 66 system("kldload /boot/kernel/bridgestp.ko") 67 if -r "/boot/kernel/bridgestp.ko"; 68 system("kldload /boot/kernel/if_bridge.ko"); 69 system("kldload /boot/kernel/if_tap.ko"); 70 } 37 71 38 72 if ( $tunnelip ) {
Note: See TracChangeset
for help on using the changeset viewer.