#!/bin/sh
#
# slim:		Starts the SLiM Display Manager
#
# chkconfig:	5 95 05
# description:	Starts and stops the SLiM Display Manager at startup and \
#		shutdown. can run one of several display managers; gdm, kdm, \
#		or slim, in that order of preferential treatment.
#
# config:	/etc/X11/slim/slim.conf
# probe:	true
# hide:		true

. /etc/rc.d/init.d/functions

# Get service config
if [ -f /etc/sysconfig/slim ]; then
	. /etc/sysconfig/slim
fi

start() {
	# Check if the service is already running?
	if [ -f /var/lock/subsys/slim ]; then
		msg_already_running "SLiM Display Manager"
		return
	fi

	msg_starting "SLiM Display Manager"
	daemon --fork slim
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/slim
}

stop() {
	if [ ! -f /var/lock/subsys/slim ]; then
		msg_not_running "SLiM Display Manager"
		return
	fi

	msg_stopping "SLiM Display Manager"
	killproc slim
	rm -f /var/lock/subsys/slim
}

condrestart() {
	if [ ! -f /var/lock/subsys/slim ]; then
		msg_not_running "SLiM Display Manager"
		RETVAL=$1
		return
	fi

	stop
	start
}

RETVAL=0
# See how we were called.
case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
  	stop
	start
	;;
  try-restart)
	condrestart 0
	;;
  force-reload)
	condrestart 7
	;;
  status)
	status slim
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
