#!/bin/sh 
#
# Originally based on: gdm /etc/init.d script on debian
#
# chkconfig: - 99 01
# description: Entrance Display Manager
# probe: true

# /etc/init.d/entrance
#
### BEGIN INIT INFO
# Provides:          entrance
# Required-Start:    $remote_fs
# X-UnitedLinux-Should-Start: ypbind hwscan $syslog gpm
# Required-Stop:
# Default-Start:     5
# Default-Stop:
# Description:       Entrance Display Manager
### END INIT INFO

set -e

# HEED_DEFAULT_DISPLAY_MANAGER to "false."
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/entranced
PIDFILE=/var/run/entrance/entranced.pid

test -x $DAEMON || exit 0

case "$1" in
  start)
	echo -n "Becoming entranced: entrance"
        (cd /etc/pam.d ; for i in gdm kdm wdm xdm ; do test -s $i && cp -a $i entrance && break ; done)
	set +e
	if pam_getenv -l PATH; then
		export PATH=`pam_getenv -l PATH`
	fi
	set -e
	$DAEMON
	echo "."
  ;;
  stop)
	echo -n "Stopping Entrance: entrance"
	if [ -f $PIDFILE ]; then kill -9 `cat $PIDFILE` ; fi
	echo "."
  ;;
  restart)
	$0 stop
	$0 start
  ;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
  ;;
esac

exit 0

