source: fedkit/active_config.pl @ 2edec46

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since 2edec46 was 2edec46, checked in by Ted Faber <faber@…>, 15 years ago

Factored gateway implementation. Initial import.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4
5use gateway_lib;
6
7use IO::File;
8
9use Getopt::Long;
10
11my $ssh_pubkey;
12my $ssh_privkey;
13my $tunnelip;
14my $peer;
15my $fedkit_dir= "/usr/local/federation";
16my $perl = "/usr/bin/perl";
17my $iface_file;
18my $ssh = "/usr/bin/ssh";
19
20exit(20) unless GetOptions(
21    'ssh_pubkey=s' => \$ssh_pubkey,
22    'ssh_privkey=s' => \$ssh_privkey,
23    'tunnelip' => \$tunnelip,
24    'peer=s' => \$peer,
25    'fedkit=s' => \$fedkit_dir,
26    'perl=s' => \$perl,
27    'interfaces=s' => \$iface_file,
28    'ssh=s' => \$ssh,
29);
30
31
32my $tunnelparam = $tunnelip ? '--tunnelip' : '';
33
34system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/prep_gateway.pl --peer=$peer " .
35    "--ssh_pubkey=$ssh_pubkey $tunnelparam");
36exit(20) if $?;
37
38my $f = new IO::File($iface_file) || die "Can't open $iface_file: $!\n";
39my $ifnum = 0;
40
41while (<$f>) {
42    /([[:alnum:]]+)\s+([\d\.]+)/ && do {
43        my ($iface, $addr) = ($1, $2);
44
45        my $cmd = "$ssh -w $ifnum:$ifnum -o \"Tunnel ethernet\" " . 
46            "-o \"StrictHostKeyChecking no\" -i $ssh_privkey " .
47            "$peer perl -I$fedkit_dir/lib $fedkit_dir/bin/setup_bridge.pl " .
48            "--tapno=$ifnum --dest=$addr &";
49        system($cmd);
50        die if $?;
51        gateway_lib::bind_tap_to_iface($ifnum, $iface, $addr);
52        $ifnum++;
53    };
54}
55$f->close();
56exit(0);
Note: See TracBrowser for help on using the repository browser.