#!/bin/sh
# /etc/init.d/xdm: start or stop XDM.

test -x /usr/bin/X11/xdm || exit 0

test -f /etc/X11/config || exit 0

if grep -q ^xbase-not-configured /etc/X11/config
then
  exit 0
fi

run_xdm=0
if grep -q ^start-xdm /etc/X11/config
then
  run_xdm=1
fi

case "$1" in
  start)
    if [ $run_xdm = 1 ]
    then
      start-stop-daemon --start --verbose --exec /usr/bin/X11/xdm
    fi
    ;;
  stop)
    if [ $run_xdm = 1 ]
    then
      start-stop-daemon --stop --verbose --pidfile /var/run/xdm-pid \
	--exec /usr/bin/X11/xdm
    fi
    ;;
  *)
    echo "Usage: /etc/init.d/xdm {start|stop}"
    exit 1
esac

exit 0
