diff --git a/net-snmp.spec b/net-snmp.spec index 2defe2e..ef0e2c3 100644 --- a/net-snmp.spec +++ b/net-snmp.spec @@ -11,7 +11,7 @@ Summary: A collection of SNMP protocol tools and libraries Name: net-snmp Version: 5.7 -Release: 4%{?dist} +Release: 5%{?dist} Epoch: 1 License: BSD @@ -27,6 +27,8 @@ Source6: net-snmp-trapd.redhat.conf Source7: net-snmpd.sysconfig Source8: net-snmptrapd.sysconfig Source9: net-snmp-tmpfs.conf +Source10: snmpd.service +Source11: snmptrapd.service Patch1: net-snmp-5.6-pie.patch Patch2: net-snmp-5.5-dir-fix.patch Patch3: net-snmp-5.6-multilib.patch @@ -35,6 +37,7 @@ Patch5: net-snmp-5.5-apsl-copying.patch Patch6: net-snmp-5.5-perl-linking.patch Patch7: net-snmp-5.6-test-debug.patch Patch8: net-snmp-5.6.1-mysql.patch +Patch9: net-snmp-5.7-systemd.patch Requires(post): chkconfig Requires(preun): chkconfig @@ -44,6 +47,11 @@ Requires(preun): initscripts Requires(preun): coreutils Requires: %{name}-libs = %{epoch}:%{version}-%{release} Requires: mysql-libs +# This is actually needed for the %triggerun script but Requires(triggerun) +# is not valid. We can use %post because this particular %triggerun script +# should fire just after this package is installed. +Requires(post): systemd-sysv + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: openssl-devel, bzip2-devel, elfutils-devel BuildRequires: libselinux-devel, elfutils-libelf-devel, rpm-devel @@ -55,6 +63,7 @@ BuildRequires: mysql-devel BuildRequires: net-tools # for make test BuildRequires: perl(TAP::Harness) +BuildRequires: systemd-units %ifnarch s390 s390x BuildRequires: lm_sensors-devel >= 3 %endif @@ -174,6 +183,7 @@ Net-SNMP toolkit library. #%patch6 -p1 -b .perl-linking %patch7 -p1 %patch8 -p1 -b .mysql +%patch9 -p1 -b .systemd %ifarch sparc64 # disable failing test - see https://bugzilla.redhat.com/show_bug.cgi?id=680697 @@ -218,6 +228,7 @@ MIBS="$MIBS ucd-snmp/lmsensorsMib" --with-transports="DTLSUDP TLSTCP" \ --with-security-modules=tsm \ --with-mysql \ + --with-systemd \ --with-sys-contact="root@localhost" </dev/null || : - +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi %preun if [ $1 = 0 ]; then - service snmpd stop >/dev/null 2>&1 - /sbin/chkconfig --del snmpd - service snmptrapd stop >/dev/null 2>&1 - /sbin/chkconfig --del snmptrapd + /bin/systemctl --no-reload disable snmpd.service > /dev/null 2>&1 || : + /bin/systemctl --no-reload disable snmptrapd.service > /dev/null 2>&1 || : + /bin/systemctl stop snmpd.service > /dev/null 2>&1 || : + /bin/systemctl stop snmptrapd.service > /dev/null 2>&1 || : fi %postun if [ "$1" -ge "1" ]; then - service snmpd condrestart >/dev/null 2>&1 || : - service snmptrapd condrestart >/dev/null 2>&1 || : + /bin/systemctl try-restart snmpd.service >/dev/null 2>&1 || : + /bin/systemctl try-restart snmptrapd.service >/dev/null 2>&1 || : fi + +%triggerun -- net-snmp < 1:5.7-5 +# Convert SysV -> systemd. +# Save the current service runlevel info, +# User must manually run systemd-sysv-convert --apply snmpd +# to migrate them to systemd targets +echo "hello world" >> /tmp/snmp +echo date >>/tmp/snmp +/usr/bin/systemd-sysv-convert --save snmpd >/dev/null 2>&1 ||: +/usr/bin/systemd-sysv-convert --save snmptrapd >/dev/null 2>&1 ||: +/sbin/chkconfig --del snmpd >/dev/null 2>&1 || : +/sbin/chkconfig --del snmptrapd >/dev/null 2>&1 || : +/bin/systemctl try-restart snmpd.service >/dev/null 2>&1 || : +/bin/systemctl try-restart snmptrapd.service >/dev/null 2>&1 || : + %post libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig @@ -386,6 +412,7 @@ rm -rf ${RPM_BUILD_ROOT} %dir %{_localstatedir}/lib/net-snmp %dir %{_localstatedir}/run/net-snmp %config(noreplace) %{_sysconfdir}/tmpfiles.d/net-snmp.conf +%{_unitdir}/snmp* %files utils %defattr(-,root,root,-) @@ -444,6 +471,9 @@ rm -rf ${RPM_BUILD_ROOT} %{_datadir}/snmp/mibs/* %changelog +* Tue Aug 9 2011 Jan Safranek - 1:5.7-5 +- integrated with systemd (#718183) + * Thu Jul 21 2011 Petr Sabata - 1:5.7-4 - Perl mass rebuild diff --git a/net-snmpd.sysconfig b/net-snmpd.sysconfig index 8b1791f..fa38f79 100644 --- a/net-snmpd.sysconfig +++ b/net-snmpd.sysconfig @@ -1,2 +1,6 @@ +# WARNING: +# This file is only for compatibility with SysV init scripts if someone uses +# them! systemd does not use this file when starting snmpd! +# # snmpd command line options # OPTIONS="-LS0-6d -Lf /dev/null -p /var/run/snmpd.pid" diff --git a/net-snmptrapd.sysconfig b/net-snmptrapd.sysconfig index 09a9012..562203f 100644 --- a/net-snmptrapd.sysconfig +++ b/net-snmptrapd.sysconfig @@ -1,2 +1,6 @@ +# WARNING: +# This file is only for compatibility with SysV init scripts if someone uses +# them! systemd does not use this file when starting snmpd! +# # snmptrapd command line options # OPTIONS="-Lsd -p /var/run/snmptrapd.pid" diff --git a/snmpd.service b/snmpd.service new file mode 100644 index 0000000..3af5ea7 --- /dev/null +++ b/snmpd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Simple Network Management Protocol (SNMP) Daemon. +After=syslog.target network.target + +[Service] +Type=notify +ExecStart=/usr/sbin/snmpd -LS0-6d -f +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/snmptrapd.service b/snmptrapd.service new file mode 100644 index 0000000..e4689a6 --- /dev/null +++ b/snmptrapd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Simple Network Management Protocol (SNMP) Trap Daemon. +After=syslog.target network.target + +[Service] +Type=notify +ExecStart=/usr/sbin/snmptrapd -Lsd -f +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target