add epel6 conditionals
This commit is contained in:
parent
7fc6e678ea
commit
a026e25dbb
121
lldpd-el6.init
Normal file
121
lldpd-el6.init
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
#!/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
|
68
lldpd.spec
68
lldpd.spec
@ -1,7 +1,10 @@
|
|||||||
# there are tests but they don't run in mock
|
%if 0%{?el6}
|
||||||
# as they require the ability to create and act
|
%bcond_with systemd
|
||||||
# inside a network namespace
|
%global rundir /var/run/
|
||||||
%bcond_with tests
|
%else
|
||||||
|
%bcond_without systemd
|
||||||
|
%global rundir /run/
|
||||||
|
%endif
|
||||||
|
|
||||||
%global gh_owner vincentbernat
|
%global gh_owner vincentbernat
|
||||||
|
|
||||||
@ -16,16 +19,29 @@ Source0: https://media.luffy.cx/files/lldpd/lldpd-%{version}.tar.gz
|
|||||||
Source1: %{name}-fedora.service
|
Source1: %{name}-fedora.service
|
||||||
Source2: %{name}-tmpfiles
|
Source2: %{name}-tmpfiles
|
||||||
Source3: %{name}-fedora.sysconfig
|
Source3: %{name}-fedora.sysconfig
|
||||||
|
Source4: %{name}-el6.init
|
||||||
|
|
||||||
BuildRequires: libevent-devel
|
|
||||||
BuildRequires: readline-devel
|
BuildRequires: readline-devel
|
||||||
BuildRequires: check-devel
|
BuildRequires: check-devel
|
||||||
BuildRequires: net-snmp-devel
|
BuildRequires: net-snmp-devel
|
||||||
BuildRequires: libxml2-devel
|
BuildRequires: libxml2-devel
|
||||||
|
# EL6 needs libevent2 as the package
|
||||||
|
%if 0%{?el6}
|
||||||
|
BuildRequires: libevent2-devel
|
||||||
|
%else
|
||||||
|
BuildRequires: libevent-devel
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%if 0%{?with_systemd}
|
||||||
# For systemd stuff
|
# For systemd stuff
|
||||||
BuildRequires: systemd
|
BuildRequires: systemd
|
||||||
%{?systemd_requires}
|
%{?systemd_requires}
|
||||||
|
%else
|
||||||
|
Requires(post): chkconfig
|
||||||
|
Requires(preun): chkconfig
|
||||||
|
# This is for /sbin/service
|
||||||
|
Requires(preun): initscripts
|
||||||
|
%endif
|
||||||
|
|
||||||
Requires(pre): shadow-utils
|
Requires(pre): shadow-utils
|
||||||
|
|
||||||
@ -48,10 +64,12 @@ Summary: %{summary}
|
|||||||
|
|
||||||
%build
|
%build
|
||||||
%configure --disable-static --with-snmp --disable-silent-rules \
|
%configure --disable-static --with-snmp --disable-silent-rules \
|
||||||
--with-systemdsystemunitdir=%{_unitdir} --with-sysusersdir=no \
|
|
||||||
--with-privsep-user=%{name} --with-privsep-group=%{name} \
|
--with-privsep-user=%{name} --with-privsep-group=%{name} \
|
||||||
--with-privsep-chroot=/run/%{name}/chroot \
|
--with-privsep-chroot=%{rundir}%{name}/chroot \
|
||||||
--with-lldpd-ctl-socket=/run/%{name}/%{name}.socket
|
--with-lldpd-ctl-socket=%{rundir}%{name}/%{name}.socket \
|
||||||
|
%if 0%{?with_systemd}
|
||||||
|
--with-systemdsystemunitdir=%{_unitdir} --with-sysusersdir=no
|
||||||
|
%endif
|
||||||
|
|
||||||
make %{?_smp_mflags}
|
make %{?_smp_mflags}
|
||||||
|
|
||||||
@ -59,10 +77,15 @@ make %{?_smp_mflags}
|
|||||||
%install
|
%install
|
||||||
%make_install
|
%make_install
|
||||||
|
|
||||||
|
%if 0%{?with_systemd}
|
||||||
install -p -D -m644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
|
install -p -D -m644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
|
||||||
install -p -D -m644 %{SOURCE2} %{buildroot}%{_tmpfilesdir}/%{name}.conf
|
install -p -D -m644 %{SOURCE2} %{buildroot}%{_tmpfilesdir}/%{name}.conf
|
||||||
|
%else
|
||||||
|
install -p -D -m755 %{SOURCE4} %{buildroot}%{_initddir}/%{name}
|
||||||
|
%endif
|
||||||
install -p -D -m644 %{SOURCE3} %{buildroot}/etc/sysconfig/%{name}
|
install -p -D -m644 %{SOURCE3} %{buildroot}/etc/sysconfig/%{name}
|
||||||
install -d -D -m 0755 %{buildroot}/run/%{name}/chroot
|
|
||||||
|
install -d -D -m 0755 %{buildroot}%{rundir}%{name}/chroot
|
||||||
install -d -m 0755 %{buildroot}%{_sharedstatedir}/%{name}
|
install -d -m 0755 %{buildroot}%{_sharedstatedir}/%{name}
|
||||||
# remove the docs from buildroot
|
# remove the docs from buildroot
|
||||||
rm -rf %{buildroot}/usr/share/doc/%{name}
|
rm -rf %{buildroot}/usr/share/doc/%{name}
|
||||||
@ -84,14 +107,32 @@ exit 0
|
|||||||
|
|
||||||
%post
|
%post
|
||||||
/sbin/ldconfig
|
/sbin/ldconfig
|
||||||
|
%if 0%{?with_systemd}
|
||||||
%systemd_post %{name}.service
|
%systemd_post %{name}.service
|
||||||
|
%else
|
||||||
|
# This adds the proper /etc/rc*.d links for the script
|
||||||
|
/sbin/chkconfig --add %{name}
|
||||||
|
%endif
|
||||||
|
|
||||||
%preun
|
%preun
|
||||||
|
%if 0%{?with_systemd}
|
||||||
%systemd_preun %{name}.service
|
%systemd_preun %{name}.service
|
||||||
|
%else
|
||||||
|
if [ $1 -eq 0 ] ; then
|
||||||
|
/sbin/service %{name} stop >/dev/null 2>&1
|
||||||
|
/sbin/chkconfig --del %{name}
|
||||||
|
fi
|
||||||
|
%endif
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
/sbin/ldconfig
|
/sbin/ldconfig
|
||||||
|
%if 0%{?with_systemd}
|
||||||
%systemd_postun_with_restart %{name}.service
|
%systemd_postun_with_restart %{name}.service
|
||||||
|
%else
|
||||||
|
if [ "$1" -ge "1" ] ; then
|
||||||
|
/sbin/service %{name} condrestart >/dev/null 2>&1 || :
|
||||||
|
fi
|
||||||
|
%endif
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%doc NEWS README.md
|
%doc NEWS README.md
|
||||||
@ -106,10 +147,14 @@ exit 0
|
|||||||
%{_mandir}/man8/%{name}.8*
|
%{_mandir}/man8/%{name}.8*
|
||||||
%{_libdir}/liblldpctl.so.4
|
%{_libdir}/liblldpctl.so.4
|
||||||
%{_libdir}/liblldpctl.so.4.8.0
|
%{_libdir}/liblldpctl.so.4.8.0
|
||||||
%dir /run/%{name}
|
%dir %{rundir}%{name}
|
||||||
%dir /run/%{name}/chroot
|
%dir %{rundir}%{name}/chroot
|
||||||
|
%if 0%{?with_systemd}
|
||||||
%{_unitdir}/%{name}.service
|
%{_unitdir}/%{name}.service
|
||||||
%{_tmpfilesdir}/%{name}.conf
|
%{_tmpfilesdir}/%{name}.conf
|
||||||
|
%else
|
||||||
|
%{_initddir}/%{name}
|
||||||
|
%endif
|
||||||
%dir %attr(-,lldpd,lldpd) %{_sharedstatedir}/%{name}
|
%dir %attr(-,lldpd,lldpd) %{_sharedstatedir}/%{name}
|
||||||
|
|
||||||
%files devel
|
%files devel
|
||||||
@ -122,6 +167,7 @@ exit 0
|
|||||||
%changelog
|
%changelog
|
||||||
* Wed Apr 05 2017 James Hogarth <james.hogarth@gmail.com> - 0.9.7-3
|
* Wed Apr 05 2017 James Hogarth <james.hogarth@gmail.com> - 0.9.7-3
|
||||||
- Use the official release tarball rather than the github snapshot
|
- Use the official release tarball rather than the github snapshot
|
||||||
|
- Add EPEL6 conditionals
|
||||||
|
|
||||||
* Wed Apr 05 2017 James Hogarth <james.hogarth@gmail.com> - 0.9.7-2
|
* Wed Apr 05 2017 James Hogarth <james.hogarth@gmail.com> - 0.9.7-2
|
||||||
- Tweaks to spec requested in review
|
- Tweaks to spec requested in review
|
||||||
|
Loading…
Reference in New Issue
Block a user