#!/bin/sh
# This is the lcdproc init-script for RPM based (RedHat, Mandrake) systems
#
# Copyright (C) 2001  Rene Wagner <reenoo@gmx.de>
#               2001  Guillaume Filion <gfk@logidac.com>
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this file; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
#
#
# chkconfig: - 71 20
# 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: lcdproc
# pidfile: /var/run/lcdproc.pid
# config: /etc/sysconfig/lcdproc/lcdproc.conf
#
### BEGIN INIT INFO
# Provides:          lcdproc
# Required-Start:    $syslog $local_fs $network $remote_fs
# Required-Stop:     $syslog $local_fs $network $remote_fs
# Should-Start:      LCDd
# Default-Start:
# Default-Stop:      S 0 1 6
# Short-Description: LCDproc system status information viewer
# Description:       LSB init script for lcdproc, the system
#                    status information viewer in the LCDproc suite
### END INIT INFO

prog=lcdproc
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

# Source networking configuration.
if [ -e /etc/sysconfig/network ]; then
  . /etc/sysconfig/network
fi

# Check that networking is up.
if [ ${NETWORKING} = "no" ]; then
        exit 0
fi

prefix=/usr
exec_prefix=/usr
bindir=/usr/bin
sbindir=/usr/sbin
etc=/etc/sysconfig/lcdproc

[ -x ${bindir}/${prog} ] || exit 0

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


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

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

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

dostatus() {
	status ${prog}
	return $?
}

restart() {
	stop
	start
	return $?
}

condrestart() {
	[ -f ${lockfile} ] && restart || :
	return $?
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	dostatus
	;;
  restart|force-reload)
	restart
	;;
  try-restart|condrestart)
	condrestart
	;;
  reload)
	reload
	;;
  *)
	echo "Usage: $0 {start|stop|status|restart|condrestart|reload}"
	exit 1
esac

exit $RETVAL
