#!/bin/sh
#
# lisa		LAN Information Server
#
# chkconfig:	45 50 50
#
# description:	LISa is a small daemon which is intended to run on end user
#		systems. It provides something like a "network neighbourhood",
#		but only relying on the TCP/IP protocol stack, no smb or
#		whatever.
#
# $Id: kdenetwork-lisa.init,v 1.6 2007/03/28 18:19:18 glen Exp $

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

# Get network config
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/lisa ] && . /etc/sysconfig/lisa

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network ]; then
		msg_network_down lisa
		exit 1
	fi
else
	exit 0
fi

start() {
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/lisa ]; then
		msg_starting lisa
		busy
		lisa >/dev/null
		RETVAL=$?
		if [ $RETVAL -eq 0 ]; then
			log_success "$1 startup"
			ok
		else
			fail
			log_failed "$1 startup"
		fi
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/lisa
	else
		msg_already_running lisa
	fi
}

stop() {
	# Stop daemons.
	if [ -f /var/lock/subsys/lisa ]; then
		msg_stopping lisa
		killproc lisa
		rm -f /var/lock/subsys/lisa
	else
		msg_not_running lisa
	fi
}

RETVAL=0
# See how we were called.
case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart|force-reload)
	stop
	start
	;;
  reload)
	if [ -f /var/lock/subsys/lisa ]; then
		msg_reloading lisa
		killproc lisa -HUP
		RETVAL=$?
	else
		msg_not_running lisa
		exit 7
	fi
	;;
  status)
	status lisa
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
	exit 3
esac

exit $RETVAL
