#! /bin/sh
#
# chkconfig: - 70 21
# description: LCDd(8) is the LCDproc server used for displaying text and other data to LCDs. \
#	Apart from the main client lcdproc(1) there are various clients. \
#	See http://lcdproc.omnipotent.net for details.
# processname: LCDd
#
# config: /etc/sysconfig/lcdproc/LCDd.conf

### BEGIN INIT INFO
# Provides:          LCDd
# Required-Start:    $syslog $local_fs $network $remote_fs
# Required-Stop:     $syslog $local_fs $network $remote_fs
# Default-Start:     
# Default-Stop:      S 0 1 6
# Short-Description: LCDproc Server Daemon
# Description:       LSB init script for LCDd, the display
#                    server daemon in the LCDproc suite
### END INIT INFO


prog=LCDd
lockfile=/var/lock/subsys/$prog
configfile=/etc/sysconfig/lcdproc/$prog.conf
RETVAL=0


# load LSB 3.x init functions
if [ -e /lib/lsb/init-functions ]; then
  . /lib/lsb/init-functions
fi

# Source function library.
if [ -e /etc/rc.d/init.d/functions ]; then
  . /etc/rc.d/init.d/functions
fi

# check that non-default config file exists.
 [ -f $configfile ] || exit 6


start() {
	echo -n $"Starting $prog services: "
	daemon $prog -c $configfile
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch $lockfile || \
	   RETVAL=1
	return $RETVAL
}	

stop() {
	echo -n $"Shutting down $prog services: "
	killproc $prog
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f $lockfile
	return $RETVAL
}	

reload() {
        echo -n $"Reloading $prog file: "
	killproc $prog -HUP
	RETVAL=$?
	echo
	return $RETVAL
}	

rhstatus() {
	status $prog
	return $?
}	


# Allow status as non-root.
if [ "$1" = status ]; then
       rhstatus
       exit $?
fi


case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status $prog
	;;
  restart|force-reload)
	stop
	start
	;;
  try-restart|condrestart)
	if [ -f $lockfile ]; then
	    stop
	    start
	fi
	;;
  reload)
	reload
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
	exit 2
esac

exit $RETVAL
