Index: fedkit/federate.sh
===================================================================
--- fedkit/federate.sh	(revision 61f19e0091c0d6c6684209b50bef81099721e923)
+++ fedkit/federate.sh	(revision 63f7c7e4cd48d49acd4a12961a57cff382e0ecc2)
@@ -3,4 +3,11 @@
 BOSSNODE="/usr/local/etc/emulab/bossnode"
 # GATEWAY="detertunnel"
+
+PORTS="139 7777"
+NC="/usr/bin/nc"
+RCDIR="/usr/local/etc/emulab/rc"
+
+RCACCT="rc.accounts"
+SMBMOUNT="smbmount.pl"
 
 if [ -f $BOSSNODE ]
@@ -10,12 +17,25 @@
 
 EMUDIR="/usr/local/etc/emulab/"
+
+# Find this experiment's stashed scripts.  (Perl for advanced parsing)
+SCRIPTDIR=`$EMUDIR/tmcc -b status | perl -ne '/ALLOCATED=([^\/]+)\/([^\s]+)/ && print "/proj/$1/exp/$2/tmp\n";'`
+
+# Die if things are weird
+if [ -z "$SCRIPTDIR" ] ; then
+    echo "Can't find federation scripts.  Tmcc status says:"
+    $EMUDIR/tmcc -b status
+    exit 1;
+fi
+
+# Move the SMB mounting script out of NFS so we can call it after the umount
+cp "$SCRIPTDIR/$SMBMOUNT" /tmp
+
+# Copy the global hostnames file into /etc/hosts so this node can address
+# others in the experiment on other testbeds.
+grep 127\\.0\\.0\\.1 /etc/hosts > /tmp/hosts
+cat "$SCRIPTDIR/hosts" >> /tmp/hosts
+cp /tmp/hosts /etc/hosts && rm /tmp/hosts
+
 GATEWAY=`$EMUDIR/tmcc -b syncserver | awk ' { match($0, /SERVER=[^[:space:]]+/); print substr($0,RSTART+8,RLENGTH-9);}'`
-
-PORTS="139 7777"
-NC="/usr/bin/nc"
-RCDIR="/usr/local/etc/emulab/rc"
-
-RCACCT="rc.accounts"
-SMBMOUNT="smbmount.pl"
 
 #
@@ -43,4 +63,5 @@
 echo $GATEWAY > $BOSSNODE
 
+
 #
 # Unmount stuff before messing with accounts
@@ -60,3 +81,3 @@
 echo "Mounting via SMB."
 
-exec $EMUDIR/$SMBMOUNT
+exec "/tmp/$SMBMOUNT"
Index: fedkit/splitter.pl
===================================================================
--- fedkit/splitter.pl	(revision 61f19e0091c0d6c6684209b50bef81099721e923)
+++ fedkit/splitter.pl	(revision 63f7c7e4cd48d49acd4a12961a57cff382e0ecc2)
@@ -2,4 +2,7 @@
 
 use Getopt::Std;
+
+@scripts = ("federate.sh", "smbmount.pl");
+$local_script_dir = ".";
 
 # use scp to transfer a file, reporting true if successful and false otherwise.
@@ -41,4 +44,18 @@
     }
     else { return 1; }
+}
+
+# Ship local copies of the federation scripts out to the given host.  If any of
+# the script transfers fails, return 0.  The scripts to transfer are from the
+# global @scripts and are found locally in $local_script_dir (another global).
+sub ship_scripts {
+    my($host, $user, $dest_dir) = @_;	    # Where, who, where remotely
+    my($s);
+
+    for $s (@scripts) {
+	&scp_file("$local_script_dir/$s", "$user\@$host", $dest_dir) || 
+	    return 0;
+    }
+    return 1;
 }
 
@@ -60,5 +77,6 @@
     my($tclfile) = "./$eid.$tb.tcl";	    # Local tcl file with the
 					    # sub-experiment
-    my($to_hostname) = "/proj/$pid/hosts.$eid"; # remote hostnames file
+    my($proj_dir) = "/proj/$pid/exp/$eid/tmp";  # Where to stash federation stuff
+    my($to_hostname) = "$proj_dir/hosts";   # remote hostnames file
 
     # Determine the status of the remote experiment
@@ -79,12 +97,14 @@
     print "$tb: $state\n";
 
-    # Copy the configuration data over (unless the host is local)
+    # Copy the experiment definition data over (unless the host is local)
     if ( $host ne "localhost") {
 	&scp_file($tclfile, "$user\@$host") || return 0;
-	&scp_file("./hostnames", "$user\@$host", $to_hostname) || return 0;
     }
 
     # Remote experiment is active.  Modify it.
     if ($state eq "active") {
+	# First copy new scripts and hostinfo into the remote /proj
+	&scp_file("./hostnames", "$user\@$host", $to_hostname) || return 0;
+	&ship_scripts($host, $user, $proj_dir) || return 0;
 	&ssh_cmd($user, $host, "/usr/testbed/bin/modexp -r -s -w $pid " . 
 	    "$eid $tclfile", "modexp") || return 0;
@@ -96,4 +116,8 @@
 	&ssh_cmd($user, $host, "/usr/testbed/bin/modexp -w $pid $eid $tclfile", 
 	    "modexp") || return 0;
+	# First copy new scripts and hostinfo into the remote /proj
+	&scp_file("./hostnames", "$user\@$host", $to_hostname) || return 0;
+	&ship_scripts($host, $user, $proj_dir) || return 0;
+	# Now start up
 	&ssh_cmd($user, $host, "/usr/testbed/bin/swapexp -w $pid $eid in", 
 	    "swapexp") || return 0;
@@ -101,8 +125,15 @@
     }
 
-    # No remote experiment.  Create one.
+    # No remote experiment.  Create one.  We do this in 2 steps so we can put
+    # the configuration files and scripts into the new experiment directories.
     if ($state eq "none") {
-	&ssh_cmd($user, $host, "/usr/testbed/bin/startexp -i -w -p " . 
+	&ssh_cmd($user, $host, "/usr/testbed/bin/startexp -f -w -p " . 
 	    "$pid -e $eid $tclfile", "startexp") || return 0;
+	# First copy new scripts and hostinfo into the remote /proj
+	&scp_file("./hostnames", "$user\@$host", $to_hostname) || return 0;
+	&ship_scripts($host, $user, $proj_dir) || return 0;
+	# Now start up
+	&ssh_cmd($user, $host, "/usr/testbed/bin/swapexp -w $pid $eid in", 
+	    "swapexp") || return 0;
 	return 1;
     }
@@ -138,5 +169,5 @@
 
 # Argument processing.
-getopts('c:m:e:f:n', \%opts);
+getopts('d:c:m:e:f:n', \%opts);
 
 $eid = $opts{'e'};		    # Experiment ID
@@ -145,4 +176,10 @@
 $startem = $opts{'n'} ? 0 : 1;	    # If true, start the sub-experiments
 $config = $opts{'c'} || "./testbeds";
+$local_script_dir = $opts{'d'};	    # Local scripts
+
+for $s (@scripts) {
+    die "$local_script_dir/$s not in local script directory. Try -d\n"
+	unless -r "$local_script_dir/$s";
+}
 
 die "Must supply file, master and experiment" unless $master && $tcl && $eid;
@@ -265,5 +302,6 @@
 
 B<splitter.pl> B<-e> I<experiment> B<-m> I<master_testbed> [B<-n>] 
-    [B<-c> I<config_file>] [B<-f> I<experiment_tcl>] [I<experiment_tcl>]
+    [B<-d> F<script_dir>] [B<-c> F<config_file>] [B<-f> F<experiment_tcl>]
+    [F<experiment_tcl>]
 
 =head1 DESCRIPTION
@@ -289,4 +327,8 @@
 currently instantiated last.
 
+Scripts to start federation are copied into the local experiment's tmp file -
+e.g., F</proj/DETER/exp/simple-split/tmp>.  These are taken from the directory
+given by the B<-d> option.
+
 If any sub-experiment fails to instantiate, the other sub-exeriments are
 swapped out.
