#!/bin/sh -e
#
# Test if the XFree86 server is working.

. /usr/share/debian-edu-config/testsuite-lib.sh

if test -r /etc/debian-edu/config ; then
    . /etc/debian-edu/config
fi

# Standalone Main-Server do not install XFree86 dictionaries
if [ "$PROFILE" = Main-Server ] ; then
    exit 0
fi

# Only test if xserver-common is installed
if  deb_installed xserver-common ; then
    :
else
    echo "info: $0: xserver-common is not installed"
    exit 0
fi

symlink=/etc/X11/X
if [ -e $symlink ] ; then
	linkto=`ls -l $symlink | rev | awk '{ print $1 }' | rev`
	echo "info: $0: Symlink $symlink points to $linkto"
else
	echo "error: $0: no symlink $symlink pointing to X server"
fi

#filename=/tmp/.X11-unix/X0
#if netstat -a 2>&1 | grep LISTENING | grep -q "$filename" ; then
#    echo "success: $0: XFree86 server is listening on $filename."
#else
#    # X is not started yet when this is executed during installation.
#    # Thus only information.
#    echo "info: $0: XFree86 server is not listening on $filename."
#    exit 1
#fi

exit 0
