### 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
+# 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
. /etc/init.d/functions
-OPTIONS=""
+LLDPD_OPTIONS=""
if [ -e /etc/sysconfig/lldpd ]; then
. /etc/sysconfig/lldpd
fi
failure
else
build_chroot
- daemon --pidfile=$pidfile $binary $OPTIONS
+ daemon --pidfile=$pidfile $binary $LLDPD_OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/lldpd
fi;
%define lldpd_group _lldpd
%define lldpd_chroot /var/run/lldpd
-Summary: implementation of IEEE 802.1ab (LLDP)
+Summary: Implementation of IEEE 802.1ab (LLDP)
Name: lldpd
Version: 0.5.1
Release: 1%{?dist}
%if %{with snmp}
BuildRequires: net-snmp-devel
-Requires: net-snmp
BuildRequires: openssl-devel
-Requires: openssl
%endif
%if %{with xml}
BuildRequires: libxml2-devel
-Requires: libxml2
%endif
-Requires(pre): %{_sbindir}/useradd, %{_sbindir}/groupadd
+%if 0%{?suse_version}
+PreReq: %fillup_prereq %insserv_prereq pwdutils
+%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
[ -f /usr/include/net-snmp/agent/struct.h ] || touch src/struct.h
make %{?_smp_mflags}
+%define _initdir %{?suse_version:/etc/init.d}%{!?suse_version:/etc/rc.d/init.d}
%install
-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/%{_initdir}
+install -m755 %{SOURCE1} $RPM_BUILD_ROOT/%{_initdir}/lldpd
+%if 0%{?suse_version}
+mkdir -p ${RPM_BUILD_ROOT}/var/adm/fillup-templates
+install -m700 %{SOURCE2} ${RPM_BUILD_ROOT}/var/adm/fillup-templates/sysconfig.lldpd
+%else
install -d $RPM_BUILD_ROOT/etc/sysconfig
install -m644 %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/lldpd
-install -m755 %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/lldpd
+%endif
%pre
# Create lldpd user/group
-c "LLDP daemon" -d %lldpd_chroot %lldpd_user 2> /dev/null \
|| exit 1 ; fi
+
+%if 0%{?suse_version}
+# Service management for SuSE
+
%post
-/sbin/chkconfig --add lldpd
+%{fillup_and_insserv lldpd}
+%postun
+%restart_on_update lldpd
+%insserv_cleanup
+%preun
+%stop_on_removal lldpd
+%else
+# Service management for Redhat/Centos
+
+%post
+/sbin/chkconfig --add lldpd
%postun
if [ "$1" -ge "1" ]; then
- /etc/rc.d/init.d/lldpd condrestart >/dev/null 2>&1
+ %{_initdir}/lldpd condrestart >/dev/null 2>&1
fi
-
%preun
if [ "$1" = "0" ]; then
/sbin/chkconfig --del lldpd
fi
+%endif
+
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
+%dir %_docdir/lldpd
%doc %_docdir/lldpd/CHANGELOG
%doc %_docdir/lldpd/README
%_sbindir/lldpd
%_sbindir/lldpctl
%doc %_mandir/man8/lldp*
%dir %attr(750,root,root) %lldpd_chroot
+%config %{_initdir}/lldpd
+%attr(755,root,root) %{_initdir}/*
+%if 0%{?suse_version}
+%attr(644,root,root) /var/adm/fillup-templates/sysconfig.lldpd
+%else
%config(noreplace) /etc/sysconfig/lldpd
-%attr(755,root,root) /etc/rc.d/init.d/*
+%endif
%changelog
* Fri Jun 11 2010 Vincent Bernat <bernat@luffy.cx> - 0.5.1-1
with RHEL
- Disable SNMP by default on Fedora 13 and RHEL.
- Requires useradd and groupadd.
+- Adapt to make it work with SuSE
* Fri Mar 12 2010 Vincent Bernat <bernat@luffy.cx> - 0.5.0-1
- New upstream version