[openhpi-subagent] convert from initscript to systemd unit
Dan Horák
sharkcz at fedoraproject.org
Thu Mar 22 15:14:25 UTC 2012
commit 31249031265d9c3b085077e10625b5d33f766fb5
Author: Dan Horák <dan at danny.cz>
Date: Thu Mar 22 16:14:04 2012 +0100
convert from initscript to systemd unit
openhpi-subagent.initd | 102 --------------------------------------------
openhpi-subagent.service | 10 ++++
openhpi-subagent.spec | 48 ++++++++++----------
openhpi-subagent.sysconfig | 4 --
4 files changed, 34 insertions(+), 130 deletions(-)
---
diff --git a/openhpi-subagent.service b/openhpi-subagent.service
new file mode 100644
index 0000000..f4b1757
--- /dev/null
+++ b/openhpi-subagent.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Hardware Platform Interface SNMP subagent
+After=syslog.target
+
+[Service]
+Type=forking
+ExecStart=/usr/bin/hpiSubagent -f
+
+[Install]
+WantedBy=multi-user.target
diff --git a/openhpi-subagent.spec b/openhpi-subagent.spec
index 6ac9dd6..b1d8ed4 100644
--- a/openhpi-subagent.spec
+++ b/openhpi-subagent.spec
@@ -7,8 +7,7 @@ Group: System Environment/Base
License: BSD
URL: http://www.openhpi.org
Source0: http://downloads.sourceforge.net/openhpi/%{name}-%{version}.tar.gz
-Source1: %{name}.initd
-Source2: %{name}.sysconfig
+Source1: %{name}.service
# https://sourceforge.net/tracker/?func=detail&aid=2849869&group_id=71730&atid=532251
Patch1: %{name}-2.3.4-format.patch
# https://sourceforge.net/tracker/?func=detail&aid=2951290&group_id=71730&atid=532251
@@ -16,14 +15,15 @@ Patch1: %{name}-2.3.4-format.patch
Patch2: %{name}-2.3.4-dso.patch
# disable -Werror as gcc >= 4.6 is too strict for our code
Patch3: %{name}-2.3.4-no-werror.patch
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires: openhpi-devel >= 2.10, net-snmp-devel, openssl-devel
+BuildRequires: openhpi-devel
+BuildRequires: net-snmp-devel
+BuildRequires: openssl-devel
BuildRequires: docbook-utils
-Requires(post): /sbin/chkconfig
-Requires(preun): /sbin/chkconfig
-Requires(preun): /sbin/service
-Requires(postun): /sbin/service
+BuildRequires: systemd-units
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
%description
The openhpi-subagent package contains the Service Availability Forum's
@@ -47,46 +47,46 @@ make -C docs subagent-manual/book1.html
%install
-rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
rm -f $RPM_BUILD_ROOT%{_sysconfdir}/init.d/%{name}
-mkdir -p $RPM_BUILD_ROOT%{_initddir}
-install -p -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_initddir}/%{name}
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
-install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}
+mkdir -p $RPM_BUILD_ROOT%{_unitdir}
+install -p -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service
-%clean
-rm -rf $RPM_BUILD_ROOT
-
%post
-/sbin/chkconfig --add %{name}
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
%preun
-if [ $1 = 0 ] ; then
- /sbin/service %{name} stop >/dev/null 2>&1
- /sbin/chkconfig --del %{name}
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable openhpid-subagent.service > /dev/null 2>&1 || :
+ /bin/systemctl stop openhpid-subagent.service > /dev/null 2>&1 || :
fi
%postun
-if [ "$1" -ge "1" ] ; then
- /sbin/service %{name} condrestart >/dev/null 2>&1
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart openhpid-subagent.service >/dev/null 2>&1 || :
fi
%files
%defattr(-,root,root,-)
%doc COPYING README docs/subagent-manual
-%{_initddir}/%{name}
+%{_unitdir}/%{name}.service
%config(noreplace) %{_sysconfdir}/snmp/hpiSubagent.conf
-%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_bindir}/hpiSubagent
%{_datadir}/snmp/mibs/*.mib
%changelog
* Thu Mar 22 2012 Dan Horák <dan[at]danny.cz> - 2.3.4-18
- rebuilt against openhpi 3.0
+- convert from initscript to systemd unit
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.3.4-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
More information about the scm-commits
mailing list