[Ocfs2-tools-devel] [PATCH 05/14] ocfs2-tools: add systemd support
Eric Ren
zren at suse.com
Fri Apr 1 19:34:41 PDT 2016
Hello Junxiao,
Please see comments in lines:
On 04/01/2016 11:10 AM, Junxiao Bi wrote:
> 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 at 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 864a71eef4f4..3c8902ce42a6 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 e92884e3dac4..2526cdc004b3 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 000000000000..94e2b1a29993
> --- /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
Lately, we got this issue:
~~~
o2cb.service failes to start on boot:
ilias4:~ # journalctl -u o2cb
-- Logs begin at Do 2016-01-28 11:09:11 CET, end at Do 2016-01-28
11:56:40 CET. --
Jan 28 11:09:28 ilias4 systemd[1]:
[/usr/lib/systemd/system/o2cb.service:11] Unknown lvalue 'ExecRestart'
in section 'Service'
Jan 28 11:09:33 ilias4 o2cb.init[1418]: Writing O2CB configuration: OK
Jan 28 11:09:33 ilias4 o2cb.init[1418]: checking debugfs...
Jan 28 11:09:33 ilias4 o2cb.init[1418]: Loading filesystem "configfs": OK
Jan 28 11:09:33 ilias4 o2cb.init[1418]: Mounting configfs filesystem at
/sys/kernel/config: mount: configfs is already mounted or
/sys/kernel/config busy
Jan 28 11:09:33 ilias4 o2cb.init[1418]: configfs is already mounted on
/sys/kernel/config
Jan 28 11:09:33 ilias4 o2cb.init[1418]: Unable to mount configfs filesystem
Jan 28 11:09:33 ilias4 o2cb.init[1418]: Failed
~~~
1. Systemd may hasn't "ExecRestart" anymore, for reference:
[1] https://techdetails.agwego.com/2013/06/07/227/
2. Maybe, we should adjust /sbin/o2cb.init for systemd than just a move,
because SysV init scripts need handling dependency like configfs on
itself. But systemd just requires adding "After
sys-kernel-config.mount", for reference:
[2]
https://github.com/systemd/systemd/blob/master/units/sys-kernel-config.mount
[3] http://0pointer.de/blog/projects/systemd-for-admins-3.html
Eric
> +
> +[Install]
> +WantedBy=multi-user.target
> diff --git a/vendor/common/ocfs2-tools.spec-generic.in b/vendor/common/ocfs2-tools.spec-generic.in
> index 4fabc8ca2406..9527908a8fb8 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 at oracle.com>
> +- Add systemd support
> +
> * Thu Jan 27 2005 Manish Singh <manish.singh at oracle.com>
> - Add ocfs2console
>
> diff --git a/vendor/common/ocfs2.service b/vendor/common/ocfs2.service
> new file mode 100644
> index 000000000000..768f80676c47
> --- /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 025de08621cc..a3002afe04d7 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 6a78602cfd5b..ba9c4f09092f 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 db9fde16946d..64d03fdeeb99 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 2245f440176b..5ce8e05582db 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 fb5b591007af..815600047d29 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 8f4a470038a6..20144a3be31c 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 b8fc25e6c47a..cc3925b97b21 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 85969eae18ec..56b1feb6483f 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 8cb0482cdf14..56be69f602f5 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
>
>
More information about the Ocfs2-tools-devel
mailing list