Index: fedkit/fed-tun.pl
===================================================================
--- fedkit/fed-tun.pl	(revision f64fa816aea8218515cc0900940696d700329c0a)
+++ fedkit/fed-tun.pl	(revision 803457931197ea1296fe15a6150b0f152d898c5a)
@@ -61,4 +61,6 @@
 my $ssh_port_fwds = "";
 my $remote_script_dir;		# location of the other sides fed-tun.pl
+my $event_repeater;		# The pathname of the event repeater
+my $remote_config_file;		# Config file for the other side
 
 if ($#ARGV != 0 && !getopts('df:r', \%opts)) {
@@ -97,4 +99,7 @@
     $type =~ tr/A-Z/a-z/;
     $remote_script_dir = $opts{'remotescriptdir'} || ".";
+    $event_repeater = $opts{'eventrepeater'};
+    $remote_config_file = $opts{'remoteconfigfile'};
+    $remote_config_file = "-f $remote_config_file" if $remote_config_file;
 
     if (defined($opts{'fsname'})) {
@@ -179,5 +184,6 @@
 	# the expected single line of output when the tunnel is connected.
 
-	open($SSHCMD[$count], "$SSH -w $count:$count $ssh_port_fwds -o \"StrictHostKeyChecking no\" $opts{'peer'}  \"$remote_script_dir/fed-tun.pl -r $addr $count\" |") or die "Failed to run ssh";
+	print "$SSH -w $count:$count $ssh_port_fwds -o \"StrictHostKeyChecking no\" $opts{'peer'}  \"$remote_script_dir/fed-tun.pl $remote_config_file -r $addr $count\"\n" if $debug;
+	open($SSHCMD[$count], "$SSH -w $count:$count $ssh_port_fwds -o \"StrictHostKeyChecking no\" $opts{'peer'}  \"$remote_script_dir/fed-tun.pl $remote_config_file -r $addr $count\" |") or die "Failed to run ssh";
 
 	my $check = <$SSHCMD[$count]>;  # Make sure something ran...
@@ -210,4 +216,34 @@
     &setup_bridging($tun, $bridge, $iface, $addr);
     print "Remote connection all set up!\n";  # Trigger other end with output
+
+    # If this is the first remote invocation on a control gateway, start the
+    # event repeater.
+
+    my $file = new IO::File(">/tmp/remote");
+    print($file "hello!!!\n") if $file;
+    if ( $count == 0 && $type ne "experiment" ) {
+	my $remote_pubsub_port = $PUBSUB_PORT - 1;  # There will be a local
+						    # pubsubd running, so we
+						    # dodge the port on the
+						    # remote tunnel node.
+	print($file "In here!\n");
+	# Make sure we have the relevant parameters
+	die "Missing event repeater params (No config file ?)\n"
+	    unless $event_repeater && $opts{'remoteexperiment'} && 
+	    $opts{'localexperiment'};
+
+	print "Starting event repeater\n" if $debug;
+	
+	print($file "$event_repeater -P $remote_pubsub_port -S localhost " . 
+	    "-E $opts{'remoteexperiment'} -e $opts{'localexperiment'}\n") 
+	    if $file;
+	# Connect to the forwarded pubsub port on this host to listen to the
+	# other experiment's events, and to the local experiment to forward
+	# events.
+	system("$event_repeater -P $remote_pubsub_port -S localhost " . 
+	    "-E $opts{'remoteexperiment'} -e $opts{'localexperiment'}");
+	warn "Event repeater returned $?\n" if $?;
+    }
+    $file->close() if $file;
 } else {
     print "inactive end of a connection, finishing" if ($debug);
Index: fedkit/splitter.pl
===================================================================
--- fedkit/splitter.pl	(revision f64fa816aea8218515cc0900940696d700329c0a)
+++ fedkit/splitter.pl	(revision 803457931197ea1296fe15a6150b0f152d898c5a)
@@ -10,5 +10,5 @@
 
 my @scripts = ("fed_bootstrap", "federate.sh", "smbmount.pl", 
-    "make_hosts", "fed-tun.pl");
+    "make_hosts", "fed-tun.pl", "fed_evrepeater" );
 my $local_script_dir = ".";
 my($pid, $gid);			# Process and group IDs for calling parse.tcl
@@ -638,6 +638,8 @@
 	my $ddomain =				# domain for the destination
 	    $tbparams->{$dtb}->{'domain'};
-	my $sproject =				# Project of the destination
+	my $sproject =				# Project of the source
 	    $tbparams->{$gateways}->{'project'};
+	my $dproject =				# Project of the destination
+	    $tbparams->{$dtb}->{'project'};
 	my $fs =				# Master fs node (FQDN)
 	    $tbparams->{$master}->{'fs'} .  $tbparams->{$master}->{'domain'};
@@ -648,5 +650,7 @@
 	    $tbparams->{$master}->{'domain'};
 	my $remote_script_dir =			# Remote fed script location
-	    "/proj/" . $tbparams->{$dtb}->{'project'} . "/exp/$eid/tmp";
+	    "/proj/" . $dproject . "/exp/$eid/tmp";
+	my $local_script_dir =			# Local fed script location
+	    "/proj/" . $sproject . "/exp/$eid/tmp";
 	my $active;				# Is this the active side of
 						# the connector?
@@ -656,7 +660,9 @@
 
 	my $conf_file = "$myname$sdomain.gw.conf";
+	my $remote_conf_file = "$desthost$ddomain.gw.conf";
 	# translate to lower case so the `hostname` hack for specifying
 	# configuration files works.
 	$conf_file =~ tr/A-Z/a-z/;
+	$remote_conf_file =~ tr/A-Z/a-z/;
 
 	# If either end of this link is in the master side of the testbed, that
@@ -684,4 +690,9 @@
 	print $gwconfig "Type: $type\n";
 	print $gwconfig "RemoteScriptDir: $remote_script_dir\n";
+	print $gwconfig "EventRepeater: $local_script_dir/fed_evrepeater\n";
+	print $gwconfig "RemoteExperiment: $dproject/$eid\n";
+	print $gwconfig "LocalExperiment: $sproject/$eid\n";
+	print $gwconfig "RemoteConfigFile: " . 
+	    "$remote_script_dir/$remote_conf_file\n";
 	print $gwconfig "Peer: $desthost$ddomain\n";
 	print $gwconfig "Pubkeys: " . 
