#!/bin/sh
# openlldp	LLDPD - LLDP, CDP and EDP implimentation
#
# chkconfig:	345 55 55
# description:	The LLDPD project aims to provide a comprehensive implementation 
#    		of the IEEE standard 802.1AB Link Layer Discovery Protocol.
# processname:	lldpd

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

# Get network config
. /etc/sysconfig/network

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

start() {
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/lldpd ]; then
		msg_starting "LLDP Daemon"
		daemon /usr/sbin/lldpd $LLDP_OPT
		RETVAL=$?
		if [ $RETVAL -eq 0 ]; then
		   	touch /var/lock/subsys/lldpd
			ok
		else
			fail
		fi
	else
		msg_already_running "LLDP Daemon"
	fi
}

stop() {
	# Stop daemons.
	if [ -f /var/lock/subsys/lldpd ]; then
		killproc --pidfile /var/run/lldpd.pid lldpd
		rm -f /var/lock/subsys/lldpd
	else
		msg_not_running "LLDP Daemon"
	fi
}

RETVAL=0
# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	stop
	start
	;;
  status)
	status lldpd
	RETVAL=$?
	;;
  *)
	msg_usage "$0 {start|stop|restart|status}"
	exit 3
	;;
esac

exit $RETVAL
