#!/bin/bash # lldpd init file # # chkconfig: 2345 60 20 # description: 802.1ab (LLDP) daemon # # processname: lldpd # pidfile: /var/run/lldpd.pid ### BEGIN INIT INFO # Provides: lldpd # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Should-Start: $syslog $network $net-snmp # Should-Stop: $syslog $network $net-snmp # Default-Start: 2 3 5 # Default-Stop: 0 1 6 # Short-Description: LLDP daemon # Description: 802.1ab (LLDP) daemon ### END INIT INFO # source function library . /etc/rc.d/init.d/functions LLDPD_OPTIONS="" [ -e /etc/sysconfig/lldpd ] && . /etc/sysconfig/lldpd RETVAL=0 prog="lldpd" binary=/usr/sbin/lldpd pidfile=/var/run/lldpd.pid lockfile=/var/lock/subsys/$prog # Determine if we can use the -p option to daemon, killproc, and status. # RHEL < 5 can't. if status | grep -q -- '-p' 2>/dev/null; then daemonopts="--pidfile $pidfile" pidopts="-p $pidfile" fi start() { [ -x $binary ] || exit 5 echo -n $"Starting $prog: " if [ $UID -ne 0 ]; then RETVAL=1 failure else daemon $daemonopts $binary $LLDPD_OPTIONS RETVAL=$? [ $RETVAL -eq 0 ] && touch $lockfile fi; echo return $RETVAL } stop() { echo -n $"Stopping $prog: " if [ $UID -ne 0 ]; then RETVAL=1 failure else killproc $pidopts $binary RETVAL=$? [ $RETVAL -eq 0 ] && rm -f $lockfile fi; echo return $RETVAL } restart(){ stop start } condrestart(){ [ -e $lockfile ] && restart return 0 } rh_status_q(){ status $pidopts $prog >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 start RETVAL=$? ;; stop) rh_status_q || exit 0 stop RETVAL=$? ;; restart) restart RETVAL=$? ;; reload) rh_status_q || exit 7 exit 3 ;; force-reload) restart RETVAL=$? ;; condrestart|try-restart) rh_status_q || exit 0 condrestart RETVAL=$? ;; status) status $pidopts $prog RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|force-reload}" RETVAL=2 esac exit $RETVAL