Add systemd support

This commit is contained in:
Vitezslav Crhonek 2012-05-21 15:19:34 +02:00
parent 9edd67429b
commit 845aee7949
2 changed files with 45 additions and 18 deletions

11
tog-pegasus.service Normal file
View File

@ -0,0 +1,11 @@
[Unit]
Description=OpenPegasus CIM Server
After=syslog.target
[Service]
Type=forking
ExecStart=/usr/sbin/cimserver
PIDFile=/var/run/tog-pegasus/cimserver.pid
[Install]
WantedBy=multi-user.target

View File

@ -8,7 +8,7 @@
Name: tog-pegasus
Version: %{major_ver}.1
Release: 5%{?dist}
Release: 6%{?dist}
Epoch: 2
Summary: OpenPegasus WBEM Services for Linux
@ -24,10 +24,9 @@ Source2: genOpenPegasusSSLCerts
Source3: README.RedHat.SSL
# 4: /etc/tmpfiles.d configuration file
Source4: tog-pegasus.tmpfiles
# 5: systemd service file
Source5: tog-pegasus.service
# 0: Still not fixed by http://cvs.rdg.opengroup.org/bugzilla/show_bug.cgi?id=5008
# Changes to the init script to make it LSB compliant
Patch0: pegasus-2.9.0-initscript.patch
# 1: http://cvs.rdg.opengroup.org/bugzilla/show_bug.cgi?id=5011
# Removing insecure -rpath
Patch1: pegasus-2.9.0-no-rpath.patch
@ -56,8 +55,6 @@ Patch12: pegasus-2.7.0-no_snmp_tests.patch
Patch13: pegasus-2.9.0-sparc.patch
# 16: Fixes "getpagesize" build error
Patch16: pegasus-2.9.1-getpagesize.patch
# 18: Let the makefile install initscript we want to use
Patch18: pegasus-2.9.1-makefile-initscript.patch
# 19: Don't strip binaries, add -g flag
Patch19: pegasus-2.10.0-dont-strip.patch
# 20: use posix locks on sparc arches
@ -70,6 +67,7 @@ BuildRequires: bash, sed, grep, coreutils, procps, gcc, gcc-c++
BuildRequires: libstdc++, make, pam-devel
BuildRequires: openssl-devel >= 0.9.6
BuildRequires: net-snmp-devel, openslp-devel
BuildRequires: systemd-units
Requires: net-snmp
Requires: %{name}-libs = %{epoch}:%{version}-%{release}
Provides: cim-server
@ -187,9 +185,7 @@ The OpenPegasus WBEM tests for the OpenPegasus %{version} Linux rpm.
%patch12 -p1 -b .no_snmp_tests
%patch5 -p1 -b .local-or-remote-auth
%patch13 -p1 -b .sparc
%patch0 -p1 -b .initscript
%patch16 -p1 -b .getpagesize
%patch18 -p1 -b .makefile-initscript
%patch19 -p1 -b .dont-strip
%patch20 -p1 -b .sparc-locks
%patch21 -p1 -b .disable-privilege-separation
@ -250,9 +246,10 @@ make -f $PEGASUS_ROOT/Makefile.Release stage \
install -p -D -m 644 %{SOURCE4} $RPM_BUILD_ROOT/%{_sysconfdir}/tmpfiles.d/tog-pegasus.conf
%endif
# move files to right directories
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/
mv $RPM_BUILD_ROOT/etc/init.d/tog-pegasus $RPM_BUILD_ROOT/etc/rc.d/init.d/tog-pegasus
# remove SysV initscript, install .service file
rm -f $RPM_BUILD_ROOT/etc/init.d/tog-pegasus
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
install -p -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{_unitdir}/tog-pegasus.service
# cimserver_planned.conf is on the right place since 2.9.2 (update - not in 2.10.0)
#mv $RPM_BUILD_ROOT/var/lib/Pegasus/cimserver_planned.conf $RPM_BUILD_ROOT/etc/Pegasus/cimserver_planned.conf
mkdir -p $RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}
@ -289,7 +286,7 @@ rm -rf $RPM_BUILD_ROOT
%ghost %attr(0640, root, pegasus) /var/run/tog-pegasus/cimserver.pid
%ghost %attr(0640, root, pegasus) /var/run/tog-pegasus/cimserver_start.lock
%ghost %attr(1640,root,pegasus) /var/run/tog-pegasus/cimxml.socket
%attr(0755, root, pegasus) %config(noreplace) /etc/rc.d/init.d/tog-pegasus
%{_unitdir}/tog-pegasus.service
%defattr(0640, root, pegasus, 0750)
%ghost %attr(0640, root, pegasus) %config(noreplace) /etc/Pegasus/cimserver_current.conf
%ghost %config(noreplace) /etc/Pegasus/cimserver_planned.conf
@ -355,9 +352,18 @@ fi
%post
install -d -m 1750 -o root -g pegasus /var/run/tog-pegasus
/sbin/ldconfig;
/sbin/chkconfig --add tog-pegasus;
if [ $1 -ge 1 ]; then
echo `date` >> /var/lib/Pegasus/log/install.log 2>&1 || :;
if [ $1 -eq 1 ] ; then
# Initial installation
if [ ! -e /etc/Pegasus/ssl.cnf ] || [ ! -e /etc/Pegasus/server.pem ] ||
[ ! -e /etc/Pegasus/file.pem ] || [ ! -e /etc/Pegasus/client.pem ]; then
if [ -x /usr/share/Pegasus/scripts/genOpenPegasusSSLCerts ]; then
/usr/share/Pegasus/scripts/genOpenPegasusSSLCerts
fi;
fi;
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
if [ $1 -gt 1 ]; then
if [ -d /var/lib/Pegasus/prev_repository ]; then
# The user's old repository was moved to /var/lib/Pegasus/prev_repository, which
@ -365,20 +371,27 @@ if [ $1 -ge 1 ]; then
/usr/sbin/repupgrade 2>> /var/lib/Pegasus/log/install.log || :;
mv /var/lib/Pegasus/prev_repository /var/lib/Pegasus/prev_repository_`date '+%Y-%m-%d-%s.%N'`.rpmsave;
fi;
/sbin/service tog-pegasus condrestart >/dev/null 2>&1 || :;
/bin/systemctl try-restart tog-pegasus.service >/dev/null 2>&1 || :;
fi;
fi
:;
%preun
if [ $1 -eq 0 ]; then
/sbin/service tog-pegasus stop >/dev/null 2>&1 || :;
/sbin/chkconfig --del tog-pegasus >/dev/null 2>&1 || :;
if [ $1 -eq 0 ]; then
# Package removal, not upgrade
/bin/systemctl --no-reload disable tog-pegasus.service > /dev/null 2>&1 || :
/bin/systemctl stop tog-pegasus.service > /dev/null 2>&1 || :
rm -rf /var/run/tog-pegasus
fi
:;
%postun -p /sbin/ldconfig
%postun
/sbin/ldconfig
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
/bin/systemctl try-restart tog-pegasus.service >/dev/null 2>&1 || :
fi
%preun devel
if [ $1 -eq 0 ] ; then
@ -433,6 +446,9 @@ fi
%changelog
* Mon May 21 2012 Vitezslav Crhonek <vcrhonek@redhat.com> - 2:2.11.1-6
- Add systemd support
* Tue Feb 28 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2:2.11.1-5
- Rebuilt for c++ ABI breakage