From 85b7dd53be6acaa0ba074ba0716254b21762c1090bc26f81ae02e42a556a6004 Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Fri, 20 Jan 2012 00:08:24 +0000 Subject: [PATCH] - Add support for systemd - Add /etc/sysconfig/sanlock configuration file OBS-URL: https://build.opensuse.org/package/show/Virtualization/sanlock?expand=0&rev=3 --- sanlock.changes | 6 ++++++ sanlock.init | 2 +- sanlock.spec | 47 ++++++++++++++++++++++++++++++++++++++++++---- suse-systemd.patch | 31 ++++++++++++++++++++++++++++++ sysconfig.sanlock | 10 ++++++++++ 5 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 suse-systemd.patch create mode 100644 sysconfig.sanlock diff --git a/sanlock.changes b/sanlock.changes index 73382c1..27f625d 100644 --- a/sanlock.changes +++ b/sanlock.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Jan 19 17:05:58 MST 2012 - jfehlig@suse.com + +- Add support for systemd +- Add /etc/sysconfig/sanlock configuration file + ------------------------------------------------------------------- Thu Jan 19 16:23:03 MST 2012 - jfehlig@suse.com diff --git a/sanlock.init b/sanlock.init index 269b488..85cee76 100644 --- a/sanlock.init +++ b/sanlock.init @@ -37,7 +37,7 @@ case "$1" in fi fi echo -n "Starting sanlock " - startproc $SANLOCK_BIN daemon $SANLOCKOPTS + startproc $SANLOCK_BIN daemon $SANLOCK_OPTS rc_status -v ;; stop) diff --git a/sanlock.spec b/sanlock.spec index 0d2dbdb..a507dfc 100644 --- a/sanlock.spec +++ b/sanlock.spec @@ -15,6 +15,12 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # +%define with_systemd 0 +%if 0%{?suse_version} > 1140 +%define with_systemd 1 +%endif + + Name: sanlock Version: 1.9 Release: 1%{?dist} @@ -25,13 +31,19 @@ License: GPLv2, GPLv2+, LGPLv2+ URL: https://fedorahosted.org/sanlock/ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: libblkid-devel libaio-devel python python-devel +%if %{with_systemd} +BuildRequires: systemd +%{?systemd_requires} +%endif Requires: %{name}-lib = %{version}-%{release} Source0: https://fedorahosted.org/releases/s/a/sanlock/%{name}-%{version}.tar.gz Source1: sanlock.init Source2: wdmd.init +Source3: sysconfig.sanlock Patch0: sanlock-SCHED_RESET_ON_FORK-undefined.patch Patch1: sanlock-python-prefix.patch Patch2: sanlock-old_blkid.patch +Patch3: suse-systemd.patch %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} @@ -45,6 +57,7 @@ access to the shared disks. %patch0 %patch1 %patch2 +%patch3 -p1 %build # upstream does not require configure @@ -64,7 +77,12 @@ make -C python \ install LIBDIR=%{_libdir} \ DESTDIR=$RPM_BUILD_ROOT PREFIX=%_prefix install -D -m 755 %SOURCE1 $RPM_BUILD_ROOT/etc/init.d/sanlock +install -D -m 755 %SOURCE1 $RPM_BUILD_ROOT/$(localstatedir)/adm/fillup-templates/sysconfig.sanlock install -D -m 755 %SOURCE2 $RPM_BUILD_ROOT/etc/init.d/wdmd +%if %{with_systemd} +install -D -m 755 init.d/sanlock.service $RPM_BUILD_ROOT/%{_unitdir}/sanlock.service +install -D -m 755 init.d/wdmd.service $RPM_BUILD_ROOT/%{_unitdir}/wdmd.service +%endif %clean rm -rf $RPM_BUILD_ROOT @@ -72,14 +90,25 @@ rm -rf $RPM_BUILD_ROOT %pre /usr/sbin/useradd -u 179 -g 179 -c "sanlock" -s /sbin/nologin -r \ -d /var/run/sanlock sanlock 2> /dev/null || : +%if %{with_systemd} +%service_add_pre wdmd.service +%service_add_pre sanlock.service +%endif -##%post -##/sbin/chkconfig --add sanlock -##/sbin/chkconfig --add wdmd +%post +%if %{with_systemd} +%service_add_post wdmd.service sanlock.service +%else +%{fillup_only -n sanlock} +%endif %preun -%{stop_on_removal sanlock} +%if %{with_systemd} +%service_del_preun wdmd.service sanlock.service +%else %{stop_on_removal wdmd} +%{stop_on_removal sanlock} +%endif ##if [ $1 = 0 ]; then ## /sbin/service sanlock stop > /dev/null 2>&1 ## /sbin/service wdmd stop > /dev/null 2>&1 @@ -88,6 +117,12 @@ rm -rf $RPM_BUILD_ROOT ##fi %postun +%if %{with_systemd} +%service_del_postun wdmd.service sanlock.service +%else +%restart_on_update wdmd +%restart_on_update sanlock +%endif %{insserv_cleanup} #/sbin/service sanlock condrestart >/dev/null 2>&1 || : #/sbin/service wdmd condrestart >/dev/null 2>&1 || : @@ -96,6 +131,10 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root,-) /etc/init.d/sanlock /etc/init.d/wdmd +%if %{with_systemd} +%{_unitdir}/sanlock.service +%{_unitdir}/wdmd.service +%endif %{_sbindir}/sanlock %{_sbindir}/wdmd %{_mandir}/man8/wdmd* diff --git a/suse-systemd.patch b/suse-systemd.patch new file mode 100644 index 0000000..1221d51 --- /dev/null +++ b/suse-systemd.patch @@ -0,0 +1,31 @@ +Index: sanlock-1.9/init.d/sanlock.service +=================================================================== +--- sanlock-1.9.orig/init.d/sanlock.service ++++ sanlock-1.9/init.d/sanlock.service +@@ -3,8 +3,9 @@ After=syslog.target wdmd.service + + [Service] + Type=forking +-ExecStart=/lib/systemd/systemd-sanlock start +-ExecStop=/lib/systemd/systemd-sanlock stop ++EnvironmentFile=-/etc/sysconfig/sanlock ++ExecStart=/usr/sbin/sanlock daemon $SANLOCKOPTS ++ExecReload=/bin/kill -HUP $MAINPID + + [Install] + WantedBy=multi-user.target +Index: sanlock-1.9/init.d/wdmd.service +=================================================================== +--- sanlock-1.9.orig/init.d/wdmd.service ++++ sanlock-1.9/init.d/wdmd.service +@@ -3,8 +3,8 @@ After=syslog.target + + [Service] + Type=forking +-ExecStart=/lib/systemd/systemd-wdmd start +-ExecStop=/lib/systemd/systemd-wdmd stop ++ExecStart=/usr/sbin/wdmd ++ExecReload=/bin/kill -HUP $MAINPID + + [Install] + WantedBy=multi-user.target diff --git a/sysconfig.sanlock b/sysconfig.sanlock new file mode 100644 index 0000000..80bb2a4 --- /dev/null +++ b/sysconfig.sanlock @@ -0,0 +1,10 @@ +## Path: System/Virtualization/sanlock + +## Type: string +## Default: "" +# Options passed to sanlock daemon, see man sanlock(8) +# E.g. to use sanlock without the watchdog multiplexing +# daemon set SANLOCK_OPTS as follows +# +# SANLOCK_OPTS="-w 0" +SANLOCK_OPTS="" \ No newline at end of file