#!/bin/bash
#
# webIPsearch	Listens for an IP multicasted by webIPbroadcast
#
# Author:	Lott Caskey <lottcaskey@gmail.com>
#
# chkconfig:	345 61 14
#
# description:	Gets the multicasted IP from webIPbroadcast and
#               creates a corresponding entry in /etc/hosts.
# processname:	webIPsearch
#

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

# Get search config / hostname to associate with
. /etc/sysconfig/webIPsearch

RETVAL=0

start() {
        echo -n $"Starting webIPsearch: "
        daemon "/usr/bin/webIPsearch $HOSTNAME &"
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/webIPsearch
}

stop() {
        echo -n $"Shutting down webIPsearch: "
	killproc webIPsearch
	echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/webIPsearch
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status webIPsearch
        RETVAL=$?
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo $"Usage:  {start|stop|status|restart}"
        exit 1
        ;;
esac

exit $RETVAL

