source: fedkit/federate.sh @ 0b466d1

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

SEER config support

  • Property mode set to 100755
File size: 6.4 KB
RevLine 
[61f19e0]1#!/bin/sh
2
[4abace9]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.
[d53dda5]8
[4abace9]9
10# The file containing the DNS name of the current boss
[61f19e0]11BOSSNODE="/usr/local/etc/emulab/bossnode"
12
[4abace9]13# Ports that the master gateway will forward
[63f7c7e]14PORTS="139 7777"
[4abace9]15# network cat command (to listen for the gateway)
[63f7c7e]16NC="/usr/bin/nc"
[4abace9]17# Emulab rc scripts directory
[63f7c7e]18RCDIR="/usr/local/etc/emulab/rc"
19
[4abace9]20# Emulab rc script to reset accounts and federation srcipt to start the smb
21# automount process.
[63f7c7e]22RCACCT="rc.accounts"
[f3691ff]23SMBMOUNT="smbmount.`uname`.pl"
24
25# Find the right version of pkill.  For killing.
26if [ -x "/usr/bin/pkill" ] ; then 
27        PKILL="/usr/bin/pkill"
28else
29        if [ -x "/bin/pkill" ] ; then 
30                PKILL="/bin/pkill"
31        else
32                PKILL="echo"
33        fi
34fi
35
36if [ -x "/usr/bin/perl" ]; then
37    PERL="/usr/bin/perl"
38else
39    if [ -x "/usr/local/bin/perl" ]; then
40        PERL="/usr/local/bin/perl"
41    else
42        # Wing it...
43        PERL="perl"
44    fi
45fi
[63f7c7e]46
[5166ad4]47# Find somewhere safe to stop
48cd /tmp
49
[61f19e0]50if [ -f $BOSSNODE ]
51then
52        rm -f $BOSSNODE
53fi
54
55EMUDIR="/usr/local/etc/emulab/"
56
[63f7c7e]57# Find this experiment's stashed scripts.  (Perl for advanced parsing)
[27b6aea]58PROJECT=`$EMUDIR/tmcc -b status | $PERL -ne '/ALLOCATED=([^\/]+)\/([^\s]+)/ && print "$1\n";'`
59EXP=`$EMUDIR/tmcc -b status | $PERL -ne '/ALLOCATED=([^\/]+)\/([^\s]+)/ && print "$2\n";'`
60SCRIPTDIR="/proj/$PROJECT/exp/$EXP/tmp"
[61f19e0]61
[4abace9]62# Die if Scripts are not where they should be.  NB, this is checked by the
63# bootstrapper, too, so a failure here is unlikely.
[63f7c7e]64if [ -z "$SCRIPTDIR" ] ; then
65    echo "Can't find federation scripts.  Tmcc status says:"
66    $EMUDIR/tmcc -b status
67    exit 1;
68fi
69
[3c7da22]70# Get our gateway, share, and mount user from the configuration file.
71# There's probably a way to get all three at once, but this works.
[f3691ff]72GATEWAY=`$PERL -ne '/ControlGateway:\s+(.*)/i && print "$1\n";' $SCRIPTDIR/client.conf`
73SHARE=`$PERL -ne '/SMBShare:\s+(.*)/i && print "$1\n";' $SCRIPTDIR/client.conf`
74SMBUSER=`$PERL -ne '/ProjectUser:\s+(.*)/i && print "$1\n";' $SCRIPTDIR/client.conf`
75SMBPROJECT=`$PERL -ne '/ProjectName:\s+(.*)/i && print "$1\n";' $SCRIPTDIR/client.conf`
76
[291423b]77# XXX: modified seer daemon to read a config file.  Not in the tarfile yet.  If
78# we see one, and there's a /usr/seer/backend/daemon.py, replace that one with
79# the local one.
80if [ -e /usr/seer/backend/daemon.py ] && [ -e $SCRIPTDIR/daemon.py ]; then
81        /bin/cp $SCRIPTDIR/daemon.py /usr/seer/backend/daemon.py
82fi
83
84if [ -e /usr/seer/backend/experiment-setup.py ] && [ -e $SCRIPTDIR/experiment-setup.py ]; then
85        /bin/cp $SCRIPTDIR/experiment-setup.py /usr/seer/backend/experiment-setup.py
86fi
87
88# Copy the seer.conf to the local /tmp if there is one
89
90if [ -e $SCRIPTDIR/seer.conf ]; then
91        /bin/cp $SCRIPTDIR/seer.conf /tmp
92fi
93
[27b6aea]94GWIP=`host -N 10 $GATEWAY | $PERL -ne 's/.* has address // && print;'`
95# Copy the global hostnames file into /etc/hosts so this node can address
96# others in the experiment on other testbeds.  The extra steps preserves teh
97# localhost entry that's aliased to this host's name.
98grep 127\\.0\\.0\\.1 /etc/hosts > /tmp/hosts
99cat "$SCRIPTDIR/hosts" >> /tmp/hosts
100# If there's no node in this experiment called control, fake one so
101# that SEER events get through (if SEER's in use)
102if ! grep -q control $SCRIPTDIR/hosts; then
103        echo "$GWIP     control.$EXP.$PROJECT" >> /tmp/hosts
104fi
105cp /tmp/hosts /etc/hosts && rm /tmp/hosts
106
[f3691ff]107# XXX:
108# The standard emulab rc.accounts script won't replace existing user accounts
109# with our new ones, so we have to patch it to do so.  This is obviously pretty
110# fragile and needs to change.  To make matters worse, our FBSD62-SMB images
111# contain the patched rc.accounts, so this patching step will fail there.
112cd "$EMUDIR/rc"
113patch -f < /tmp/rc.accounts.patch
114cd /tmp
[61f19e0]115
116#
117# Spin on our gateway!
118#
119
120echo "Waiting for the tunnel to come online."
121
122for port in $PORTS
123do
124        until $NC -z $GATEWAY $port
125        do
126                sleep 5
127        done
128done
129
130#
131# Setup TMCC to use our gateway
132#
133
134echo "Configuring TMCC."
135echo $GATEWAY > $BOSSNODE
136
[63f7c7e]137
[61f19e0]138#
[f3691ff]139# Unmount stuff before messing with accounts
[61f19e0]140#
141
[f778038]142case `uname` in
143        "FreeBSD")
144                umount -A -f -t nfs,smbfs,cifs
145                ;;
146        "Linux")
147                # Linux doesn't believe in -A so pull the filesystems out of
148                # /etc/mtab and umount them individually
149                for f in `$PERL -nae 'print "$F[1]\n" if $F[2] =~ /(nfs|cifs|smbfs)/;' /etc/mtab`; do
150                        umount -f $f
151                done
152                ;;
153esac
[61f19e0]154
155#
156# Setup new accounts
157#
[f3691ff]158
159# Clear the cache, just in case:
160rm -f /var/emulab/boot/tmcc/accounts
161
[61f19e0]162$RCDIR/rc.accounts reconfig
163
164#
[f3691ff]165# Call the smbmount perl script, this invokes the automounter to mount the
[4abace9]166# needed smb filesystems.
[61f19e0]167#
168echo "Mounting via SMB."
[f3691ff]169$PERL "/tmp/$SMBMOUNT" $SHARE $GATEWAY $SMBUSER $SMBPROJECT
[d53dda5]170
[4abace9]171echo "Restoring old bossnode"
172# remove bossnode override
173/bin/rm -f $BOSSNODE
174# Also clear any cached data that might interfere with rourte construction.
175/bin/rm -f /var/emulab/boot/tmcc/ifconfig
176
177# I remain unclear why ospfd seems screwed up after the resetting of accounts
178# and mounts.  This seems to fix it, but it's not very satisfying.  At this
179# point the federated topology is complete, so any problems with routing in a
180# partial topology -e.g. failed or partial bridging - that might have confused
181# the router should be gone.
[f3691ff]182$PKILL ospf
183$PKILL gated
184# XXX Danger, hack ahead.  Apparently our FC6-SMB image and emulab disagree
185# about where gated lives.  This will alias it.
186if [ ! -x /usr/sbin/gated ] ; then 
187        if [ -x /sbin/gated ] ; then
188                ln /sbin/gated /usr/sbin/gated
189        fi
190fi
[4abace9]191/usr/local/etc/emulab/rc/rc.route boot
192
[7c3008e]193# And restore the ifconfig information because SEER wants it. (SEER pulls this
194# from tmcc now
195# "$EMUDIR/tmcc" ifconfig > /var/emulab/boot/tmcc/ifconfig
196
197# SEER feels pain and confusion if times are wrong.  This lays a big lick on
198# ntp sets the time directly and then restarts it.  XXX FreeBSD incantation is
199# untested.
200
201case `uname` in
202        "FreeBSD")
203                /etc/rc.d/ntpd stop
204                /usr/sbin/ntpdate boss
205                /etc/rc.d/ntpd start
206                ;;
207        "Linux")
208                /etc/rc.d/init.d/ntpd stop
209                /usr/sbin/ntpdate boss
210                /etc/rc.d/init.d/ntpd start
211                ;;
212esac
213
[4abace9]214# Execute any command passed in as a startcmd.  This basically daisy chains the
[7c3008e]215# startcmd.  This needs to become a perl script to have uniform behavior here.
216echo "*$1* *$2*"
[d53dda5]217if [ ! -z "$1" ]; then 
[7c3008e]218        echo "calling *$1* *$2*"
219        case `uname` in
220                "FreeBSD")
221                        su -l "$1" -c "$2"
222                        ;;
223                "Linux")
224                        su "$1" --command="$2"
225                        ;;
226        esac
[d53dda5]227fi
Note: See TracBrowser for help on using the repository browser.