source: fedkit/active_config.pl @ 43649f1

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

Add support for parameters via files in a standard emulab location

Also moved combo_active.pl to combo.pl and added support for passive gateways.

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[2edec46]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";
[8d4e4fb]17my $iface_file = "/var/emulab/boot/ifmap";
[2edec46]18my $ssh = "/usr/bin/ssh";
[8d4e4fb]19my $use_file;
[2edec46]20
[8d4e4fb]21my %opts = (
[2edec46]22    'ssh_pubkey=s' => \$ssh_pubkey,
23    'ssh_privkey=s' => \$ssh_privkey,
24    'tunnelip' => \$tunnelip,
25    'peer=s' => \$peer,
26    'fedkit=s' => \$fedkit_dir,
27    'perl=s' => \$perl,
28    'interfaces=s' => \$iface_file,
29    'ssh=s' => \$ssh,
[8d4e4fb]30    'use_file' => \$use_file,
[2edec46]31);
32
[8d4e4fb]33exit(20) unless GetOptions(%opts);
34
35gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts)
36    if $use_file;
[2edec46]37
38my $tunnelparam = $tunnelip ? '--tunnelip' : '';
39
40system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/prep_gateway.pl --peer=$peer " .
41    "--ssh_pubkey=$ssh_pubkey $tunnelparam");
42exit(20) if $?;
43
44my $f = new IO::File($iface_file) || die "Can't open $iface_file: $!\n";
45my $ifnum = 0;
46
47while (<$f>) {
48    /([[:alnum:]]+)\s+([\d\.]+)/ && do {
49        my ($iface, $addr) = ($1, $2);
50
51        my $cmd = "$ssh -w $ifnum:$ifnum -o \"Tunnel ethernet\" " . 
52            "-o \"StrictHostKeyChecking no\" -i $ssh_privkey " .
53            "$peer perl -I$fedkit_dir/lib $fedkit_dir/bin/setup_bridge.pl " .
54            "--tapno=$ifnum --dest=$addr &";
55        system($cmd);
56        die if $?;
57        gateway_lib::bind_tap_to_iface($ifnum, $iface, $addr);
58        $ifnum++;
59    };
60}
61$f->close();
62exit(0);
[2b35261]63
64=pod
65
66=head1 NAME
67
68B<active_config.pl> - Configure an active connectivity gateway under the DETER Federation Architecture
69
70=head1 OPTIONS
71
72=over 8
73
74=item B<fedkit=>I<install_dir>
75
76Directory in which this software is installed.  Generally not needed.
77
78=item B<interfaces=>I<interface table>
79
80A list of interfaces to forward data on of the form:
81
82=begin text
83
84iface ip_addr
85
86=end text
87
88The interface is the operating system name of the interface and the IP address
89is given in standard dotted decimal notation.  Other characters on a line are
90ignored.
91
92=item B<peer=>I<hostname>
93
94The other gateway providing forwarding.
95
96=item B<perl=>I<perl_binary>
97 
98Location of the perl binary.  Usually unneeded.
99
100=item B<ssh=>I<ssh_binary>
101
102The pathname of the ssh binary.  Unusally unnecessary.
103
104=item B<ssh_pubkey=>I<keyfile>
105
106A public to install as authorized.
107
108=item B<ssh_privkey=>I<identity_file>
109
110The identity to use for remote access
111
112=item B<tunnelip>
113
114True if the testbed uses the DETER tunnelip extension to provide external
115connectivity information
116
[8d4e4fb]117=item B<use_file>
118
119If given read additional parameters from the file in
120/proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the
121current testbed project and experiment and the hostname is before the first
122dot.  The file is option: value.
123
124
[2b35261]125=back
126
127=head1 SYNOPSIS
128
129B<active_config.pl> initiates the active side of the connectivity connection,
130which is to say that it:
131
132=over 4
133
134=item *
135
136Installs local keys and reconfigures that local ssh system to do link layer
137tunneling.
138
139=item *
140
141Starts a tunnel for each interface in the given interface table, both locally
142and remotely.
143
144=back
145
146=head1 AUTHORS
147
148Ted Faber <faber@isi.edu>
149
150=cut
Note: See TracBrowser for help on using the repository browser.