I done that some weeks ago, while traveling by train.
I did not have time to test it thoroughly, and I will probably have no time for that in future. So I'm posting it here. Decide yourself, if you want to merge it, or leave it for somebody else who will work on systemd integration.
--
Miroslav Suchý
Red Hat Satellite Engineering

>From 1e9dcfd8016d85888c02d44d50a611f0987f6090 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miroslav=20Such=C3=BD?= <msu...@redhat.com>
Date: Fri, 15 Jun 2012 11:46:44 +0200
Subject: [PATCH 1/3] implement rhnsd.service for systemd

---
 client/rhel/rhnsd/rhnsd.service |   11 +++++++++++
 client/rhel/rhnsd/rhnsd.spec    |   30 +++++++++++++++++++++++++++---
 2 files changed, 38 insertions(+), 3 deletions(-)
 create mode 100644 client/rhel/rhnsd/rhnsd.service

diff --git a/client/rhel/rhnsd/rhnsd.service b/client/rhel/rhnsd/rhnsd.service
new file mode 100644
index 0000000..14b3e3b
--- /dev/null
+++ b/client/rhel/rhnsd/rhnsd.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Red Hat Network Server daemon
+After=syslog.target network.target auditd.service
+
+[Service]
+PIDFile=/var/run/rhnsd.pid
+ExecStart=/usr/sbin/rhnsd
+ExecReload=/bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy=multi-user.target
diff --git a/client/rhel/rhnsd/rhnsd.spec b/client/rhel/rhnsd/rhnsd.spec
index 5c9d4c0..711b188 100644
--- a/client/rhel/rhnsd/rhnsd.spec
+++ b/client/rhel/rhnsd/rhnsd.spec
@@ -4,7 +4,7 @@ Group: System Environment/Base
 Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
 URL:     https://fedorahosted.org/spacewalk
 Name: rhnsd
-Version: 4.9.15
+Version: 5.0.0
 Release: 1%{?dist}
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -15,6 +15,13 @@ Requires: rhn-check >= 0.0.8
 Requires(post): aaa_base
 Requires(preun): aaa_base
 BuildRequires: sysconfig
+%elsif 0%{?fedora} || 0%{?rhel} > 5
+Requires(post): chkconfig
+Requires(preun): chkconfig
+Requires(post): systemd-sysv
+Requires(preun): systemd-sysv
+Requires(post): systemd-units
+Requires(preun): systemd-units
 %else
 Requires(post): chkconfig
 Requires(preun): chkconfig
@@ -41,6 +48,11 @@ make -f Makefile.rhnsd install VERSION=%{version}-%{release} PREFIX=$RPM_BUILD_R
 %if 0%{?suse_version}
 install -m 0755 rhnsd.init.SUSE $RPM_BUILD_ROOT/%{_initrddir}/rhnsd
 %endif
+%if 0%{?fedora} || 0%{?rhel} > 5
+rm $RPM_BUILD_ROOT/%{_initrddir}/rhnsd
+mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
+install -m 0644 rhnsd.service $RPM_BUILD_ROOT/%{_unitdir}/
+%endif
 
 %find_lang %{name}
 
@@ -50,14 +62,22 @@ install -m 0755 rhnsd.init.SUSE $RPM_BUILD_ROOT/%{_initrddir}/rhnsd
 
 %preun
 if [ $1 = 0 ] ; then
-    /etc/rc.d/init.d/rhnsd stop >/dev/null 2>&1
+    %if 0%{?fedora} || 0%{?rhel} > 5
+    /bin/systemctl stop rhnsd >/dev/null 2>&1
+    %else
+    service rhnsd stop >/dev/null 2>&1
+    %endif
     /sbin/chkconfig --del rhnsd
 fi
 
 
 %postun
 if [ "$1" -ge "1" ]; then
-    /etc/rc.d/init.d/rhnsd condrestart >/dev/null 2>&1 || :
+    %if 0%{?fedora} || 0%{?rhel} > 5
+    /bin/systemctl condrestart rhnsd >/dev/null 2>&1 || :
+    %else
+    service rhnsd condrestart >/dev/null 2>&1 || :
+    %endif
 fi
 
 %clean
@@ -68,7 +88,11 @@ rm -fr $RPM_BUILD_ROOT
 %dir %{_sysconfdir}/sysconfig/rhn
 %config(noreplace) %{_sysconfdir}/sysconfig/rhn/rhnsd
 %{_sbindir}/rhnsd
+%if 0%{?fedora} || 0%{?rhel} > 5
+%{_unitdir}/rhnsd.service
+%else
 %{_initrddir}/rhnsd
+%endif
 %{_mandir}/man8/rhnsd.8*
 %doc LICENSE
 
-- 
1.7.10.4

>From b7bef2628996765fc0e67412bfefe772dd5ae30f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miroslav=20Such=C3=BD?= <msu...@redhat.com>
Date: Sun, 17 Jun 2012 17:16:57 +0200
Subject: [PATCH 2/3] implement osad.service for systemd

---
 client/tools/osad/osad.service |   11 +++++++++++
 client/tools/osad/osad.spec    |   31 ++++++++++++++++++++++++-------
 2 files changed, 35 insertions(+), 7 deletions(-)
 create mode 100644 client/tools/osad/osad.service

diff --git a/client/tools/osad/osad.service b/client/tools/osad/osad.service
new file mode 100644
index 0000000..5597571
--- /dev/null
+++ b/client/tools/osad/osad.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=OSAD daemon
+After=syslog.target network.target
+
+[Service]
+EnvironmentFile=-/etc/sysconfig/osad
+PIDFile=/var/run/osad.pid
+ExecStart=/usr/sbin/osad --pid-file $PIDFile
+
+[Install]
+WantedBy=multi-user.target
diff --git a/client/tools/osad/osad.spec b/client/tools/osad/osad.spec
index cba0768..dd74885 100644
--- a/client/tools/osad/osad.spec
+++ b/client/tools/osad/osad.spec
@@ -16,7 +16,7 @@ Group:   System Environment/Daemons
 License: GPLv2
 URL:     https://fedorahosted.org/spacewalk
 Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
-Version: 5.10.44
+Version: 5.11.0
 Release: 1%{?dist}
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch: noarch
@@ -35,17 +35,24 @@ Requires: PyXML
 %endif
 Conflicts: osa-dispatcher < %{version}-%{release}
 Conflicts: osa-dispatcher > %{version}-%{release}
-%if !0%{?suse_version}
-Requires(post): chkconfig
-Requires(preun): chkconfig
-# This is for /sbin/service
-Requires(preun): initscripts
-%else
+%if 0%{?suse_version}
 # provides chkconfig on SUSE
 Requires(post): aaa_base
 Requires(preun): aaa_base
 # to make chkconfig test work during build
 BuildRequires: sysconfig syslog
+%elsif 0%{?fedora} || 0%{?rhel} > 5
+Requires(post): chkconfig
+Requires(preun): chkconfig
+Requires(post): systemd-sysv
+Requires(preun): systemd-sysv
+Requires(post): systemd-units
+Requires(preun): systemd-units
+%else
+Requires(post): chkconfig
+Requires(preun): chkconfig
+# This is for /sbin/service
+Requires(preun): initscripts
 %endif
 
 %description
@@ -135,6 +142,12 @@ mkdir -p %{buildroot}%{_var}/log/rhn
 touch %{buildroot}%{_var}/log/osad
 touch %{buildroot}%{_var}/log/rhn/osa-dispatcher.log
 
+%if 0%{?fedora} || 0%{?rhel} > 5
+rm $RPM_BUILD_ROOT/%{_initrddir}/osad
+mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
+install -m 0644 osad.service $RPM_BUILD_ROOT/%{_unitdir}/
+%endif
+
 %if 0%{?include_selinux_package}
 for selinuxvariant in %{selinux_variants}
   do
@@ -227,7 +240,11 @@ rpm -ql osa-dispatcher | xargs -n 1 /sbin/restorecon -rvi {}
 %config(noreplace) %{_sysconfdir}/sysconfig/rhn/osad.conf
 %config(noreplace) %attr(600,root,root) %{_sysconfdir}/sysconfig/rhn/osad-auth.conf
 %config(noreplace) %{client_caps_dir}/*
+%if 0%{?fedora} || 0%{?rhel} > 5
+%{_unitdir}/osad.service
+%else
 %attr(755,root,root) %{_initrddir}/osad
+%endif
 %doc LICENSE
 %config(noreplace) %{_sysconfdir}/logrotate.d/osad
 %ghost %attr(600,root,root) %{_var}/log/osad
-- 
1.7.10.4

>From c60c0dd70a0335588fa1a29eb73d085abb8a4282 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miroslav=20Such=C3=BD?= <msu...@redhat.com>
Date: Sun, 17 Jun 2012 17:58:39 +0200
Subject: [PATCH 3/3] implement osa-dispatcher.service for systemd

---
 client/tools/osad/osa-dispatcher.service |   11 +++++++++++
 client/tools/osad/osad.spec              |    6 ++++++
 2 files changed, 17 insertions(+)
 create mode 100644 client/tools/osad/osa-dispatcher.service

diff --git a/client/tools/osad/osa-dispatcher.service b/client/tools/osad/osa-dispatcher.service
new file mode 100644
index 0000000..92958e7
--- /dev/null
+++ b/client/tools/osad/osa-dispatcher.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=OSA Dispatcher daemon
+After=syslog.target network.target
+
+[Service]
+EnvironmentFile=-/etc/sysconfig/osa-dispatcher
+PIDFile=/var/run/osa-dispatcher.pid
+ExecStart=/usr/sbin/osa-dispatcher --pid-file $PIDFile
+
+[Install]
+WantedBy=multi-user.target
diff --git a/client/tools/osad/osad.spec b/client/tools/osad/osad.spec
index dd74885..bddffc0 100644
--- a/client/tools/osad/osad.spec
+++ b/client/tools/osad/osad.spec
@@ -144,8 +144,10 @@ touch %{buildroot}%{_var}/log/rhn/osa-dispatcher.log
 
 %if 0%{?fedora} || 0%{?rhel} > 5
 rm $RPM_BUILD_ROOT/%{_initrddir}/osad
+rm $RPM_BUILD_ROOT/%{_initrddir}/osa-dispatcher
 mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
 install -m 0644 osad.service $RPM_BUILD_ROOT/%{_unitdir}/
+install -m 0644 osa-dispatcher.service $RPM_BUILD_ROOT/%{_unitdir}/
 %endif
 
 %if 0%{?include_selinux_package}
@@ -269,7 +271,11 @@ rpm -ql osa-dispatcher | xargs -n 1 /sbin/restorecon -rvi {}
 %dir %{_sysconfdir}/rhn/tns_admin
 %dir %{_sysconfdir}/rhn/tns_admin/osa-dispatcher
 %config(noreplace) %{_sysconfdir}/rhn/tns_admin/osa-dispatcher/sqlnet.ora
+%if 0%{?fedora} || 0%{?rhel} > 5
+%{_unitdir}/osa-dispatcher.service
+%else
 %attr(755,root,root) %{_initrddir}/osa-dispatcher
+%endif
 %attr(770,root,%{apache_group}) %dir %{_var}/log/rhn/oracle
 %attr(770,root,root) %dir %{_var}/log/rhn/oracle/osa-dispatcher
 %doc LICENSE
-- 
1.7.10.4

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to