[openwsman] Add systemd support
vcrhonek
vcrhonek at fedoraproject.org
Wed May 23 12:47:29 UTC 2012
commit 797f4654675e16a67eaa5ce8bb24d15731785e2e
Author: Vitezslav Crhonek <vcrhonek at redhat.com>
Date: Wed May 23 14:47:20 2012 +0200
Add systemd support
openwsman.service | 12 ++++++++++++
openwsman.spec | 34 ++++++++++++++++++++++------------
owsmantestcert.sh | 21 +++++++++++++++++++++
3 files changed, 55 insertions(+), 12 deletions(-)
---
diff --git a/openwsman.service b/openwsman.service
new file mode 100644
index 0000000..142cd5b
--- /dev/null
+++ b/openwsman.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Openwsman WS-Management Service
+After=syslog.target
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/openwsmand
+ExecStartPre=/etc/openwsman/owsmantestcert.sh
+PIDFile=/var/run/wsmand.pid
+
+[Install]
+WantedBy=multi-user.target
diff --git a/openwsman.spec b/openwsman.spec
index 7f59947..93945dc 100644
--- a/openwsman.spec
+++ b/openwsman.spec
@@ -13,8 +13,9 @@ BuildRequires: libcurl-devel libxml2-devel pam-devel sblim-sfcc-devel
BuildRequires: python python-devel perl
BuildRequires: perl-devel pkgconfig openssl-devel
BuildRequires: cmake
+BuildRequires: systemd-units
Version: 2.3.0
-Release: 1%{?dist}
+Release: 2%{?dist}
Url: http://www.openwsman.org/
License: BSD
Group: Applications/System
@@ -22,8 +23,11 @@ Summary: Open source Implementation of WS-Management
Source: http://downloads.sourceforge.net/project/openwsman/%{name}/%{version}/%{name}-%{version}.tar.bz2
# help2man generated manpage for openwsmand binary
Source1: openwsmand.8.gz
+# service file for systemd
+Source2: openwsman.service
+# script for testing presence of the certificates in ExecStartPre
+Source3: owsmantestcert.sh
Patch0: %{name}-sitelibdir.patch
-Patch1: openwsman-2.2.3-initscript.patch
Patch2: openwsman-2.2.7-disable-ruby.patch
Patch3: openwsman-2.2.7-libssl.patch
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXXX)
@@ -138,7 +142,6 @@ This package provides Perl bindings to access the openwsman client API.
%setup -q
# don't make backup of file patched by patch0, it'll be installed...
%patch0 -p1
-%patch1 -p1 -b .initscript
%patch2 -p1
%patch3 -p1 -b .libssl
@@ -179,10 +182,10 @@ rm -f %{buildroot}/%{_libdir}/openwsman/authenticators/*.la
mkdir -p %{buildroot}%{_sysconfdir}/init.d
install -m 644 etc/openwsman.conf %{buildroot}/%{_sysconfdir}/openwsman
install -m 644 etc/openwsman_client.conf %{buildroot}/%{_sysconfdir}/openwsman
-mkdir -p %{buildroot}/%{_sysconfdir}/rc.d/init.d
-install -m 755 build/etc/init/openwsmand.sh %{buildroot}/%{_sysconfdir}/rc.d/init.d/openwsmand
+mkdir -p $RPM_BUILD_ROOT%{_unitdir}
+install -p -m 644 %{SOURCE2} %{buildroot}/%{_unitdir}/openwsman.service
install -m 644 etc/ssleay.cnf %{buildroot}/%{_sysconfdir}/openwsman
-ln -sf %{_sysconfdir}/rc.d/init.d/openwsmand %{buildroot}/%{_sbindir}/rcopenwsmand
+install -p -m 755 %{SOURCE3} %{buildroot}/%{_sysconfdir}/openwsman
# install manpage
mkdir -p %{buildroot}/%{_mandir}/man8/
cp %SOURCE1 %{buildroot}/%{_mandir}/man8/
@@ -200,19 +203,23 @@ rm -rf %{buildroot}
%post server
/sbin/ldconfig
-/sbin/chkconfig --add openwsmand
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
%preun server
if [ $1 = 0 ] ; then
- /sbin/service %{name}d stop >/dev/null 2>&1
- /sbin/chkconfig --del openwsmand
+ /bin/systemctl --no-reload disable openwsman.service > /dev/null 2>&1 || :
+ /bin/systemctl stop openwsman.service > /dev/null 2>&1 || :
fi
%postun server
rm -f /var/log/wsmand.log
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ "$1" -ge "1" ] ; then
- /sbin/service %{name}d condrestart >/dev/null 2>&1 || :
+ /bin/systemctl try-restart openwsman.service >/dev/null 2>&1 || :
fi
/sbin/ldconfig
@@ -264,8 +271,9 @@ fi
%config(noreplace) %{_sysconfdir}/openwsman/openwsman.conf
%config(noreplace) %{_sysconfdir}/openwsman/ssleay.cnf
%attr(0755,root,root) %{_sysconfdir}/openwsman/owsmangencert.sh
+%attr(0755,root,root) %{_sysconfdir}/openwsman/owsmantestcert.sh
%config(noreplace) %{_sysconfdir}/pam.d/openwsman
-%attr(0755,root,root) %{_sysconfdir}/rc.d/init.d/openwsmand
+%{_unitdir}/openwsman.service
%dir %{_libdir}/openwsman
%dir %{_libdir}/openwsman/authenticators
%{_libdir}/openwsman/authenticators/*.so
@@ -274,7 +282,6 @@ fi
%{_libdir}/openwsman/plugins/*.so
%{_libdir}/openwsman/plugins/*.so.*
%{_sbindir}/openwsmand
-%{_sbindir}/rcopenwsmand
%{_libdir}/libwsman_server.so.*
%{_mandir}/man8/*
%doc AUTHORS COPYING ChangeLog README.md
@@ -287,6 +294,9 @@ fi
%changelog
+* Wed May 23 2012 Vitezslav Crhonek <vcrhonek at redhat.com> - 2.3.0-2
+- Add systemd support
+
* Tue Mar 27 2012 Vitezslav Crhonek <vcrhonek at redhat.com> - 2.3.0-1
- Update to openwsman-2.3.0
diff --git a/owsmantestcert.sh b/owsmantestcert.sh
new file mode 100644
index 0000000..8918f41
--- /dev/null
+++ b/owsmantestcert.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+if [ ! -f "/etc/openwsman/serverkey.pem" ]; then
+ if [ -f "/etc/ssl/servercerts/servercert.pem" \
+ -a -f "/etc/ssl/servercerts/serverkey.pem" ]; then
+ echo "Using common server certificate /etc/ssl/servercerts/servercert.pem"
+ ln -s /etc/ssl/servercerts/server{cert,key}.pem /etc/openwsman
+ exit 0
+ else
+ echo "FAILED: Starting openwsman server"
+ echo "There is no ssl server key available for openwsman server to use."
+ echo -e "Please generate one with the following script and start the openwsman service again:\n"
+ echo "##################################"
+ echo "/etc/openwsman/owsmangencert.sh"
+ echo "================================="
+
+ echo "NOTE: The script uses /dev/random device for generating some random bits while generating the server key."
+ echo " If this takes too long, you can replace the value of \"RANDFILE\" in /etc/openwsman/ssleay.cnf with /dev/urandom. Please understand the implications of replacing the RNADFILE."
+ exit 1
+ fi
+fi
More information about the scm-commits
mailing list