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