[glusterfs] BZ 748442 convert init.d to systemd for f17 and beyond (Will let this soak in rawhide for a while be

Kaleb S. KEITHLEY kkeithle at fedoraproject.org
Wed Nov 2 18:09:30 UTC 2011


commit ff4f8fdd5ca4b3db6736bec340b32a4cea6195af
Author: Kaleb S. KEITHLEY <kkeithle at redhat.com>
Date:   Wed Nov 2 14:05:43 2011 -0400

    BZ 748442
    convert init.d to systemd for f17 and beyond
    (Will let this soak in rawhide for a while before merging to f16.
    N.B. f16 continues to use init.d forever; the spec file installs
    init.d file for 16 and earlier, systemd files for f17 and later.)

 glusterd.service   |   13 +++++++
 glusterfs.spec     |   98 ++++++++++++++++++++++++++++++++++-----------------
 glusterfsd.service |   12 ++++++
 3 files changed, 90 insertions(+), 33 deletions(-)
---
diff --git a/glusterd.service b/glusterd.service
new file mode 100644
index 0000000..4bf3ea1
--- /dev/null
+++ b/glusterd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=GlusterFS an clustered file-system server
+Wants=glusterfsd.service
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/glusterd.pid
+LimitNOFILE=65536
+ExecStart=/usr/sbin/glusterd -p /run/glusterd.pid 
+
+[Install]
+WantedBy=multi-user.target
diff --git a/glusterfs.spec b/glusterfs.spec
index 7bcdf04..8e232a3 100644
--- a/glusterfs.spec
+++ b/glusterfs.spec
@@ -9,22 +9,27 @@
 
 Name:             glusterfs
 Version:          3.2.4
-Release:          1%{?dist}
+Release:          2%{?dist}
 Summary:          Clustered file-system
 
 Group:            System Environment/Base
 License:          AGPLv3
 URL:              http://www.gluster.org/
 Source0:          http://download.gluster.com/pub/gluster/glusterfs/3.2/%{version}/glusterfs-%{version}.tar.gz
-Source1:          glusterd.init
-Source2:          glusterd.sysconfig
+Source1:          glusterd.sysconfig
+Source2:          glusterfsd.sysconfig
 Source3:          umount.glusterfs
 Source4:          glusterfs-fuse.logrotate
 Source5:          glusterd.logrotate
+Source6:          glusterfsd.logrotate
+%if 0%{?fedora} < 17
 # Legacy server
-Source11:         glusterfsd.init
-Source12:         glusterfsd.sysconfig
-Source15:         glusterfsd.logrotate
+Source7:          glusterd.init
+Source8:          glusterfsd.init
+%else
+Source7:          glusterd.service
+Source8:          glusterfsd.service
+%endif
 BuildRoot:        %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 
 BuildRequires:    bison
@@ -33,10 +38,24 @@ BuildRequires:    gcc
 BuildRequires:    make
 BuildRequires:    ncurses-devel, readline-devel, python-ctypes
 
+%if 0%{?fedora} < 17
 Requires(post):   /sbin/chkconfig
 Requires(preun):  /sbin/service
 Requires(preun):  /sbin/chkconfig
 Requires(postun): /sbin/service
+%define _daemon_enable()  /sbin/chkconfig --add %1 ;
+%define _daemon_disable() /sbin/chkconfig --del %1 ;
+%define _daemon_restart() /sbin/service %1 condrestart &>/dev/null ;
+%define _daemon_stop()    /sbin/service %1 stop &>/dev/null ;
+%else
+Requires(post):   systemd-units
+Requires(preun):  systemd-units
+Requires(postun): systemd-units
+%define _daemon_enable()  /bin/systemctl enable %1.service ;
+%define _daemon_disable() /bin/systemctl disable %1.service ;
+%define _daemon_restart() /bin/systemctl try-restart %1.service ;
+%define _daemon_stop()    /bin/systemctl stop %1.service ;
+%endif
 
 Obsoletes:        %{name}-libs <= 2.0.0
 Obsoletes:        %{name}-common < 3.1.0
@@ -191,8 +210,13 @@ sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
 find %{buildroot}%{_libdir} -name '*.a' -delete
 find %{buildroot}%{_libdir} -name '*.la' -delete
 
-# Remove what the `make install` did, %%doc will install later
-%{__rm} -rf %{buildroot}%{_datadir}/doc/glusterfs
+# Remove installed docs, we include them ourselves as %%doc
+%{__rm} -rf %{buildroot}%{_datadir}/doc/glusterfs/
+
+# Rename the samples, so we can include them as %%config
+for file in %{buildroot}%{_sysconfdir}/glusterfs/*.sample; do
+  %{__mv} ${file} `dirname ${file}`/`basename ${file} .sample`
+done
 
 # Create working directory
 %{__mkdir_p} %{buildroot}%{_sharedstatedir}/glusterd
@@ -206,14 +230,21 @@ sed -i 's|option working-directory /etc/glusterd|option working-directory %{_sha
 %{__rm} -f examples/Makefile*
 
 # Install init script and sysconfig file
-%{__install} -D -p -m 0755 %{SOURCE1} \
-    %{buildroot}%{_sysconfdir}/init.d/glusterd
-%{__install} -D -p -m 0644 %{SOURCE2} \
-    %{buildroot}%{_sysconfdir}/sysconfig/glusterd
+%if 0%{?fedora} < 17
 # Legacy init script and sysconfig file
-%{__install} -D -p -m 0755 %{SOURCE11} \
+%{__install} -D -p -m 0755 %{SOURCE7} \
+    %{buildroot}%{_sysconfdir}/init.d/glusterd
+%{__install} -D -p -m 0755 %{SOURCE8} \
     %{buildroot}%{_sysconfdir}/init.d/glusterfsd
-%{__install} -D -p -m 0644 %{SOURCE12} \
+%else
+%{__install} -D -p -m 0644 %{SOURCE7} \
+    %{buildroot}%{_unitdir}/glusterd.service
+%{__install} -D -p -m 0644 %{SOURCE8} \
+    %{buildroot}%{_unitdir}/glusterfsd.service
+%endif
+%{__install} -D -p -m 0644 %{SOURCE1} \
+    %{buildroot}%{_sysconfdir}/sysconfig/glusterd
+%{__install} -D -p -m 0644 %{SOURCE2} \
     %{buildroot}%{_sysconfdir}/sysconfig/glusterfsd
 
 # Install wrapper umount script
@@ -227,7 +258,7 @@ sed -i 's|option working-directory /etc/glusterd|option working-directory %{_sha
 %{__install} -D -p -m 0644 %{SOURCE5} \
     %{buildroot}%{_sysconfdir}/logrotate.d/glusterd
 # Legacy server logrotate entry
-%{__install} -D -p -m 0644 %{SOURCE15} \
+%{__install} -D -p -m 0644 %{SOURCE6} \
     %{buildroot}%{_sysconfdir}/logrotate.d/glusterfsd
 
 # Install vim syntax plugin
@@ -275,7 +306,7 @@ sed -i 's|option working-directory /etc/glusterd|option working-directory %{_sha
 
 %files server
 %defattr(-,root,root,-)
-%doc examples/{*.vol,README} doc/*.sample
+%doc examples/ doc/glusterfs*.vol.sample
 %config(noreplace) %{_sysconfdir}/logrotate.d/glusterd
 %config(noreplace) %{_sysconfdir}/sysconfig/glusterd
 %config(noreplace) %{_sysconfdir}/glusterfs
@@ -283,9 +314,14 @@ sed -i 's|option working-directory /etc/glusterd|option working-directory %{_sha
 %config(noreplace) %{_sysconfdir}/logrotate.d/glusterfsd
 %config(noreplace) %{_sysconfdir}/sysconfig/glusterfsd
 %{_sharedstatedir}/glusterd
-%{_sysconfdir}/init.d/glusterd
+%if 0%{?fedora} < 17
 # Legacy init
+%{_sysconfdir}/init.d/glusterd
 %{_sysconfdir}/init.d/glusterfsd
+%else
+%{_unitdir}/glusterd.service
+%{_unitdir}/glusterfsd.service
+%endif
 
 %files vim
 %defattr(-,root,root,-)
@@ -303,32 +339,28 @@ sed -i 's|option working-directory /etc/glusterd|option working-directory %{_sha
 %postun -p /sbin/ldconfig
 
 %post server
-/sbin/chkconfig --add glusterd
-
 # Legacy server
-/sbin/chkconfig --add glusterfsd
+%_daemon_enable glusterd
+%_daemon_enable glusterfsd
 
 %preun server
 if [ $1 -eq 0 ]; then
-    /sbin/service glusterd stop &>/dev/null || :
-    /sbin/chkconfig --del glusterd
-fi
-if [ $1 -ge 1 ]; then
-    /sbin/service glusterd condrestart &>/dev/null || :
-fi
-
-# Legacy server
-if [ $1 -eq 0 ]; then
-    /sbin/service glusterfsd stop &>/dev/null || :
-    /sbin/chkconfig --del glusterfsd
+    %_daemon_stop glusterfsd
+    %_daemon_stop glusterd
+    %_daemon_disable glusterfsd
+    %_daemon_disable glusterd
 fi
 if [ $1 -ge 1 ]; then
-    /sbin/service glusterfsd condrestart &>/dev/null || :
+    %_daemon_restart glusterd
+    %_daemon_restart glusterfsd
 fi
 
 %changelog
+* Fri Sep 30 2011 Kaleb S. KEITHLEY <kkeithle at redhat.com> - 3.2.4-2
+- Convert init.d to systemd for f17 and later
+
 * Fri Sep 30 2011 Kaleb S. KEITHLEY <kkeithle at redhat.com> - 3.2.4-1
-- Update to 3.2.4 
+- Update to 3.2.4
 
 * Mon Aug 22 2011 Kaleb S. KEITHLEY <kkeithle at redhat.com> - 3.2.3-1
 - Update to 3.2.3 
diff --git a/glusterfsd.service b/glusterfsd.service
new file mode 100644
index 0000000..4454ad8
--- /dev/null
+++ b/glusterfsd.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=GlusterFS an clustered file-system server
+After=network.target glusterd.service
+
+[Service]
+Type=forking
+PIDFile=/run/glusterfsd.pid
+LimitNOFILE=65536
+ExecStart=/usr/sbin/glusterfsd -p /run/glusterfsd.pid
+
+[Install]
+WantedBy=multi-user.target


More information about the scm-commits mailing list