1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | |
---|
5 | use gateway_lib; |
---|
6 | |
---|
7 | use IO::File; |
---|
8 | |
---|
9 | use Getopt::Long; |
---|
10 | |
---|
11 | my $ssh_pubkey; |
---|
12 | my $ssh_privkey; |
---|
13 | my $active; |
---|
14 | my $tunnelip; |
---|
15 | my $peer; |
---|
16 | my $fedkit_dir= "/usr/local/federation"; |
---|
17 | my $perl = "/usr/bin/perl"; |
---|
18 | my $iface_file = "/var/emulab/boot/ifmap"; |
---|
19 | my $ssh = "/usr/bin/ssh"; |
---|
20 | my $ssh_port = 22; |
---|
21 | my @ports; |
---|
22 | my $use_file; |
---|
23 | |
---|
24 | my %opts = ( |
---|
25 | 'ssh_pubkey=s' => \$ssh_pubkey, |
---|
26 | 'ssh_privkey=s' => \$ssh_privkey, |
---|
27 | 'tunnelip' => \$tunnelip, |
---|
28 | 'peer=s' => \$peer, |
---|
29 | 'fedkit=s' => \$fedkit_dir, |
---|
30 | 'perl=s' => \$perl, |
---|
31 | 'interfaces=s' => \$iface_file, |
---|
32 | 'ssh=s' => \$ssh, |
---|
33 | 'port=s' => \@ports, |
---|
34 | 'active' => \$active, |
---|
35 | 'ssh_port=s' => \$ssh_port, |
---|
36 | 'use_file' => \$use_file, |
---|
37 | ); |
---|
38 | |
---|
39 | exit(20) unless GetOptions(%opts); |
---|
40 | |
---|
41 | if ($use_file) { |
---|
42 | gateway_lib::read_config(gateway_lib::config_filename(), \%opts) |
---|
43 | } |
---|
44 | |
---|
45 | my $tunnelparam = $tunnelip ? '--tunnelip' : ''; |
---|
46 | if ($active) { |
---|
47 | my $portparam = join(" --port=", @ports); |
---|
48 | |
---|
49 | # join doesn't prefix the first one |
---|
50 | $portparam="--port=$portparam" if $portparam; |
---|
51 | |
---|
52 | system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/active_config.pl " . |
---|
53 | "--peer=$peer --ssh_pubkey=$ssh_pubkey --ssh_privkey=$ssh_privkey " . |
---|
54 | " $tunnelparam --fedkit=$fedkit_dir --perl=$perl " . |
---|
55 | "--ssh_port=$ssh_port --ssh=$ssh --interfaces=$iface_file"); |
---|
56 | exit(20) if $?; |
---|
57 | |
---|
58 | system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/port_forward.pl " . |
---|
59 | "--peer=$peer --ssh_pubkey=$ssh_pubkey --ssh_privkey=$ssh_privkey " . |
---|
60 | " $tunnelparam --fedkit=$fedkit_dir --perl=$perl " . |
---|
61 | "--ssh=$ssh --ssh_port=$ssh_port $portparam"); |
---|
62 | exit(20) if $?; |
---|
63 | } |
---|
64 | else { |
---|
65 | system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/prep_gateway.pl " . |
---|
66 | "--peer=$peer --ssh_pubkey=$ssh_pubkey $tunnelparam"); |
---|
67 | exit(20) if $?; |
---|
68 | } |
---|
69 | |
---|
70 | =pod |
---|
71 | |
---|
72 | =head1 NAME |
---|
73 | |
---|
74 | B<combo_active.pl> - Do both the active configuration of a connectiveity gateway and service port forwarding. |
---|
75 | |
---|
76 | =head1 OPTIONS |
---|
77 | |
---|
78 | =over 8 |
---|
79 | |
---|
80 | =item B<fedkit=>I<install_dir> |
---|
81 | |
---|
82 | Directory in which this software is installed. Generally not needed. |
---|
83 | |
---|
84 | =item B<interfaces=>I<interface table> |
---|
85 | |
---|
86 | A list of interfaces to forward data on of the form: |
---|
87 | |
---|
88 | =begin text |
---|
89 | |
---|
90 | iface ip_addr |
---|
91 | |
---|
92 | =end text |
---|
93 | |
---|
94 | The interface is the operating system name of the interface and the IP address |
---|
95 | is given in standard dotted decimal notation. Other characters on a line are |
---|
96 | ignored. |
---|
97 | |
---|
98 | =item B<peer=>I<hostname> |
---|
99 | |
---|
100 | The other gateway providing forwarding. |
---|
101 | |
---|
102 | =item B<perl=>I<perl_binary> |
---|
103 | |
---|
104 | Location of the perl binary. Usually unneeded. |
---|
105 | |
---|
106 | =item B<port=>I<port_spec> |
---|
107 | |
---|
108 | Forward the given port. The port is specified as |
---|
109 | for B<port_forward.pl> |
---|
110 | |
---|
111 | =item B<ssh=>I<ssh_binary> |
---|
112 | |
---|
113 | The pathname of the ssh binary. Unusally unnecessary. |
---|
114 | |
---|
115 | =item B<ssh_pubkey=>I<keyfile> |
---|
116 | |
---|
117 | A public to install as authorized. |
---|
118 | |
---|
119 | =item B<ssh_privkey=>I<identity_file> |
---|
120 | |
---|
121 | The identity to use for remote access |
---|
122 | |
---|
123 | =item B<tunnelip> |
---|
124 | |
---|
125 | True if the testbed uses the DETER tunnelip extension to provide external |
---|
126 | connectivity information |
---|
127 | |
---|
128 | =item B<use_file> |
---|
129 | |
---|
130 | If given read additional parameters from the file in |
---|
131 | /proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the |
---|
132 | current testbed project and experiment and the hostname is before the first |
---|
133 | dot. The file is option: value. |
---|
134 | |
---|
135 | =back |
---|
136 | |
---|
137 | =head1 SYNOPSIS |
---|
138 | |
---|
139 | Call B<active_config.pl> and B<port_forward.pl> with the relevant parameters. |
---|
140 | |
---|
141 | |
---|
142 | =head1 AUTHORS |
---|
143 | |
---|
144 | Ted Faber <faber@isi.edu> |
---|
145 | |
---|
146 | =cut |
---|