[61f19e0] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | BOSSNODE="/usr/local/etc/emulab/bossnode" |
---|
| 4 | # GATEWAY="detertunnel" |
---|
| 5 | |
---|
[63f7c7e] | 6 | PORTS="139 7777" |
---|
| 7 | NC="/usr/bin/nc" |
---|
| 8 | RCDIR="/usr/local/etc/emulab/rc" |
---|
| 9 | |
---|
| 10 | RCACCT="rc.accounts" |
---|
| 11 | SMBMOUNT="smbmount.pl" |
---|
| 12 | |
---|
[61f19e0] | 13 | if [ -f $BOSSNODE ] |
---|
| 14 | then |
---|
| 15 | rm -f $BOSSNODE |
---|
| 16 | fi |
---|
| 17 | |
---|
| 18 | EMUDIR="/usr/local/etc/emulab/" |
---|
| 19 | |
---|
[63f7c7e] | 20 | # Find this experiment's stashed scripts. (Perl for advanced parsing) |
---|
| 21 | SCRIPTDIR=`$EMUDIR/tmcc -b status | perl -ne '/ALLOCATED=([^\/]+)\/([^\s]+)/ && print "/proj/$1/exp/$2/tmp\n";'` |
---|
[61f19e0] | 22 | |
---|
[63f7c7e] | 23 | # Die if things are weird |
---|
| 24 | if [ -z "$SCRIPTDIR" ] ; then |
---|
| 25 | echo "Can't find federation scripts. Tmcc status says:" |
---|
| 26 | $EMUDIR/tmcc -b status |
---|
| 27 | exit 1; |
---|
| 28 | fi |
---|
| 29 | |
---|
| 30 | # Move the SMB mounting script out of NFS so we can call it after the umount |
---|
| 31 | cp "$SCRIPTDIR/$SMBMOUNT" /tmp |
---|
| 32 | |
---|
| 33 | # Copy the global hostnames file into /etc/hosts so this node can address |
---|
| 34 | # others in the experiment on other testbeds. |
---|
| 35 | grep 127\\.0\\.0\\.1 /etc/hosts > /tmp/hosts |
---|
| 36 | cat "$SCRIPTDIR/hosts" >> /tmp/hosts |
---|
| 37 | cp /tmp/hosts /etc/hosts && rm /tmp/hosts |
---|
| 38 | |
---|
[3c7da22] | 39 | # Get our gateway, share, and mount user from the configuration file. |
---|
| 40 | # There's probably a way to get all three at once, but this works. |
---|
| 41 | GATEWAY=`perl -ne '/ControlGateway:\s+(.*)/i && print "$1\n";' $SCRIPTDIR/client.conf` |
---|
| 42 | SHARE=`perl -ne '/SMBShare:\s+(.*)/i && print "$1\n";' $SCRIPTDIR/client.conf` |
---|
| 43 | SMBUSER=`perl -ne '/ProjectUser:\s+(.*)/i && print "$1\n";' $SCRIPTDIR/client.conf` |
---|
[61f19e0] | 44 | |
---|
| 45 | # |
---|
| 46 | # Spin on our gateway! |
---|
| 47 | # |
---|
| 48 | |
---|
| 49 | echo "Waiting for the tunnel to come online." |
---|
| 50 | |
---|
| 51 | for port in $PORTS |
---|
| 52 | do |
---|
| 53 | until $NC -z $GATEWAY $port |
---|
| 54 | do |
---|
| 55 | sleep 5 |
---|
| 56 | done |
---|
| 57 | done |
---|
| 58 | |
---|
| 59 | # |
---|
| 60 | # Setup TMCC to use our gateway |
---|
| 61 | # |
---|
| 62 | |
---|
| 63 | echo "Configuring TMCC." |
---|
| 64 | |
---|
| 65 | $EMUDIR/sethostname |
---|
| 66 | |
---|
| 67 | echo $GATEWAY > $BOSSNODE |
---|
| 68 | |
---|
[63f7c7e] | 69 | |
---|
[61f19e0] | 70 | # |
---|
| 71 | # Unmount stuff before messing with accounts |
---|
| 72 | # |
---|
| 73 | umount -A -f -t nfs,smbfs |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | # |
---|
| 77 | # Setup new accounts |
---|
| 78 | # |
---|
| 79 | $RCDIR/rc.accounts reconfig |
---|
| 80 | |
---|
| 81 | # |
---|
| 82 | # Copy and exec the smbmount perl script |
---|
| 83 | # |
---|
| 84 | |
---|
| 85 | echo "Mounting via SMB." |
---|
| 86 | |
---|
[3c7da22] | 87 | exec "/tmp/$SMBMOUNT" $SHARE $SMBUSER $GATEWAY |
---|