#!/bin/sh
##############################################################################
#
#  Copyright (c) 2005, Doremi Labs, Inc.
#    All rights reserved.
#
#  Redistribution in source or binary forms, with or without
#  modification, are NOT permitted.
#
#    Doremi Labs, Inc.
#    1020 Chestnut St.
#    Burbank, CA 91506
#    Tel : (818) 562 1101
#    Fax : (818) 562 1109
#
##############################################################################


trap ":" INT QUIT TSTP

start_xfree86()
{
	if [ ! -e /doremi/X11R6/etc/login.conf ]; then
		exec /etc/init.d/wdm start
	fi 
	user=`cat /doremi/X11R6/etc/login.conf`
	if [ -z $user ] ; then
		exec /etc/init.d/wdm start
	fi
	if grep -q "^$user" /etc/passwd ; then
		su - "$user" -c "/usr/X11R6/bin/startx -- -nolisten TCP -dpi 75"
	fi
	exec /etc/init.d/wdm start
}

case "$1" in
  start)
    start_xfree86 & 
    ;;

  *)
    echo "Usage: $0 {start}"
    exit 1
    ;;
esac
