#!/bin/sh

domid=`xm domid $1` 
port=`xenstore-read /local/domain/${domid}/console/vnc-port` 

if [ $port .gt. 5900 ] ; then 
	port=`expr $port - 5900`
fi

tmphost=`grep vnc-listen /etc/xen/xend-config.sxp`
host=`echo $tmphost | sed -e "s;.*'\(.*\)');\1;"`

echo "Starting VNC viewer for $1 ($domid) on host $host port $port..."

vncviewer $host:$port
