ocfs2-tools/0004-add-systemd-support.patch
Goldwyn Rodrigues ba2ae35d8f Accepting request 330115 from home:ZRen:branches:network:ha-clustering:Factory
Add systemd support for o2cb and ocfs2 service. 

1. I've tested changes on opensuse13.2 and sle12 sp1. It works well. 
2. Backforward compatible.
3. It will be added into sle12 once it become mature in opensuse.

OBS-URL: https://build.opensuse.org/request/show/330115
OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/ocfs2-tools?expand=0&rev=84
2015-09-22 12:30:33 +00:00

310 lines
9.4 KiB
Diff

From: Junxiao Bi <junxiao.bi@oracle.com>
To: <ocfs2-tools-devel@oss.oracle.com>
Date: 6/29/2015 4:29 PM
Subject: [Ocfs2-tools-devel] [PATCH 2/6] ocfs2-tools: add systemd support
When systemd is enabled, the old way to start/stop/status service
should be disabled, so move /etc/init.d/o2cb and /etc/init.d/ocfs2
to /sbin.
Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
---
vendor/common/Makefile | 4 ++-
vendor/common/Vendor.make | 1 +
vendor/common/o2cb.service | 14 ++++++++
vendor/common/ocfs2-tools.spec-generic.in | 55 +++++++++++++++++++++++------
vendor/common/ocfs2.service | 14 ++++++++
vendor/fc7/Vendor.make | 1 +
vendor/fc8/Vendor.make | 1 +
vendor/fc9/Vendor.make | 1 +
vendor/rhel4/Vendor.make | 1 +
vendor/rhel5/Vendor.make | 1 +
vendor/rhel6/Vendor.make | 1 +
vendor/rhel7/Vendor.make | 1 +
vendor/sles10/Vendor.make | 1 +
vendor/sles9/Vendor.make | 1 +
14 files changed, 85 insertions(+), 12 deletions(-)
create mode 100644 vendor/common/o2cb.service
create mode 100644 vendor/common/ocfs2.service
diff --git a/vendor/common/Makefile b/vendor/common/Makefile
index 864a71e..3c8902c 100644
--- a/vendor/common/Makefile
+++ b/vendor/common/Makefile
@@ -25,6 +25,8 @@ DIST_FILES = \
ocfs2-tools.spec-generic.in \
51-ocfs2.rules \
Vendor.make \
- o2cb.sysconfig.5.in
+ o2cb.sysconfig.5.in \
+ o2cb.service \
+ ocfs2.service
include $(TOPDIR)/Postamble.make
diff --git a/vendor/common/Vendor.make b/vendor/common/Vendor.make
index e92884e..2526cdc 100644
--- a/vendor/common/Vendor.make
+++ b/vendor/common/Vendor.make
@@ -20,6 +20,7 @@ $(TOPDIR)/ocfs2-tools-$(DIST_VERSION)-$(PKG_VERSION).$(VENDOR_EXTENSION).src.rpm
-e 's,@@PYVERSION@@,'$(PYVERSION)',g' \
-e 's,@@COMPILE_PY@@,'$(COMPILE_PY)',g' \
-e 's,@@CHKCONFIG_DEP@@,'$(CHKCONFIG_DEP)',g' \
+ -e 's,@@SYSTEMD_ENABLED@@,'$(SYSTEMD_ENABLED)',g' \
< "$(TOPDIR)/vendor/common/ocfs2-tools.spec-generic" \
> "$(TOPDIR)/vendor/common/ocfs2-tools.spec"
$(RPMBUILD) -bs --define "_sourcedir $(RPM_TOPDIR)" --define "_srcrpmdir $(RPM_TOPDIR)" "$(TOPDIR)/vendor/common/ocfs2-tools.spec"
diff --git a/vendor/common/o2cb.service b/vendor/common/o2cb.service
new file mode 100644
index 0000000..94e2b1a
--- /dev/null
+++ b/vendor/common/o2cb.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Load o2cb Modules
+Requires=network.service
+After=network.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/sbin/o2cb.init enable
+ExecStop=/sbin/o2cb.init disable
+ExecRestart=/sbin/o2cb.init restart
+
+[Install]
+WantedBy=multi-user.target
diff --git a/vendor/common/ocfs2-tools.spec-generic.in b/vendor/common/ocfs2-tools.spec-generic.in
index 4fabc8c..9527908 100644
--- a/vendor/common/ocfs2-tools.spec-generic.in
+++ b/vendor/common/ocfs2-tools.spec-generic.in
@@ -17,6 +17,7 @@
%define build_ocfs2console 0
%define compile_py 0
+%define systemd_enabled @@SYSTEMD_ENABLED@@
%if %{build_ocfs2console}
%define compile_py @@COMPILE_PY@@
@@ -80,9 +81,18 @@ make
%install
-mkdir -p $RPM_BUILD_ROOT/etc/init.d
-cp -f vendor/common/o2cb.init $RPM_BUILD_ROOT/etc/init.d/o2cb
-cp -f vendor/common/ocfs2.init $RPM_BUILD_ROOT/etc/init.d/ocfs2
+%if %{systemd_enabled}
+ mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system
+ cp -f vendor/common/o2cb.service $RPM_BUILD_ROOT/usr/lib/systemd/system/
+ cp -f vendor/common/ocfs2.service $RPM_BUILD_ROOT/usr/lib/systemd/system/
+ mkdir -p $RPM_BUILD_ROOT/sbin
+ cp -f vendor/common/o2cb.init $RPM_BUILD_ROOT/sbin
+ cp -f vendor/common/ocfs2.init $RPM_BUILD_ROOT/sbin
+%else
+ mkdir -p $RPM_BUILD_ROOT/etc/init.d
+ cp -f vendor/common/o2cb.init $RPM_BUILD_ROOT/etc/init.d/o2cb
+ cp -f vendor/common/ocfs2.init $RPM_BUILD_ROOT/etc/init.d/ocfs2
+%endif
if [ -f /etc/redhat-release ]
then
# Red Hat chkconfig is completely and utterly broken
@@ -104,14 +114,27 @@ rm -rf "$RPM_BUILD_ROOT"
%post
-/sbin/chkconfig --add o2cb >/dev/null
-/sbin/chkconfig --add ocfs2 >/dev/null
+%if !%{systemd_enabled}
+ /sbin/chkconfig --add o2cb >/dev/null
+ /sbin/chkconfig --add ocfs2 >/dev/null
+%else
+ # clean up start/kill entry in /etc/rc*.d/ when upgrade.
+ if [ -f /etc/init.d/o2cb ]; then
+ /sbin/chkconfig --del o2cb >/dev/null
+ fi
+
+ if [ -f /etc/init.d/ocfs2 ]; then
+ /sbin/chkconfig --del ocfs2 >/dev/null
+ fi
+%endif
%preun
-if [ $1 = 0 ]; then # execute this only if we are NOT doing an upgrade
- /sbin/chkconfig --del ocfs2 >/dev/null
- /sbin/chkconfig --del o2cb >/dev/null
-fi
+%if !%{systemd_enabled}
+ if [ $1 = 0 ]; then # execute this only if we are NOT doing an upgrade
+ /sbin/chkconfig --del ocfs2 >/dev/null
+ /sbin/chkconfig --del o2cb >/dev/null
+ fi
+%endif
%files
%defattr(-,root,root)
@@ -127,10 +150,17 @@ fi
/sbin/o2image
/sbin/o2cluster
/sbin/ocfs2_hb_ctl
-/usr/bin/o2info
-/usr/sbin/o2hbmonitor
+%if %{systemd_enabled}
+/sbin/o2cb.init
+/sbin/ocfs2.init
+/usr/lib/systemd/system/o2cb.service
+/usr/lib/systemd/system/ocfs2.service
+%else
/etc/init.d/o2cb
/etc/init.d/ocfs2
+%endif
+/usr/bin/o2info
+/usr/sbin/o2hbmonitor
%config(noreplace) /etc/sysconfig/o2cb
/usr/share/man/man8/debugfs.ocfs2.8.gz
/usr/share/man/man8/fsck.ocfs2.8.gz
@@ -172,6 +202,9 @@ fi
%changelog
+* Thu Jun 18 2015 Junxiao Bi <junxiao.bi@oracle.com>
+- Add systemd support
+
* Thu Jan 27 2005 Manish Singh <manish.singh@oracle.com>
- Add ocfs2console
diff --git a/vendor/common/ocfs2.service b/vendor/common/ocfs2.service
new file mode 100644
index 0000000..768f806
--- /dev/null
+++ b/vendor/common/ocfs2.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Load ocfs2 Modules
+Requires=o2cb.service
+After=o2cb.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/sbin/ocfs2.init start
+ExecStop=/sbin/ocfs2.init stop
+ExecReload=/sbin/ocfs2.init restart
+
+[Install]
+WantedBy=multi-user.target
diff --git a/vendor/fc7/Vendor.make b/vendor/fc7/Vendor.make
index 025de08..a3002af 100644
--- a/vendor/fc7/Vendor.make
+++ b/vendor/fc7/Vendor.make
@@ -4,6 +4,7 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/fc7/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = fc7
+SYSTEMD_ENABLED = 0
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/fc8/Vendor.make b/vendor/fc8/Vendor.make
index 6a78602..ba9c4f0 100644
--- a/vendor/fc8/Vendor.make
+++ b/vendor/fc8/Vendor.make
@@ -4,6 +4,7 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/fc8/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = fc8
+SYSTEMD_ENABLED = 0
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/fc9/Vendor.make b/vendor/fc9/Vendor.make
index db9fde1..64d03fd 100644
--- a/vendor/fc9/Vendor.make
+++ b/vendor/fc9/Vendor.make
@@ -4,6 +4,7 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/fc9/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = fc9
+SYSTEMD_ENABLED = 0
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/rhel4/Vendor.make b/vendor/rhel4/Vendor.make
index 2245f44..5ce8e05 100644
--- a/vendor/rhel4/Vendor.make
+++ b/vendor/rhel4/Vendor.make
@@ -4,6 +4,7 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/rhel4/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = el4
+SYSTEMD_ENABLED = 0
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/rhel5/Vendor.make b/vendor/rhel5/Vendor.make
index fb5b591..8156000 100644
--- a/vendor/rhel5/Vendor.make
+++ b/vendor/rhel5/Vendor.make
@@ -4,6 +4,7 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/rhel5/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = el5
+SYSTEMD_ENABLED = 0
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/rhel6/Vendor.make b/vendor/rhel6/Vendor.make
index 8f4a470..20144a3 100644
--- a/vendor/rhel6/Vendor.make
+++ b/vendor/rhel6/Vendor.make
@@ -4,6 +4,7 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/rhel6/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = el6
+SYSTEMD_ENABLED = 0
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/rhel7/Vendor.make b/vendor/rhel7/Vendor.make
index b8fc25e..cc3925b 100644
--- a/vendor/rhel7/Vendor.make
+++ b/vendor/rhel7/Vendor.make
@@ -4,6 +4,7 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/rhel7/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = el7
+SYSTEMD_ENABLED = 1
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/sles10/Vendor.make b/vendor/sles10/Vendor.make
index 85969ea..56b1feb 100644
--- a/vendor/sles10/Vendor.make
+++ b/vendor/sles10/Vendor.make
@@ -4,6 +4,7 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/sles10/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = SLE10
+SYSTEMD_ENABLED = 0
include $(TOPDIR)/vendor/common/Vendor.make
diff --git a/vendor/sles9/Vendor.make b/vendor/sles9/Vendor.make
index 8cb0482..56be69f 100644
--- a/vendor/sles9/Vendor.make
+++ b/vendor/sles9/Vendor.make
@@ -4,6 +4,7 @@
TOOLSARCH = $(shell $(TOPDIR)/vendor/sles9/rpmarch.guess tools $(TOPDIR))
VENDOR_EXTENSION = SLE9
+SYSTEMD_ENABLED = 0
include $(TOPDIR)/vendor/common/Vendor.make
--
1.7.9.5
_______________________________________________
Ocfs2-tools-devel mailing list
Ocfs2-tools-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel