#! /bin/sh
# Copyright (c) 1995-2003 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# Author: Thomas Siedentopf
# Please send feedback to http://www.suse.de/feedback/
#
# /etc/init.d/lcd4linux
#   and its symbolic link
# /(usr/)sbin/rclcd4linux
#
### BEGIN INIT INFO
# Provides:          lcd4linux
# Required-Start:    $local_fs $syslog $remote_fs
# Should-Start:      inetd sensors cyrus
# Required-Stop:     $local_fs $syslog
# Should-Stop:       inetd sensors cyrus $remote_fs
# Default-Start:     2 3 5
# Default-Stop:      0 1 6
# Short-Description: lcd4linux daemon
# Description:       start lcd4linux which displays system informations on a LCD
### END INIT INFO

# Check for missing binaries (stale symlinks should not happen)
lcd4linux_BIN=/usr/bin/lcd4linux
test -x $lcd4linux_BIN || { echo "$lcd4linux_BIN not installed"; exit 5; }

# Check for existence of needed config file
lcd4linux_CONFIG=/etc/lcd4linux.conf
test -r $lcd4linux_CONFIG || { echo "$lcd4linux_CONFIG not existing"; exit 6; }

# Source LSB init functions
. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
    start)
	echo -n "Starting lcd4linux "
	startproc $lcd4linux_BIN
	rc_status -v
	;;
    stop)
	echo -n "Shutting down lcd4linux "
	killproc -TERM $lcd4linux_BIN
	rc_status -v
	;;
    try-restart|condrestart)
	if test "$1" = "condrestart"; then
		echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
	fi
	$0 status
	if test $? = 0; then
		$0 restart
	else
		rc_reset	# Not running is not a failure.
	fi
	rc_status
	;;
    restart)
	$0 stop
	$0 start
	rc_status
	;;
    force-reload)
	echo -n "Reload service lcd4linux "
	killproc -HUP $lcd4linux_BIN
	rc_status -v
	;;
    reload)
	echo -n "Reload service lcd4linux "
	killproc -HUP $lcd4linux_BIN
	rc_status -v
	;;
    status)
	echo -n "Checking for service lcd4linux "
	checkproc $lcd4linux_BIN
	rc_status -v
	;;
    probe)
	test /etc/lcd4linux.conf -nt /var/run/lcd4linux.pid && echo reload
	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
	exit 1
	;;
esac
rc_exit
