#!/bin/sh
#
# Startup script for LISa
#
# chkconfig: 345 86 14
# description: Starts and stops the LAN Information Server used \
#              to provide a LAN browser.
# processname: lisa
#
# based on rclisa Version 0.1
# 2001 by Marcus Thiesen (marcus@thiesenweb.de) for SuSE Linux 7.1
# This is free and comes with absolutely no WARRANTY
# adapted for Mandrake 8.0 by Patrick Alberts (mandrake@alberts.org)

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

# Get config.
. /etc/sysconfig/network

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

# check how we were called
case "$1" in
	start)
	PID=`pidof -s lisa`
	if [ -z "$PID" ]; then
	if [ -e /usr/bin/lisa ]; then
                action "Starting LISa: " /bin/true
                /usr/bin/lisa -c /root/.kde/share/config/lisarc > /dev/null &2> /dev/null
	else
	        action "Starting LISa: binaries not found " /bin/false
	fi
	else
	        action "Starting LISa: already running ($PID) " /bin/false
	fi
        touch /var/lock/subsys/lisa
	;;

	stop)
	PID=`pidof -s lisa`
	if [ "$PID" ]; then
	        action "Stopping LISa: " kill -3 $PID
        fi
        rm -f /var/lock/subsys/lisa
	;;

	status)
	PID=`pidof -s lisa`
	if [ "$PID" ]; then
	gprintf "LISa is running! ($PID)\n"
	kill -SIGUSR1 $PID;
	sleep 3
	else
	gprintf "LISa is not running!\n";
	fi
	;;

	restart)
	$0 stop && $0 start
	;;

	refresh)
	PID=`pidof -s lisa`
	if [ "$PID" ]; then
	gprintf "Sending LISa a SIGHUP ($PID)\n"
	kill -SIGHUP $PID;
	else
	gprintf "LISa is not running!\n";
	fi
	;;

	*)
	gprintf "usage: %s {start|stop|status|refresh|restart}\n" $0
	;;
esac

exit 0
