[ntop] convert to systemd
Tom Callaway
spot at fedoraproject.org
Thu Sep 8 19:19:34 UTC 2011
commit 9311802653ee87bbeee15df6b336cd4cc7512f45
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date: Thu Sep 8 15:19:23 2011 -0400
convert to systemd
ntop.service | 16 ++++++++++++++++
ntop.spec | 47 +++++++++++++++++++++--------------------------
2 files changed, 37 insertions(+), 26 deletions(-)
---
diff --git a/ntop.service b/ntop.service
new file mode 100644
index 0000000..31eaff0
--- /dev/null
+++ b/ntop.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=A network traffic probe similar to the UNIX top command
+Requires=network.target
+# created after configuration by manual start
+ConditionPathExists=/var/lib/ntop/ntop_pw.db
+ConditionPathExists=/etc/ntop.conf
+After=syslog.target network.target
+
+[Service]
+Environment=LANG=C
+ExecStart=/usr/sbin/ntop @/etc/ntop.conf
+Type=simple
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/ntop.spec b/ntop.spec
index f64cb73..8574103 100644
--- a/ntop.spec
+++ b/ntop.spec
@@ -1,13 +1,13 @@
Name: ntop
Version: 3.4
-Release: 0.7.pre3%{?dist}
+Release: 0.8.pre3%{?dist}
Summary: A network traffic probe similar to the UNIX top command
Group: Applications/Internet
# Confirmed from fedora legal 488717
License: GPLv2 and BSD with advertising
URL: http://www.ntop.org
Source0: http://downloads.sourceforge.net/ntop/ntop-%{version}-pre3.tar.gz
-Source1: ntop.init
+Source1: ntop.service
Source2: ntop.conf
Source3: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
Source4: http://www.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
@@ -18,16 +18,15 @@ Patch2: ntop-running-user.patch
Patch3: ntop-dbfile-default-dir.patch
Patch4: ntop-disable-etter_fingerprint_download.patch
Patch5: ntop-http_c.patch
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: autoconf, automake, pkgconfig, libtool, groff, libpcap-devel wget
BuildRequires: gdbm-devel, gd-devel, rrdtool-devel, openssl-devel
BuildRequires: net-snmp-devel, lm_sensors-devel, pcre-devel, mysql-devel
BuildRequires: tcp_wrappers-devel, perl(ExtUtils::Embed)
BuildRequires: GeoIP-devel, libevent-devel, lua-devel, python-devel
+BuildRequires: systemd-units
Requires: initscripts, graphviz
-Requires(post): /sbin/chkconfig
+Requires(post): systemd-sysv
Requires(post): openssl >= 0.9.7f-4, /bin/cat
-Requires(preun):/sbin/chkconfig
%description
@@ -86,12 +85,11 @@ sed -i -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' -e 's
make %{?_smp_mflags}
%install
-rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p'
# Now add init, conf
-install -d $RPM_BUILD_ROOT/%{_initrddir}
-install -p -m 0755 %SOURCE1 $RPM_BUILD_ROOT/%{_initrddir}/ntop
+install -d $RPM_BUILD_ROOT/%{_unitdir}
+install -p -m 0755 %SOURCE1 $RPM_BUILD_ROOT/%{_unitdir}/ntop.service
install -p -m 0644 %SOURCE2 $RPM_BUILD_ROOT/%{_sysconfdir}/ntop.conf
### CLEAN UP ###
@@ -110,9 +108,6 @@ touch $RPM_BUILD_ROOT/%{_localstatedir}/lib/ntop/{addressQueue,dnsCache,fin
#remove expired certificate
rm -rf $RPM_BUILD_ROOT/%{_sysconfdir}/ntop/ntop-cert.pem
-%clean
-rm -rf $RPM_BUILD_ROOT
-
%pre
if [ $1 = 1 ]; then
getent group %{name} >/dev/null || groupadd -r %{name}
@@ -123,10 +118,6 @@ fi
%post
/sbin/ldconfig
-if [ $1 = 1 ]; then
- /sbin/chkconfig --add %{name} &> /dev/null || :
-fi
-
# create new self-signed certificate
%define sslcert %{_sysconfdir}/ntop/ntop-cert.pem
if [ ! -f %{sslcert} ] ; then
@@ -147,17 +138,18 @@ root@${FQDN}
EOF
fi
-%preun
-if [ $1 = 0 ]; then
- /sbin/service %{name} stop &> /dev/null || :
- /sbin/chkconfig --del %{name} &> /dev/null || :
-fi
-
-%postun
+%postun -p /sbin/ldconfig
/sbin/ldconfig
-if [ "$1" -ge "1" ]; then
- /sbin/service %{name} condrestart &> /dev/null || :
-fi
+
+%triggerun -- ntop < 3.4-0.8.pre3
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply ntop
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save ntop >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del ntop >/dev/null 2>&1 || :
+/bin/systemctl try-restart ntop.service >/dev/null 2>&1 || :
%files
%defattr(-,root,root,-)
@@ -167,7 +159,7 @@ fi
%doc docs/1STRUN.txt NEWS README SUPPORT_NTOP.txt THANKS
%config(noreplace) %{_sysconfdir}/ntop.conf
%config(noreplace) %{_sysconfdir}/ntop
-%{_initrddir}/ntop
+%{_unitdir}/ntop.service
%{_sbindir}/*
%{_libdir}/*.so
%{_libdir}/ntop
@@ -189,6 +181,9 @@ fi
%{_localstatedir}/lib/ntop/rrd
%changelog
+* Thu Sep 8 2011 Tom Callaway <spot at fedoraproject.org> - 3.4-0.8.pre3
+- convert to systemd
+
* Fri Aug 12 2011 Adam Jackson <ajax at redhat.com> 3.4-0.7.pre3
- Rebuilt for new libnetsnmp soname
More information about the scm-commits
mailing list