]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Add init script for RPM
authorVincent Bernat <bernat@luffy.cx>
Tue, 19 May 2009 11:03:55 +0000 (13:03 +0200)
committerVincent Bernat <bernat@luffy.cx>
Tue, 19 May 2009 11:14:22 +0000 (13:14 +0200)
redhat/lldpd.init [new file with mode: 0644]
redhat/lldpd.spec [moved from lldpd.spec with 79% similarity]
redhat/lldpd.sysconfig [new file with mode: 0644]

diff --git a/redhat/lldpd.init b/redhat/lldpd.init
new file mode 100644 (file)
index 0000000..a8d494f
--- /dev/null
@@ -0,0 +1,113 @@
+#!/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 $network
+# Required-Stop: $local_fs $network
+# Should-Start: 
+# Should-Stop: 
+# Default-Start: 
+# Default-Stop: 
+# Short-Description: start and stop LLDP daemon
+# Description: 802.1ab (LLDP) daemon
+### END INIT INFO
+
+# source function library
+. /etc/init.d/functions
+
+
+OPTIONS=""
+if [ -e /etc/sysconfig/lldpd ]; then
+  . /etc/sysconfig/lldpd
+fi
+
+RETVAL=0
+prog="lldpd"
+binary=/usr/sbin/lldpd
+pidfile=/var/run/lldpd.pid
+
+start() {
+        [ -x $binary ] || exit 5
+        echo -n $"Starting $prog: "
+        if [ $UID -ne 0 ]; then
+                RETVAL=1
+                failure
+        else
+                daemon --pidfile=$pidfile $binary $OPTIONS
+                RETVAL=$?
+                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lldpd
+        fi;
+        echo 
+        return $RETVAL
+}
+
+stop() {
+        echo -n $"Stopping $prog: "
+        if [ $UID -ne 0 ]; then
+                RETVAL=1
+                failure
+        else
+                killproc -p $pidfile $binary
+                RETVAL=$?
+                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/lldpd
+        fi;
+        echo
+        return $RETVAL
+}
+
+reload(){
+        echo -n $"Reloading $prog: "
+        killproc -p $pidfile $binary -HUP
+        RETVAL=$?
+        echo
+        return $RETVAL
+}
+
+restart(){
+       stop
+       start
+}
+
+condrestart(){
+    [ -e /var/lock/subsys/lldpd ] && restart
+    return 0
+}
+
+case "$1" in
+  start)
+       start
+       RETVAL=$?
+       ;;
+  stop)
+       stop
+       RETVAL=$?
+       ;;
+  restart)
+       restart
+       RETVAL=$?
+        ;;
+  reload)
+       reload
+       RETVAL=$?
+        ;;
+  condrestart|try-restart)
+       condrestart
+       RETVAL=$?
+       ;;
+  status)
+        status lldpd
+       RETVAL=$?
+        ;;
+  *)
+       echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
+       RETVAL=2
+esac
+
+exit $RETVAL
similarity index 79%
rename from lldpd.spec
rename to redhat/lldpd.spec
index 461ec40aa785fd80ba8d6c72c67b809ce0f9c2ea..c8013f8233cdf5232aad5803972bdeb6e6d3ab39 100644 (file)
@@ -13,7 +13,7 @@
 
 Summary: implementation of IEEE 802.1ab (LLDP)
 Name: lldpd
-Version: 0.3.3
+Version: 0.4.0
 Release: 1%{?dist}
 License: MIT
 Group: System Environment/Daemons
@@ -94,6 +94,10 @@ make %{?_smp_mflags}
 rm -rf $RPM_BUILD_ROOT
 make install DESTDIR=$RPM_BUILD_ROOT
 install -d -m770  $RPM_BUILD_ROOT/%lldpd_chroot
+install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
+install -d $RPM_BUILD_ROOT/etc/sysconfig
+install -m644 redhat/lldpd.sysconfig $RPM_BUILD_ROOT/etc/sysconfig/lldpd
+install -m755 redhat/lldpd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/lldpd
 
 %pre
 # Create lldpd user/group
@@ -104,6 +108,19 @@ if getent passwd %lldpd_user >/dev/null 2>&1 ; then : ; else \
  -c "LLDP daemon" -d %lldpd_chroot %lldpd_user 2> /dev/null \
  || exit 1 ; fi
 
+%post
+/sbin/chkconfig --add lldpd
+
+%postun
+if [ "$1" -ge  "1" ]; then
+   /etc/rc.d/init.d/lldpd  condrestart >/dev/null 2>&1
+fi
+
+%preun
+if [ "$1" = "0" ]; then
+   /sbin/chkconfig --del lldpd
+fi
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -114,7 +131,17 @@ rm -rf $RPM_BUILD_ROOT
 %_sbindir/lldpd 
 %_sbindir/lldpctl
 %doc %_mandir/man8/lldp*
+%dir %attr(750,root,root) %lldpd_chroot
+%config(noreplace) /etc/sysconfig/lldpd
+%attr(755,root,root) /etc/rc.d/init.d/*
 
 %changelog
+* Tue May 19 2009 Vincent Bernat <bernat@luffy.cx> - 0.4.0-1
+- Add variables
+- Enable SNMP support
+- Add _lldpd user creation
+- Add initscript
+- New upstream version
+
 * Mon May 18 2009 Dean Hamstead <dean.hamstead@optusnet.com.au> - 0.3.3-1
 - Initial attempt
diff --git a/redhat/lldpd.sysconfig b/redhat/lldpd.sysconfig
new file mode 100644 (file)
index 0000000..795e5f4
--- /dev/null
@@ -0,0 +1,2 @@
+# Uncomment to start SNMP subagent and enable CDP, SONMP and EDP protocol
+#OPTIONS="-x -c -s -e"