[mailgraph] Migrated to systemd.
Jon Ciesla
limb at fedoraproject.org
Wed Mar 14 16:35:05 UTC 2012
commit a2b2eaf51e08673d02819c19f434771930e5f95f
Author: Jon Ciesla <limburgher at gmail.com>
Date: Wed Mar 14 11:34:54 2012 -0500
Migrated to systemd.
mailgraph.service | 12 +++++++++
mailgraph.spec | 67 ++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 61 insertions(+), 18 deletions(-)
---
diff --git a/mailgraph.service b/mailgraph.service
new file mode 100644
index 0000000..484050a
--- /dev/null
+++ b/mailgraph.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=mailgraph mail log file analyzer
+After=syslog.target
+
+[Service]
+EnvironmentFile=/etc/sysconfig/mailgraph
+Nice=19
+Type=forking
+ExecStart=/usr/sbin/mailgraph -d -l $MAILLOG --daemon-rrd=/var/lib/mailgraph $OPTIONS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/mailgraph.spec b/mailgraph.spec
index 818d1fe..56bb0e4 100644
--- a/mailgraph.spec
+++ b/mailgraph.spec
@@ -7,7 +7,7 @@
Name: mailgraph
Version: 1.14
-Release: 11%{?dist}%{?repotag:.%{repotag}}
+Release: 12%{?dist}%{?repotag:.%{repotag}}
Summary: A RRDtool frontend for Mail statistics
Group: System Environment/Daemons
@@ -15,7 +15,7 @@ License: GPL+
URL: http://mailgraph.schweikert.ch/
Source0: http://mailgraph.schweikert.ch/pub/%{name}-%{version}.tar.gz
-Source1: mailgraph.init
+Source1: mailgraph.service
Source2: mailgraph.conf
Source3: mailgraph.sysconfig
Source4: mailgraph.te
@@ -30,7 +30,10 @@ BuildRequires: checkpolicy, selinux-policy-devel, hardlink
Requires: perl(File::Tail), rrdtool, httpd
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
-Requires: initscripts
+#Requires: initscripts
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
BuildArch: noarch
@@ -50,8 +53,8 @@ Requires: selinux-policy >= %{selinux_policyver}
%endif
Requires: %{name} = %{version}-%{release}
-Requires(post): /usr/sbin/semodule, /sbin/restorecon, /sbin/fixfiles, %{name}
-Requires(postun): /usr/sbin/semodule, /sbin/restorecon, /sbin/fixfiles, %{name}
+#Requires(post): /usr/sbin/semodule, /sbin/restorecon, /sbin/fixfiles, %{name}
+#Requires(postun): /usr/sbin/semodule, /sbin/restorecon, /sbin/fixfiles, %{name}
%description selinux
This is the selinux policy for mailgraph.
@@ -79,7 +82,7 @@ cd -
%install
rm -rf $RPM_BUILD_ROOT
%{__install} -d -m 0755 $RPM_BUILD_ROOT/%{_sbindir}
-%{__install} -d -m 0755 $RPM_BUILD_ROOT/%{_initrddir}
+%{__install} -d -m 0755 $RPM_BUILD_ROOT/%{_unitdir}
%{__install} -d -m 0755 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig
%{__install} -d -m 0755 $RPM_BUILD_ROOT/%{_sysconfdir}/httpd/conf.d
%{__install} -d -m 0755 $RPM_BUILD_ROOT/%{_datadir}/mailgraph
@@ -89,7 +92,7 @@ rm -rf $RPM_BUILD_ROOT
%{__install} -p -m 0755 mailgraph.cgi $RPM_BUILD_ROOT/%{_datadir}/mailgraph
%{__install} -p -m 0644 mailgraph.css $RPM_BUILD_ROOT/%{_datadir}/mailgraph
%{__install} -p -m 0755 mailgraph.pl $RPM_BUILD_ROOT/%{_sbindir}/mailgraph
-%{__install} -p -m 0755 %SOURCE1 $RPM_BUILD_ROOT/%{_initrddir}/mailgraph
+%{__install} -p -m 0755 %SOURCE1 $RPM_BUILD_ROOT/%{_unitdir}/mailgraph.service
%{__install} -p -m 0644 %SOURCE2 $RPM_BUILD_ROOT/%{_sysconfdir}/httpd/conf.d/
%{__install} -p -m 0644 %SOURCE3 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/mailgraph
@@ -110,22 +113,36 @@ cd -
rm -rf $RPM_BUILD_ROOT
%post
-/sbin/chkconfig --add %{name} 2>&1 > /dev/null || :
-
-if [ "$1" -ge "1" ]; then
- /sbin/service %{name} condrestart 2>&1 > /dev/null || :
+#/sbin/chkconfig --add %{name} 2>&1 > /dev/null || :
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
+#if [ "$1" -ge "1" ]; then
+# /sbin/service %{name} condrestart 2>&1 > /dev/null || :
+#fi
+
%preun
-if [ $1 = 0 ]; then
- /sbin/service %{name} stop 2>&1 > /dev/null || :
- /sbin/chkconfig --del %{name} 2>&1 > /dev/null || :
+#if [ $1 = 0 ]; then
+# /sbin/service %{name} stop 2>&1 > /dev/null || :
+# /sbin/chkconfig --del %{name} 2>&1 > /dev/null || :
+#fi
+#exit 0
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable mailgraph.service > /dev/null 2>&1 || :
+ /bin/systemctl stop mailgraph.service > /dev/null 2>&1 || :
fi
-exit 0
%postun
-if [ "$1" -ge "1" ]; then
- /sbin/service %{name} condrestart 2>&1 > /dev/null || :
+#if [ "$1" -ge "1" ]; then
+# /sbin/service %{name} condrestart 2>&1 > /dev/null || :
+#fi
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart mailgraph.service >/dev/null 2>&1 || :
fi
%if ! 0%{?without_selinux}
@@ -181,13 +198,24 @@ if [ $1 -eq 0 ]; then
fi
%endif
+%triggerun -- mailgraph < 1.14-12
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply mailgraph
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save mailgraph >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del mailgraph >/dev/null 2>&1 || :
+/bin/systemctl try-restart mailgraph.service >/dev/null 2>&1 || :
+
+
%files
%defattr(-,root,root,-)
%dir %{_localstatedir}/lib/mailgraph
%dir %attr(0775,root,apache) %{_localstatedir}/cache/mailgraph
%{_sbindir}/*
%{_datadir}/mailgraph
-%{_initrddir}/mailgraph
+%{_unitdir}/mailgraph.service
%config(noreplace) %{_sysconfdir}/sysconfig/mailgraph
%config(noreplace) %{_sysconfdir}/httpd/conf.d/mailgraph.conf
%doc CHANGES COPYING README
@@ -200,6 +228,9 @@ fi
%endif
%changelog
+* Wed Mar 14 2012 Jon Ciesla <limburgher at gmail.com> - 1.14-12
+- Migrate to systemd, BZ 661387.
+
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.14-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
More information about the scm-commits
mailing list