#!/bin/sh

# If a server is already running, kill it first
P=`ps -o pid= -C fbvncserver`
if [ "${P}" ];then
  kill ${P}
  sleep 1
fi

AUTH=""
if [ -f $HOME/.fbvncpasswd ]; then
    AUTH="-rfbauth $HOME/.fbvncpasswd"
fi;

# Restart the server
if [ "X$LD_LIBRARY_PATH" = "X" ]; then
    LD_LIBRARY_PATH=/opt/Qtopia/lib
else
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Qtopia/lib
fi
export LD_LIBRARY_PATH
fbvncsplash&
/usr/local/bin/fbvncserver -r0 -mirrorx -mirrory $AUTH 2> /dev/null > /dev/null &
