#!/sbin/sh
#
# xdm		This script starts the xdm daemon
#
# Version:	@(#) /sbin/init.d/xdm 1.01 26-Oct-1993
#
# Author:	Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
#

  # Source function library.
  . /sbin/init.d/functions

  # Expand PATH
  export PATH=/usr/bin:/bin:/usr/X11/bin:/usr/openwin/bin:/usr/sbin:/sbin

  # See how we were called.
  case "$1" in
    start)
	# Set default permissions
	chown root.tty /dev/?ty*
	chmod 666      /dev/?ty*

	# Using console line
	exec 0<> /dev/tty0 1>&0 2>&0

	# Starting xdm
	echo -n "Starting up X Window System V.11 R.5: "

	daemon /usr/X11/bin/xdm
	# Xdm should be the first, therefore wait
	sleep 1
	echo
	;;
    stop)
	killproc -TERM xdm & sleep 1
	# Swaped out `-:0'??
	killproc -TERM xdm
	echo

	# Set permissions back
	chown root.tty /dev/?ty*
	chmod 666      /dev/?ty*
	;;
    *)
	# Oops someone made a typo.
	echo "Usage: /sbin/init.d/xdm {start|stop}"
	exit 1
  esac

exit 0
