source: fedkit/federate.sh @ 4abace9

axis_examplecompt_changesinfo-opsversion-1.30version-2.00version-3.01version-3.02
Last change on this file since 4abace9 was 4abace9, checked in by Ted Faber <faber@…>, 16 years ago

Changes to imporve reliability of routes coming up. Restructuring of
federate leaves the stsyem in a state where we can safely restart the router
(specifically, talking to the local boss again) and we restart it in the
final topology. This introduces a lag in routing actually being established.
It may be useful to add a lag to the startcmd to take this into account.

  • Property mode set to 100755
File size: 3.3 KB
Line 
1#!/bin/sh
2
3# Set up a federated environment on a client.  Unmount all local file systems,
4# erase all local accounts and then bring in accounts and file systems from the
5# master testbed.  Once all that's done, restore client communication to the
6# local bossnode and execute any startup command passed in as arguments to this
7# script.
8
9
10# The file containing the DNS name of the current boss
11BOSSNODE="/usr/local/etc/emulab/bossnode"
12
13# Ports that the master gateway will forward
14PORTS="139 7777"
15# network cat command (to listen for the gateway)
16NC="/usr/bin/nc"
17# Emulab rc scripts directory
18RCDIR="/usr/local/etc/emulab/rc"
19
20# Emulab rc script to reset accounts and federation srcipt to start the smb
21# automount process.
22RCACCT="rc.accounts"
23SMBMOUNT="smbmount.pl"
24
25# Find somewhere safe to stop
26cd /tmp
27
28if [ -f $BOSSNODE ]
29then
30        rm -f $BOSSNODE
31fi
32
33EMUDIR="/usr/local/etc/emulab/"
34
35# Find this experiment's stashed scripts.  (Perl for advanced parsing)
36SCRIPTDIR=`$EMUDIR/tmcc -b status | perl -ne '/ALLOCATED=([^\/]+)\/([^\s]+)/ && print "/proj/$1/exp/$2/tmp\n";'`
37
38# Die if Scripts are not where they should be.  NB, this is checked by the
39# bootstrapper, too, so a failure here is unlikely.
40if [ -z "$SCRIPTDIR" ] ; then
41    echo "Can't find federation scripts.  Tmcc status says:"
42    $EMUDIR/tmcc -b status
43    exit 1;
44fi
45
46# Copy the global hostnames file into /etc/hosts so this node can address
47# others in the experiment on other testbeds.  The extra steps preserves teh
48# localhost entry that's aliased to this host's name.
49grep 127\\.0\\.0\\.1 /etc/hosts > /tmp/hosts
50cat "$SCRIPTDIR/hosts" >> /tmp/hosts
51cp /tmp/hosts /etc/hosts && rm /tmp/hosts
52
53# Get our gateway, share, and mount user from the configuration file.
54# There's probably a way to get all three at once, but this works.
55GATEWAY=`perl -ne '/ControlGateway:\s+(.*)/i && print "$1\n";' $SCRIPTDIR/client.conf`
56SHARE=`perl -ne '/SMBShare:\s+(.*)/i && print "$1\n";' $SCRIPTDIR/client.conf`
57SMBUSER=`perl -ne '/ProjectUser:\s+(.*)/i && print "$1\n";' $SCRIPTDIR/client.conf`
58
59#
60# Spin on our gateway!
61#
62
63echo "Waiting for the tunnel to come online."
64
65for port in $PORTS
66do
67        until $NC -z $GATEWAY $port
68        do
69                sleep 5
70        done
71done
72
73#
74# Setup TMCC to use our gateway
75#
76
77echo "Configuring TMCC."
78echo $GATEWAY > $BOSSNODE
79
80
81#
82# Unmount stuff before messing with accounts
83#
84umount -A -f -t nfs,smbfs
85
86
87#
88# Setup new accounts
89#
90$RCDIR/rc.accounts reconfig
91
92#
93# Call the smbmount perl script, this invokes the automounter to mount teh
94# needed smb filesystems.
95#
96echo "Mounting via SMB."
97"/tmp/$SMBMOUNT" $SHARE $GATEWAY $SMBUSER 
98
99echo "Restoring old bossnode"
100# remove bossnode override
101/bin/rm -f $BOSSNODE
102# Also clear any cached data that might interfere with rourte construction.
103/bin/rm -f /var/emulab/boot/tmcc/ifconfig
104
105# I remain unclear why ospfd seems screwed up after the resetting of accounts
106# and mounts.  This seems to fix it, but it's not very satisfying.  At this
107# point the federated topology is complete, so any problems with routing in a
108# partial topology -e.g. failed or partial bridging - that might have confused
109# the router should be gone.
110/bin/pkill ospf
111/bin/pkill gated
112/usr/local/etc/emulab/rc/rc.route boot
113
114# Execute any command passed in as a startcmd.  This basically daisy chains the
115# startcmd.
116if [ ! -z "$1" ]; then 
117        su -l "$1" -c "$2"
118fi
Note: See TracBrowser for help on using the repository browser.