#!/bin/sh
#$Id: vmware-console,v 1.6 2002/07/22 00:23:23 tibbetts Exp $

TUNNEL_PORT=8902

# Start the tunnel.
# Open up the ssh tunnel and sleep for 100 years.
ssh -n -x -l $USER -L ${TUNNEL_PORT}:localhost:902 steve-dallas.mit.edu sleep 365000d &
SSH_PID=$!
echo "SSH tunnel PID is ${SSH_PID}"

# Kill the ssh on exit.
function killssh () {
    echo "Killing SSH tunnel (PID ${SSH_PID})"
    kill ${SSH_PID}
}

trap killssh EXIT

# Set environment variables for the vmware-mks fix.
#VMDIALUP_DIR=/afs/sipb.mit.edu/project/vmdialup
#VMDIALUP_ARCH=${VMDIALUP_DIR}/arch/${ATHENA_SYS}
#LD_PRELOAD=${VMDIALUP_ARCH}/lib/libvmware-etc-fix.so
#VMWARE_ETC_DIR=${VMDIALUP_DIR}/etc
#VMWARE_ETC_DIR=/afs/sipb.mit.edu/project/vmdialup/etc
#export LD_PRELOAD VMWARE_ETC_DIR
#VMWARE_ETC_DIR

# Place config in /tmp/vmware-console (replacing /etc/vmware-console)

mkdir /tmp/vmware-console/
chmod 755 /tmp/vmware-console
ln -s /mit/vmdialup/etc/vmware-console/config /tmp/vmware-console/config

# exec vmware-console.real with the right options.
athrun vmdialup vmware-console.real -h localhost -P ${TUNNEL_PORT} $@
