#!/bin/sh
#
# xfs:       Starts/Stops the X Font Server
#
# chkconfig: 2345 90 10
# description: Starts and stops the X Font Server at boot time and shutdown.
#
# processname: xfs
# config: /etc/X11/fs/config
# hide: true

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

SourceIfNotEmpty /etc/sysconfig/xfs

LOCKFILE=/var/lock/subsys/xfs
RETVAL=0

start()
{
	echo -n "Starting X Font Server: "
	rm -rf /tmp/.font-unix
	daemon xfs $ARGS
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
	return $RETVAL
}

stop()
{
	echo -n "Stopping X Font Server: "
	killproc xfs
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
	return $RETVAL
}

restart()
{
	stop
	start
}

reload()
{
	echo -n "Reloading X Font Server configuration: "
	killproc xfs -USR1
	RETVAL=$?
	echo
	return $RETVAL
} 

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		reload
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			reload
		fi
		;;
	status)
		status xfs
		RETVAL=$?
		;;
	*)
		echo "Usage: ${0##*/} {start|stop|reload|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
